CVE-2024-10940: langchain-core: file read via prompt template inputs
GHSA-5chr-fjjv-38qv MEDIUM CISA: TRACK*Any LangChain application that allows user-controlled input into ImagePromptTemplate or ChatPromptTemplate variables and exposes rendered output is leaking arbitrary server files — including .env files, cloud credentials, and API keys. Patch to langchain-core >=0.1.53, >=0.2.43, or >=0.3.15 immediately; no viable in-place workaround exists. Externally-facing LangChain apps where prompt output reaches users or model responses are highest priority.
What is the risk?
CVSS 5.3 (Medium) understates operational risk in AI deployments. EPSS 0.00096 suggests no active exploitation, but the attack is pre-authenticated, requires zero AI/ML knowledge, and targets the exact file paths most damaging to AI infrastructure: .env with API keys, ~/.aws/credentials, database connection strings, and model configs. LLM inference servers routinely hold high-value secrets that convert this Medium into a critical credential-theft vector.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| LangChain Core | pip | >= 0.1.17, < 0.1.53 | 0.1.53 |
Do you use LangChain Core? You're affected.
How severe is it?
What is the attack surface?
What should I do?
5 steps-
PATCH
upgrade langchain-core to >=0.1.53 (0.1.x branch), >=0.2.43 (0.2.x branch), or >=0.3.15 (0.3.x branch) — commit c1e7423 and e711034 contain the fix.
-
AUDIT
grep codebase for ImagePromptTemplate and ChatPromptTemplate usages; flag any that accept user-supplied variables mapped to file paths.
-
DETECT
add input validation logging to flag path traversal patterns (/etc/, ../, ~/.env, /.aws/) in template variables before patching.
-
POST-PATCH ROTATION: assume credentials on affected servers are compromised — rotate API keys, DB passwords, and cloud IAM credentials.
-
HARDEN
run LangChain app processes under least-privilege OS users with restricted filesystem access as defense-in-depth.
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-2024-10940?
Any LangChain application that allows user-controlled input into ImagePromptTemplate or ChatPromptTemplate variables and exposes rendered output is leaking arbitrary server files — including .env files, cloud credentials, and API keys. Patch to langchain-core >=0.1.53, >=0.2.43, or >=0.3.15 immediately; no viable in-place workaround exists. Externally-facing LangChain apps where prompt output reaches users or model responses are highest priority.
Is CVE-2024-10940 actively exploited?
No confirmed active exploitation of CVE-2024-10940 has been reported, but organizations should still patch proactively.
How to fix CVE-2024-10940?
1. PATCH: upgrade langchain-core to >=0.1.53 (0.1.x branch), >=0.2.43 (0.2.x branch), or >=0.3.15 (0.3.x branch) — commit c1e7423 and e711034 contain the fix. 2. AUDIT: grep codebase for ImagePromptTemplate and ChatPromptTemplate usages; flag any that accept user-supplied variables mapped to file paths. 3. DETECT: add input validation logging to flag path traversal patterns (/etc/, ../, ~/.env, /.aws/) in template variables before patching. 4. POST-PATCH ROTATION: assume credentials on affected servers are compromised — rotate API keys, DB passwords, and cloud IAM credentials. 5. HARDEN: run LangChain app processes under least-privilege OS users with restricted filesystem access as defense-in-depth.
What systems are affected by CVE-2024-10940?
This vulnerability affects the following AI/ML architecture patterns: LLM application frameworks, agent frameworks, RAG pipelines, multi-modal pipelines, chatbot deployments.
What is the CVSS score for CVE-2024-10940?
CVE-2024-10940 has a CVSS v3.1 base score of 5.3 (MEDIUM). The EPSS exploitation probability is 0.37%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0037 Data from Local System AML.T0049 Exploit Public-Facing Application AML.T0057 LLM Data Leakage Compliance Controls Affected
What are the technical details?
Original Advisory
A vulnerability in langchain-core versions >=0.1.17,<0.1.53, >=0.2.0,<0.2.43, and >=0.3.0,<0.3.15 allows unauthorized users to read arbitrary files from the host file system. The issue arises from the ability to create langchain_core.prompts.ImagePromptTemplate's (and by extension langchain_core.prompts.ChatPromptTemplate's) with input variables that can read any user-specified path from the server file system. If the outputs of these prompt templates are exposed to the user, either directly or through downstream model outputs, it can lead to the exposure of sensitive information.
Exploitation Scenario
An adversary using a LangChain-powered chatbot or assistant submits a query that populates an ImagePromptTemplate input variable with a target file path such as /app/.env or /root/.aws/credentials. The template renders the file contents and either returns them directly in the API response or passes them to the downstream LLM, which echoes the contents back. No authentication, no AI expertise, and no exploit code are required — the attacker iterates over well-known credential paths in sequence. In a multi-tenant SaaS using LangChain, a single unauthenticated user can exfiltrate the platform operator's cloud credentials, enabling full account takeover.
Weaknesses (CWE)
CWE-497 Exposure of Sensitive System Information to an Unauthorized Control Sphere
Primary
CWE-497 Exposure of Sensitive System Information to an Unauthorized Control Sphere CWE-497 — Exposure of Sensitive System Information to an Unauthorized Control Sphere: The product does not properly prevent sensitive system-level information from being accessed by unauthorized actors who do not have the same level of access to the underlying system as the product does.
- [Architecture and Design, Implementation] Production applications should never use methods that generate internal details such as stack traces and error messages unless that information is directly committed to a log that is not viewable by the end user. All error message text should be HTML entity encoded before being written to the log file to protect against potential cross-site scripting attacks against the viewer of the logs
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N References
- github.com/advisories/GHSA-5chr-fjjv-38qv
- github.com/langchain-ai/langchain/commit/7d481f10102f43559cc57bcad7eba291067939ee
- github.com/langchain-ai/langchain/commit/e711034713259ae448981bc0fd1d7a5671499c31
- nvd.nist.gov/vuln/detail/CVE-2024-10940
- github.com/langchain-ai/langchain/commit/c1e742347f9701aadba8920e4d1f79a636e50b68
- huntr.com/bounties/be1ee1cb-2147-4ff4-a57b-b6045271cf27
Timeline
Related Vulnerabilities
CVE-2026-44843 8.2 LangChain: deserialization poisons LLM chat history
Same package: langchain-core CVE-2025-68664 8.2 langchain-core: Deserialization enables RCE
Same package: langchain-core CVE-2026-34070 7.5 langchain-core: path traversal exposes host secrets via prompt config
Same package: langchain-core GHSA-926x-3r5x-gfhw 5.3 LangChain: f-string template injection exposes object internals
Same package: langchain-core CVE-2026-40087 5.3 LangChain: template injection leaks object attributes
Same package: langchain-core