Langchain Path Traversal vulnerability
The getFullPath method in langchainjs 0.2.5 does not properly sanitise user input, allowing path traversal. An attacker could use this to write files anywhere on the filesystem, overwrite text files, read .txt files, and delete files.
langchain-ai/langchainjs
Originally disclosed on huntr
A path traversal vulnerability exists in the getFullPath method of langchain-ai/langchainjs version 0.2.5. This vulnerability allows attackers to save files anywhere in the filesystem, overwrite existing text files, read .txt files, and delete files. The vulnerability is exploited through the setFileContent, getParsedFile, and mdelete methods, which do not properly sanitize user input.
From the GitHub Advisory Database (GHSA-hc5w-c9f8-9cc4, 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 getFullPath method joins user-supplied path segments without normalising or restricting them to a base directory, so '..' sequences escape the intended folder.
Impact
An attacker could save files anywhere in the filesystem, overwrite existing text files, read .txt files, and delete files.
What the attacker needed
Ability to supply a crafted file path
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.
Path traversal is when a program accepts a file path from a user but does not check it, so someone can use '..' to escape the intended folder and reach other parts of the computer. Here, a library function that builds file paths failed to clean the input, so an attacker could read, write, or delete files outside the allowed area.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.