CVE-2023-36188: langchain vulnerable to arbitrary code execution
LangChain's PALChain passes model-written Python to exec, so a remote attacker who controls the prompt can run arbitrary code. This entry, CVE-2023-36188, is fixed in langchain 0.0.247, where the vulnerable code was removed. It is a second, later fix for the same PALChain problem as CVE-2023-36095, which was patched in 0.0.236. Upgrade to 0.0.247 or later.
Published Jul 6, 2023 · Updated Jul 6, 2026 · Analysis Nov 2, 2026
What an attacker can do
PALChain asks an LLM for a Python program that solves the user's question, then runs it with exec inside the application. The issue reported as langchain issue 5872 shows a prompt that asks for import os and os.system('ls') alongside a math problem, and the chain runs it.
The flaw is CWE-74 injection into a downstream interpreter. The model's output is untrusted because the prompt is. Any app that lets outside users, or documents and web pages they influence, reach a PAL chain gives them code execution with the app's own privileges. That means API keys in environment variables, local files, cloud credentials and network access from the host.
The earlier 0.0.236 fix added ast-based checks. This advisory's fix range runs to 0.0.247, the release that removed the chain from langchain, so checks alone were not treated as enough. The reporter is credited as cookesan.
Who is affected
pip package langchain before 0.0.247 when the app builds a PALChain and runs it on untrusted input. Check what is installed:
pip show langchainIf you moved to langchain-experimental, the same class lives there and carries a security warning, so check that package too.
langchain
- Ecosystem
- PyPI
- Affected
- < 0.0.247
- Fixed in
- 0.0.247
- Check
pip show langchain
How to fix it
Upgrade to langchain 0.0.247 or later:
pip install --upgrade "langchain>=0.0.247"PAL support was moved out of the main package into langchain-experimental. If you install that package to keep using PALChain, the maintainers warn that sandboxing Python in-process is hard. Run generated code in an external sandbox, and avoid passing untrusted text to the chain.
How to tell if you were hit
Search your code for PALChain, from_math_prompt and from_colored_object_prompt. In LLM traces and logs, look for generated programs containing import, os.system, subprocess or file and socket calls. Check the service host for unexpected child processes and outbound connections. Where coding agents on developer machines run this stack, Beam's record of agent shell commands and file access can show what executed.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
An issue in langchain allows a remote attacker to execute arbitrary code via the PALChain parameter in the Python exec method.
Credited to cookesan.
Questions
- How does CVE-2023-36188 differ from CVE-2023-36095?
Both concern PALChain and exec. CVE-2023-36095 lists 0.0.236 as its fix, which added ast checks. CVE-2023-36188 lists 0.0.247, where the vulnerable code was removed from langchain.
- Is langchain 0.0.240 affected?
Yes. Any version before 0.0.247 is in the affected range for this advisory, even though 0.0.236 fixed the related CVE-2023-36095 checks.
- Is it exploited in the wild?
No source says so. It is not in CISA's KEV data. A public issue contains a working prompt, so exploitation is easy if the chain is exposed.
References
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
