NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · LangChain

CVE-2024-10940: langchain-core allows unauthorized users to read arbitrary files from the host file system

mediumCVSS 3.0 5.3GHSA-5chr-fjjv-38qv

langchain-core's `ImagePromptTemplate`, and so `ChatPromptTemplate` image blocks, could read any file path on the server if the path came from a template input variable. If the output reaches a user or a model reply, the file contents leak. Fixed in 0.1.53, 0.2.43 and 0.3.15.

Published Mar 20, 2025 · Updated May 20, 2025 · Analysis Nov 1, 2026

What an attacker can do

ImagePromptTemplate.format() accepted a path value, read the file, base64-encoded it and built a data URL. If an attacker controls the variable that fills that field, they can point it at any file the process can read, such as /etc/passwd, .env files or cloud credentials. The contents then travel with the prompt. If the formatted prompt or a model response that quotes it is shown to the attacker, the file leaks.

So the attacker needs two things: input that reaches an image template variable, and a way to see the output, directly or through the model. A chat app that lets users supply the image field is the typical case. The CVSS vector is network, no privileges and low confidentiality impact. The fix commit removes local path loading in ImagePromptTemplate altogether, so only URLs work. Passing path now raises a ValueError, and the helpers encode_image and image_to_data_url were removed from utils/image.py.

Who is affected

The pip package langchain-core in ranges 0.1.17 to before 0.1.53, 0.2.0 to before 0.2.43, and 0.3.0 to before 0.3.15. You are exposed only if your code builds image prompt templates and user input can set the path of an image.

Check the version:

pip show langchain-core

Then search your code for ImagePromptTemplate and for image_url blocks in ChatPromptTemplate with variable fields.

langchain-core

Ecosystem
PyPI
Affected
>= 0.1.17, < 0.1.53
Fixed in
0.1.53
Check
pip show langchain-core

langchain-core

Ecosystem
PyPI
Affected
>= 0.2.0, < 0.2.43
Fixed in
0.2.43
Check
pip show langchain-core

langchain-core

Ecosystem
PyPI
Affected
>= 0.3.0, < 0.3.15
Fixed in
0.3.15
Check
pip show langchain-core

How to fix it

Upgrade to the patched release for your line: 0.1.53, 0.2.43 or 0.3.15.

pip install -U "langchain-core>=0.3.15"

After the fix, image templates accept URLs only. Code that relied on loading local files through the template will fail with a ValueError and must read and encode files itself, from paths you control. The sources name no other workaround.

How to tell if you were hit

Review prompt inputs and application logs for image fields holding file system paths like /etc/ or C:\, instead of URLs. Check outbound model requests for data URLs (data:image/...;base64,) that decode to text files. Search logs for the ValueError message about loading images from path after you upgrade, which shows code still sending paths.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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.

Credited to zly123987.

Questions

Does CVE-2024-10940 need the output to be visible?

Yes. The advisory says exposure happens if the template output is shown to the user, directly or through downstream model outputs.

Which langchain-core versions are fixed?

0.1.53, 0.2.43 and 0.3.15, for their respective release lines.

Will upgrading break my code?

It can. After the fix, ImagePromptTemplate rejects path with a ValueError and accepts only URLs. Code that loaded local images through it must handle that itself.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More LangChain vulnerabilities

All LangChain entries