Skip to content
Path traversal Disclosed report Intermediate CVE-2024-10940

langchain-core allows unauthorized users to read arbitrary files from the host file system

Prompt template classes in langchain-core could be configured with input variables that read arbitrary files from the server's file system. If the rendered prompt or downstream model output was shown to the user, sensitive host files could be exposed.

langchain-ai/langchain

Originally disclosed on huntr

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.

From the GitHub Advisory Database (GHSA-5chr-fjjv-38qv, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the prompt template accepted user-controlled input variables that were used to load files from disk without restricting which paths could be read.

Impact

An attacker could read arbitrary files from the host, and if the prompt output or model response is exposed to them, sensitive information may be disclosed.

What the attacker needed

Ability to set prompt template input variables; output exposed to the user

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A library used to build prompts for AI models let a template include a placeholder that, instead of plain text, pulled in the contents of any file on the server. If the resulting prompt or the model's answer was shown back to the person using the app, they could see private files. This is a file-reading flaw caused by trusting user-supplied paths.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More from langchain-ai/langchain

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.