CVE-2023-38860: LangChain vulnerable to arbitrary code execution
LangChain before 0.0.247 shipped CPALChain, a chain that ran Python derived from model output without validation, so a crafted prompt could run operating system commands. LangChain 0.0.247 removed the code from the main package and moved it to langchain-experimental, where it still carries no sandbox.
Published Aug 15, 2023 · Updated Sep 27, 2024 · Analysis Nov 2, 2026
What an attacker can do
The issue behind this advisory concerns the CPAL chain (causal program-aided language), built with from_univariate_prompt. The reporter placed a Python expression, print(exec("import os; os.system('dir')")), inside the natural-language question, and it ran with the privileges of the application. The issue page does not show the chain's internals, but the report implies that code derived from the model's output is executed with no validation against unbound Python or command execution.
An attacker needs only to get text to the chain: a chat input, a document the app summarizes, or any field that ends up in the prompt. The CVSS vector (AV:N, AC:L, PR:N, UI:N) scores 9.8. A hit gives command execution as the application's user, with its secrets, files and network reach.
The maintainer's position in the thread is that in-process Python sandboxing is an extremely difficult problem, so the project's answer is a removal plus warnings, not a filter.
Who is affected
The pip package langchain before 0.0.247. Applications that use CPALChain with input that untrusted people can influence are the exposed ones. After the move, the same class lives in the langchain-experimental package and has the same property. Check:
pip show langchain langchain-experimentalThen search your code for CPALChain.
langchain
- Ecosystem
- PyPI
- Affected
- >= 0, < 0.0.247
- Fixed in
- 0.0.247
- Check
pip show langchain
How to fix it
Upgrade langchain to 0.0.247 or later:
pip install --upgrade "langchain>=0.0.247"Version 0.0.247 removes the affected code (pull requests 8092 and 8425). Anyone who still needs it must install langchain-experimental, which is not a fix: pull requests 9938 and 9936 added security notices to the class and to that package's README. The maintainer recommends running untrusted code in an external sandbox that you set up, such as a container with no secrets and no network.
How to tell if you were hit
Search your code for imports of CPALChain, from_univariate_prompt, or langchain-experimental in your dependency files. In logs of user questions and model output, look for Python syntax such as exec, os.system or __import__. On the host, check for unexpected child processes of the service that runs the chain.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
An issue in LangChain prior to v.0.0.247 allows a remote attacker to execute arbitrary code via the prompt parameter.
Questions
- Does upgrading langchain make CPALChain safe?
Upgrading removes it from the main package. If you install langchain-experimental to keep using it, the chain is still unsandboxed and the project only added warnings.
- Which component is affected?
The CPAL chain, created with from_univariate_prompt, according to the issue thread.
- Which version fixes CVE-2023-38860?
langchain 0.0.247, which removed the affected code from the main package and moved it to langchain-experimental.
- Is it exploited in the wild?
The sources do not say so, and the entry has no CISA catalog data.
References
Read for this analysis:
- https://github.com/langchain-ai/langchain/issues/7641
- https://github.com/advisories/GHSA-fj32-q626-pjjc
- https://nvd.nist.gov/vuln/detail/CVE-2023-38860
- https://github.com/hwchase17/langchain/issues/7641
- https://github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2023-145.yaml
- https://github.com/langchain-ai/langchain/pull/8092
- https://github.com/langchain-ai/langchain/pull/8425
- https://github.com/langchain-ai/langchain/commit/d353d668e4b0514122a443cef91de7f76fea4245
- https://github.com/langchain-ai/langchain/commit/fab24457bcf8ede882abd11419769c92bc4e7751
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More LangChain vulnerabilities
All LangChain entriesCVE-2026-55443
LangChain: Path traversal and sandbox escape in LangChain file-search middleware and loaders
medium5.1Jun 16, 2026CVE-2026-45134
LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary warning
high7.1May 13, 2026CVE-2026-44843
LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad `load()` allowlists
high8.2May 8, 2026CVE-2026-40087
LangChain has incomplete f-string validation in prompt templates
medium5.3Apr 8, 2026CVE-2026-34070
LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions
high7.5Mar 27, 2026CVE-2026-27795
LangChain Community: redirect chaining can lead to SSRF bypass via RecursiveUrlLoader
medium4.1Feb 25, 2026
