Documented Incident · INC-2023-29374 · Critical severity

LangChain LLMMathChain Prompt Injection Arbitrary Python Code Execution

CVE-2023-29374 was one of the earliest high-profile LLM framework RCE CVEs, affecting LangChain's `LLMMathChain` (`numexpr` / Python `exec` fallback). Crafted natural-language prompts coerced the language model into returning arbitrary Python expressions rather than pure arithmetic, which the chain then executed directly on the host server. Attackers could read `/etc/passwd`, steal OpenAI API keys from `os.environ`, or establish reverse shells via a single chat prompt. Maintainers replaced unsafe Python evaluation with restricted AST expression parsing.

Incident dossier metadata

Case ID
INC-2023-29374
Classification
Incident
Date
Severity
Critical
Sector
Software Development & AI Tooling
Attack vector
Tool/MCP Abuse
System type
LLM Math Evaluation Chains
CVE / reference
CVE-2023-29374
Reference URI
https://nvd.nist.gov/vuln/detail/CVE-2023-29374

Inspect INC-2023-29374 in Interactive Incidents & Cases Hub

Defensive takeaway

Never pass model-generated math expressions into Python exec() or eval(); enforce strict numeric AST parsing for deterministic calculators.

Mapped AI security techniques

Mapped defensive controls

Source citation records