CVE-2023-39631: Langchain vulnerable to arbitrary code execution via the evaluate function in the numexpr library
9.8
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.77521%
CWE
Published
9/1/2023
Updated
2/20/2025
KEV Status
No
Technology
Python
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| langchain | pip | < 0.0.308 | 0.0.308 |
| numexpr | pip | < 2.8.5 | 2.8.5 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability stems from numexpr's evaluate function using eval() on unsanitized input. The commit 4b2d89c in numexpr added regex-based input validation (_forbidden_re) to block dangerous characters (;,:, __, [), confirming the pre-patch evaluate function was vulnerable. Langchain's LLMMathChain used this vulnerable evaluate implementation, allowing attackers to execute code via crafted math expressions. Both the low-level expression parser (stringToExpression) and the public evaluate API are implicated.