CVE-2024-10940 Exposure of Sensitive System Information via ImagePromptTemplate in langchain-ai/langchain
Attackers can read arbitrary files from the host file system via ImagePromptTemplate input variables, exposing sensitive information if outputs are visible.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-10940?
CVE-2024-10940 is a medium-severity path traversal vulnerability in langchain-ai/langchain, published on 20 Mar 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official 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.
Weakness: CWE-497
Which versions are affected by CVE-2024-10940?
7 open source packages ship an affected version, including langchain-core.
| Package | Affected | Fixed in |
|---|---|---|
langchain-core PyPI | From 0.1.17 | 0.1.53, 0.2.43, 0.3.15 |
langchain-core PyPI | From 0.1.17 | 0.1.53 |
langchain-core PyPI | From 0.1.17 | 0.1.53 |
langchain-core PyPI | From 0.2.0 | 0.2.43 |
langchain-core PyPI | From 0.2.0 | 0.2.43 |
langchain-core PyPI | From 0.3.0 | 0.3.15 |
1 more packages
langchain-core PyPI | From 0.3.0 | 0.3.15 |
How do I fix CVE-2024-10940?
Upgrade langchain-core to a fixed version for your release line: 0.1.53, 0.2.43 or 0.3.15.
Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.
Is CVE-2024-10940 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-10940 exists.
Sources
Also known as ECHO-db43-5462-956d, GHSA-5chr-fjjv-38qv, PYSEC-2026-1517.