CVE-2024-10940 Exposure of Sensitive System Information via ImagePromptTemplate in langchain-ai/langchain

Medium 5.3 Published Updated

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.

PackageAffectedFixed in
langchain-core PyPIFrom 0.1.170.1.53, 0.2.43, 0.3.15
langchain-core PyPIFrom 0.1.170.1.53
langchain-core PyPIFrom 0.1.170.1.53
langchain-core PyPIFrom 0.2.00.2.43
langchain-core PyPIFrom 0.2.00.2.43
langchain-core PyPIFrom 0.3.00.3.15
1 more packages
langchain-core PyPIFrom 0.3.00.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.

Is CVE-2024-10940 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free