Toutes les vulnérabilités
CRITICALAI/LLMexploited in the wild

CVE-2023-29374

LangChain · langchain

Résumé

In LangChain, the LLMMathChain chain passes LLM-generated math expressions to Python's exec()/eval() to compute results. Because the input is not sanitized, an attacker can use prompt injection to make the model emit arbitrary Python instead of a math expression, which is then executed, resulting in remote code execution. The issue affects versions through 0.0.131 and is fixed in 0.0.142.

Comment l’éviter dans votre code

  • Upgrade LangChain to 0.0.142 or later to fix LLMMathChain code execution.
  • Avoid exec()/eval() on LLM output; use a safe math evaluator with no Python execution.
  • Treat model-generated expressions as untrusted data, not executable code.
  • Sandbox any required evaluation with least privilege and restricted egress.
  • Validate output against a strict math-expression grammar before computing.

Références

Vulnérabilités liées

Tout AI/LLM →