langchain vulnerable to path traversal
The LocalFileStore in langchain-ai/langchain does not properly restrict file paths, allowing directory traversal sequences to reach unintended directories. An attacker could read or write files anywhere on the filesystem, potentially leading to information disclosure or remote code execution.
langchain-ai/langchain
Originally disclosed on huntr
langchain-ai/langchain is vulnerable to path traversal due to improper limitation of a pathname to a restricted directory ('Path Traversal') in its LocalFileStore functionality. An attacker can leverage this vulnerability to read or write files anywhere on the filesystem, potentially leading to information disclosure or remote code execution. The issue lies in the handling of file paths in the mset and mget methods, where user-supplied input is not adequately sanitized, allowing directory traversal sequences to reach unintended directories.
From the GitHub Advisory Database (GHSA-rgp8-pm28-3759, CC BY 4.0).
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 mset and mget methods fail to sanitise user-supplied file paths, allowing directory traversal sequences to escape the intended directory.
Impact
An attacker could read or write arbitrary files, potentially leading to information disclosure or remote code execution.
What the attacker needed
Access to LocalFileStore methods
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 path traversal bug lets someone use special characters like '..' in a file path to escape the folder they are supposed to stay in. Here, a part of the LangChain library that stores files locally did not check the paths properly, so an attacker could make it read or write files outside the intended storage area. This could expose sensitive data or even let the attacker run their own code.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.