# 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.

- **Severity:** Medium 5.3 (`CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 20 Mar 2025
- **Updated:** 20 Mar 2025
- **Also known as:** ECHO-db43-5462-956d, GHSA-5chr-fjjv-38qv, PYSEC-2026-1517

## 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 (Exposure of Sensitive System Information to an Unauthorized Control Sphere)

## Which versions are affected by CVE-2024-10940?

7 open source packages ship an affected version, including langchain-core.


| Package | Ecosystem | 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 |
| `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.

## Is CVE-2024-10940 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-10940 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-10940 and fix it if it is affected.

What it is: 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.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-10940 exists.

Affected packages and fixed versions:
- langchain-core (PyPI): affected from 0.1.17; fixed in 0.1.53, 0.2.43, 0.3.15
- langchain-core (PyPI): affected from 0.1.17; fixed in 0.1.53
- langchain-core (PyPI): affected from 0.1.17; fixed in 0.1.53
- langchain-core (PyPI): affected from 0.2.0; fixed in 0.2.43
- langchain-core (PyPI): affected from 0.2.0; fixed in 0.2.43
- langchain-core (PyPI): affected from 0.3.0; fixed in 0.3.15
- langchain-core (PyPI): affected from 0.3.0; fixed in 0.3.15

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-10940/ (Markdown: https://insights.sbomify.com/CVE-2024-10940/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-10940
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-10940
- OSV: https://osv.dev/vulnerability/CVE-2024-10940

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-10940/
Summaries are generated and may contain mistakes; the official description above is the record.
