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.
Risk Assessment
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.
Affected Systems
| 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.
Severity & Risk
Attack Surface
Recommended Action
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.
CISA SSVC Assessment
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
Classification
Compliance Impact
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.27%.
Technical Details
NVD Description
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)
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
AI Threat Alert