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
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
- Command and Scripting Interpreter AML.T0050
- LLM Prompt Injection: Direct AML.T0051.000
- AI Agent Tool Invocation AML.T0053
- Generate Malicious Commands AML.T0102
Mapped defensive controls
- Restrict Library Loading AML.M0011
- Enforce Access Controls for AI Agent Tools AML.M0028
- Input and Output Validation for AI Agent Components AML.M0033
Source citation records
- NVD Record CVE-2023-29374: LangChain LLMMathChain Arbitrary Code Execution · NIST National Vulnerability Database (NVD) ·