CVE-2024-7774
Critical · 9.1Langchain Path Traversal vulnerability
CVSS
9.1
EPSS
0.6%
Published
Oct 29, 2024
CISA due date
—
Cloudanix analysis
A flaw in a popular AI library lets attackers read, change, or delete files anywhere on the server, which could expose private information or break the application.
- Exploitation
- Remote Authenticated
- Attacker needs
- Low Privilege
- Complexity
- Low
- Impact
- Data Tampering
- Component
- Library
- Class
- Path Traversal
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Path traversal in getFullPath allows unsanitized user input to reach setFileContent, getParsedFile, and mdelete, enabling arbitrary file read, write, overwrite, and deletion anywhere on the filesystem.
Why it matters to the business
Attackers can exfiltrate sensitive data, tamper with configuration or application files, and delete critical assets, resulting in service disruption, compliance violations, and potential full system compromise.
How an attack unfolds
An attacker supplies crafted relative or absolute paths containing traversal sequences to the affected methods; the library fails to canonicalize or restrict the resulting paths, allowing direct filesystem operations outside intended directories.
How to fix it
Upgrade langchain-ai/langchainjs to commit a0fad77d6b569e5872bd4a9d33be0c0785e538a9 or later; validate that all file-path inputs are normalized and confined to allowed directories before calling the affected methods.
How to confirm the fix worked
Confirm the library version is at or above the fixed commit; test that traversal sequences in inputs are rejected or normalized to safe paths; review application logs for any prior use of the vulnerable methods with suspicious path arguments.
Typical attack path
- Identify an application or integration using vulnerable langchainjs file-handling methods
- Craft input containing path traversal sequences targeting sensitive files
- Invoke setFileContent to write or overwrite arbitrary files
- Use getParsedFile to read .txt contents
- Call mdelete to remove chosen files
How to detect it
Review application and web-server logs for unusual file paths containing .. or absolute paths passed to langchainjs file methods; inspect file-system timestamps and ownership changes on sensitive files; search process execution logs for node processes performing unexpected read/write/delete operations on non-application directories.
What your security team should do
- Immediately upgrade langchainjs to the fixed commit in all environments
- Audit code for direct or indirect calls to setFileContent, getParsedFile, and mdelete
- Implement input sanitization and path allow-listing as defense-in-depth
- Monitor dependency updates and scan for other path-handling libraries with similar patterns
The record
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.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| npm | langchain | 0 | 0.2.19 |
| Chainguard | kibana-8 | 0 | 8.16.1-r1 |
| Chainguard | kibana-8-bitnami | 0 | 8.16.1-r1 |
| Chainguard | kibana-8-iamguarded | 0 | 8.16.1-r1 |
| pypi | langchain | 0 | No fix |
Related vulnerabilities
- GHSA-r399-636x-v7f6 LangChain serialization injection vulnerability enables secret extraction Also affects langchain
- CVE-2025-68665 LangChain serialization injection vulnerability enables secret extraction Also affects langchain
- CVE-2025-7783 Use of Insufficiently Random Values vulnerability in form-data allows HTTP Parameter… Also affects kibana-8
- CVE-2025-5889 A vulnerability was found in juliangruber brace-expansion up to 1.1.11/2.0.1/3.0.0/4.0.0. Also affects kibana-8
- CVE-2025-47934 OpenPGP.js is a JavaScript implementation of the OpenPGP protocol. Also affects kibana-8
- CVE-2024-12905 An Improper Link Resolution Before File Access ("Link Following") and Improper Limitation… Also affects kibana-8
- CVE-2025-27789 Babel is a compiler for writing next generation JavaScript. Also affects kibana-8
- CVE-2025-22150 Undici is an HTTP/1.1 client. Also affects kibana-8