CVE-2023-38860: LangChain: RCE via unsanitized prompt parameter

GHSA-fj32-q626-pjjc CRITICAL PoC AVAILABLE CISA: ATTEND
Published August 15, 2023
CISO Take

Any application running LangChain < 0.0.247 that accepts user-supplied prompts is exposed to unauthenticated remote code execution. Patch to 0.0.247+ immediately—no workaround preserves full functionality. Audit all LangChain deployments, especially public-facing chatbots, RAG pipelines, and AI agent services; a public PoC exists via GitHub issue #7641.

What is the risk?

CVSS 9.8 with zero authentication, no user interaction, and network-accessible attack vector makes this trivially exploitable at scale. LangChain is among the most widely deployed LLM frameworks globally, creating broad exposure. EPSS of 1.36% understates operational risk given the framework's prevalence in production AI systems, public PoC availability, and the complete absence of any exploit prerequisite.

What systems are affected?

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

How severe is it?

CVSS 3.1
9.8 / 10
EPSS
1.2%
chance of exploitation in 30 days
Higher than 63% 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. Upgrade LangChain to >= 0.0.247 immediately across all environments (dev, staging, prod).

  2. Inventory all LangChain instances—shadow deployments are the highest risk.

  3. Audit application code for any user-controlled input passed to prompt parameters without sanitization.

  4. Deploy WAF rules or input validation layers to block code injection payloads at the application boundary as a temporary compensating control.

  5. Restrict runtime permissions for LangChain processes (least privilege, no outbound internet, read-only filesystem where feasible).

  6. Monitor for anomalous process spawning, unexpected outbound connections, or env variable access from LangChain service processes.

  7. Rotate all credentials (API keys, DB passwords) stored in environment variables accessible to any affected LangChain deployment.

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
ISO 42001
6.1.2 - AI Risk Assessment 8.4 - AI System Lifecycle — Risk Controls
NIST AI RMF
GOVERN-6.1 - Policies for Third-Party AI Risk MANAGE-2.2 - Manage AI Risks — Deployment Context
OWASP LLM Top 10
LLM01 - Prompt Injection LLM02 - Insecure Output Handling LLM05 - Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2023-38860?

Any application running LangChain < 0.0.247 that accepts user-supplied prompts is exposed to unauthenticated remote code execution. Patch to 0.0.247+ immediately—no workaround preserves full functionality. Audit all LangChain deployments, especially public-facing chatbots, RAG pipelines, and AI agent services; a public PoC exists via GitHub issue #7641.

Is CVE-2023-38860 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2023-38860, increasing the risk of exploitation.

How to fix CVE-2023-38860?

1. Upgrade LangChain to >= 0.0.247 immediately across all environments (dev, staging, prod). 2. Inventory all LangChain instances—shadow deployments are the highest risk. 3. Audit application code for any user-controlled input passed to prompt parameters without sanitization. 4. Deploy WAF rules or input validation layers to block code injection payloads at the application boundary as a temporary compensating control. 5. Restrict runtime permissions for LangChain processes (least privilege, no outbound internet, read-only filesystem where feasible). 6. Monitor for anomalous process spawning, unexpected outbound connections, or env variable access from LangChain service processes. 7. Rotate all credentials (API keys, DB passwords) stored in environment variables accessible to any affected LangChain deployment.

What systems are affected by CVE-2023-38860?

This vulnerability affects the following AI/ML architecture patterns: agent frameworks, RAG pipelines, LLM application backends, chatbot services, document processing pipelines, AI automation workflows.

What is the CVSS score for CVE-2023-38860?

CVE-2023-38860 has a CVSS v3.1 base score of 9.8 (CRITICAL). The EPSS exploitation probability is 1.17%.

What is the AI security impact?

Affected AI Architectures

agent frameworksRAG pipelinesLLM application backendschatbot servicesdocument processing pipelinesAI automation workflows

MITRE ATLAS Techniques

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

Compliance Controls Affected

EU AI Act: Article 15
ISO 42001: 6.1.2, 8.4
NIST AI RMF: GOVERN-6.1, MANAGE-2.2
OWASP LLM Top 10: LLM01, LLM02, LLM05

What are the technical details?

Original Advisory

An issue in LangChain v.0.0.231 allows a remote attacker to execute arbitrary code via the prompt parameter.

Exploitation Scenario

An adversary identifies a public-facing application built on LangChain—a document Q&A chatbot, an internal AI assistant with an exposed API, or a LangChain-powered automation endpoint. They send a crafted HTTP request embedding a malicious payload in the prompt parameter that exploits LangChain's unsafe code evaluation logic. The payload executes arbitrary Python server-side: extracting OPENAI_API_KEY and DATABASE_URL from environment variables, exfiltrating them to an attacker-controlled server, then dropping a reverse shell. No credentials, no prior access, no social engineering required. The full attack chain takes under 60 seconds using the publicly documented PoC.

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
August 15, 2023
Last Modified
November 21, 2024
First Seen
August 15, 2023

Related Vulnerabilities