CVE-2023-36258: langchain arbitrary code execution vulnerability
A third advisory ID for the LangChain PALChain exec problem: a prompt that makes the model write malicious Python leads to arbitrary code execution in the host process. This ID lists langchain 0.0.247 as the fixed version, the release that removed PALChain from the package. Upgrade to 0.0.247 or later.
Published Jul 3, 2023 · Updated Nov 22, 2024 · Analysis Nov 2, 2026
What an attacker can do
The advisory text is short: an attacker can execute arbitrary code through PALChain, which calls Python's exec on generated code. The linked issue 5872 and its closing comment give the context. The maintainers released mitigations in 0.0.236, then moved PALChain into the langchain-experimental package and dropped it from langchain starting at 0.0.247. They also put security notices on the PAL and CPAL experimental chains.
What this means for a team: any service that sends user text to a PAL chain lets the user decide what Python the model writes. Prompt injection through retrieved content works as well. The code runs with the service's rights, so secrets in the environment and reachable internal systems are at risk.
This ID overlaps CVE-2023-36095 and CVE-2023-36188, which describe the same class of bug with different fixed versions. If you track them separately, one upgrade past 0.0.247 closes all three.
Who is affected
pip package langchain below 0.0.247, if your code builds a PALChain. After that release the class is not in langchain at all. Check:
pip list | grep -i langchainIf you installed langchain-experimental to keep PAL working, you are still running the risky pattern and should treat it as untrusted-code execution.
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. Release 0.0.236 had earlier mitigations, but this advisory's fixed version is 0.0.247.
pip install --upgrade "langchain>=0.0.247"If you keep PALChain through langchain-experimental, follow its warning and run the generated code in a sandbox outside your process, such as a locked-down container.
How to tell if you were hit
Grep your code base and dependency lock files for PALChain and langchain versions below 0.0.247. In traces of LLM calls, look for generated code that imports os or subprocess, or opens files and sockets. Check service hosts for odd child processes or outbound connections.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
An issue in langchain allows an attacker to execute arbitrary code via the PALChain in the python exec method.
Questions
- Why does CVE-2023-36258 name 0.0.247 while CVE-2023-36095 names 0.0.236?
The 0.0.236 release added ast checks and a time limit. Release 0.0.247 removed PALChain from langchain entirely. The advisories picked different points on the same fix history.
- Do I have to leave PALChain behind?
Not necessarily, but its new home, langchain-experimental, warns that in-process Python sandboxing is hard. Use external sandboxing or avoid it for untrusted input.
- Is this exploited in the wild?
No source says so. The advisory is not in CISA's KEV data.
References
Read for this analysis:
- https://github.com/langchain-ai/langchain/issues/5872#issuecomment-1697785619
- https://nvd.nist.gov/vuln/detail/CVE-2023-36258
- https://github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2023-98.yaml
- https://github.com/langchain-ai/langchain/issues/5872
- https://github.com/langchain-ai/langchain/pull/6003
- https://github.com/langchain-ai/langchain/pull/7870
- https://github.com/langchain-ai/langchain/pull/8425
- https://github.com/langchain-ai/langchain/commit/8ba9835b925473655914f63822775679e03ea137
- https://github.com/langchain-ai/langchain/commit/e294ba475a355feb95003ed8f1a2b99942509a9e
- https://github.com/langchain-ai/langchain/commit/fab24457bcf8ede882abd11419769c92bc4e7751
- https://github.com/advisories/GHSA-2qmj-7962-cjq8
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
