CVE-2023-39659
Arbitrary Code Execution vulnerability in langchain (PyPI)
What is CVE-2023-39659 About?
This vulnerability in `langchain` allows a remote attacker to execute arbitrary code through a crafted script to the `PythonAstREPLTool._run` component. This can lead to full system compromise and data exfiltration. The exploit requires creating specifically malformed script input.
Affected Software
- langchain
- <0.0.233
- <0.0.325
Technical Details
The vulnerability lies within the PythonAstREPLTool._run component of the langchain library. This component is designed to execute Python code, likely within a REPL (Read-Eval-Print Loop) environment. If this component does not properly sanitize or validate user-supplied input, an attacker can inject crafted Python code. This injected code, when processed by _run, will be executed by the interpreter. The attack vector involves sending a specially formed script that, when parsed and executed by PythonAstREPLTool._run, breaks out of its intended scope or executes arbitrary system commands.
What is the Impact of CVE-2023-39659?
Successful exploitation may allow attackers to execute arbitrary code on the underlying system, leading to full system compromise, data theft, or denial of service.
What is the Exploitability of CVE-2023-39659?
Exploitation requires crafting a malicious Python script input that targets the PythonAstREPLTool._run component. This implies a medium level of complexity, requiring knowledge of Python execution and langchain's internal handling of scripts. No authentication or specific privileges are explicitly mentioned, but the attacker needs to be able to provide input to this component. This is a remote attack if the input can be provided over a network. The primary constraint is the ability to send attacker-controlled script input to the vulnerable component. Risk factors include applications that expose REPL-like functionality to untrusted users.
What are the Known Public Exploits?
| PoC Author | Link | Commentary |
|---|---|---|
| No known exploits | ||
What are the Available Fixes for CVE-2023-39659?
Available Upgrade Options
- langchain
- <0.0.233 → Upgrade to 0.0.233
- langchain
- <0.0.325 → Upgrade to 0.0.325
Struggling with dependency upgrades?
See how Resolved Security's drop-in replacements make it simple.
Book a demoAdditional Resources
- https://github.com/langchain-ai/langchain/pull/12427
- https://github.com/langchain-ai/langchain/releases/tag/v0.0.325
- https://osv.dev/vulnerability/PYSEC-2023-147
- https://github.com/langchain-ai/langchain
- https://github.com/langchain-ai/langchain/issues/7700
- https://github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2023-147.yaml
- https://github.com/langchain-ai/langchain/pull/5640
- https://github.com/langchain-ai/langchain/pull/5640
- https://nvd.nist.gov/vuln/detail/CVE-2023-39659
- https://github.com/langchain-ai/langchain/pull/5640
What are Similar Vulnerabilities to CVE-2023-39659?
Similar Vulnerabilities: CVE-2023-38704 , CVE-2023-32313 , CVE-2022-26134 , CVE-2021-44228 , CVE-2020-8174
