CVE-2023-29374
Python vulnerability analysis and mitigation

Overview

In LangChain through version 0.0.131, the LLMMathChain chain contains a critical security vulnerability that allows prompt injection attacks capable of executing arbitrary code via the Python exec method (NVD, GitHub Issue). The vulnerability was discovered and disclosed in early 2023, affecting all versions of LangChain up to and including 0.0.131.

Technical details

The vulnerability exists in the LLMMathChain component which uses Python's exec() function to evaluate mathematical expressions. This implementation allows attackers to inject malicious Python code that gets executed by the exec() function. The vulnerability has been assigned a CVSS v3.1 base score of 9.8 CRITICAL with vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (NVD).

Impact

The vulnerability allows attackers to execute arbitrary code on the system running LangChain. This can lead to unauthorized access to sensitive information, as demonstrated by proof-of-concept exploits that could extract API keys and environment variables. The high severity rating indicates potential for complete system compromise (GitHub Issue).

Mitigation and workarounds

The issue was addressed by replacing the unsafe exec() function with safer alternatives. Initially, a patch was proposed to use eval() instead of exec() (GitHub PR), but ultimately the solution implemented was to use the numexpr library for mathematical expression evaluation, which provides better security against code injection attacks.

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-67511CRITICAL9.6
  • PythonPython
  • cai-framework
NoNoDec 09, 2025
CVE-2025-66645HIGH7.5
  • PythonPython
  • nicegui
NoYesDec 09, 2025
GHSA-9rwj-6rc7-p77cHIGH7.3
  • PythonPython
  • langgraph-checkpoint-sqlite
NoYesDec 10, 2025
CVE-2025-67502MEDIUM5.4
  • PythonPython
  • taguette
NoYesDec 10, 2025
CVE-2025-67485MEDIUM5.3
  • PythonPython
  • mad-proxy
NoNoDec 09, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management