CVE-2023-39631
Arbitrary Code Execution vulnerability in langchain (PyPI)

Arbitrary Code Execution No known exploit

What is CVE-2023-39631 About?

LanChain-ai Langchain version 0.0.245 contains an arbitrary code execution vulnerability via the `evaluate` function in the `numexpr` library. This critical flaw allows remote attackers to execute malicious code on the server. Exploitation likely requires specific input to the `evaluate` function, but can lead to full system compromise.

Affected Software

  • langchain
    • <0.0.308
  • numexpr
    • <2.8.5

Technical Details

This vulnerability in LanChain-ai Langchain (v.0.0.245) stems from improper handling or sanitization within the evaluate function of the numexpr library. The numexpr library is designed for numerical expression evaluation, but if user-supplied input is directly passed to its evaluate function without sufficient validation, an attacker can inject arbitrary Python code or system commands. When such malicious input is processed, the evaluate function executes the injected code within the context of the running application, granting the remote attacker the ability to execute arbitrary commands on the host system. This bypasses typical sandboxing or input validation mechanisms.

What is the Impact of CVE-2023-39631?

Successful exploitation may allow attackers to execute arbitrary code, leading to full system compromise, data exfiltration, or denial of service on the affected server.

What is the Exploitability of CVE-2023-39631?

Exploitation of this arbitrary code execution vulnerability would typically involve crafting specific input that gets passed to the numexpr library's evaluate function through the Langchain application. The complexity depends on how easily an attacker can control the input to this function. This is likely a remote vulnerability, requiring no local access to the target system. Authentication requirements would depend on whether an attacker can provide input to the vulnerable function without authentication. No specific privileges are generally needed beyond the ability to interact with the Langchain application in a way that triggers code evaluation. The risk factors increase if the Langchain instance is publicly accessible and accepts arbitrary or loosely validated user input that is then fed into numexpr.evaluate.

What are the Known Public Exploits?

PoC Author Link Commentary
No known exploits

What are the Available Fixes for CVE-2023-39631?

Available Upgrade Options

  • langchain
    • <0.0.308 → Upgrade to 0.0.308
  • numexpr
    • <2.8.5 → Upgrade to 2.8.5

Struggling with dependency upgrades?

See how Resolved Security's drop-in replacements make it simple.

Book a demo

Additional Resources

What are Similar Vulnerabilities to CVE-2023-39631?

Similar Vulnerabilities: CVE-2021-31805 , CVE-2020-27950 , CVE-2021-27926 , CVE-2022-26133 , CVE-2023-28432