CVE-2024-7774 Path Traversal in langchain-ai/langchainjs
Attackers can traverse directories to read, overwrite, or delete files via unsanitized input in langchainjs methods.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-7774?
CVE-2024-7774 is a medium-severity path traversal vulnerability in langchain-ai/langchainjs, published on 29 Oct 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
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.
Which versions are affected by CVE-2024-7774?
2 open source packages ship an affected version, including langchain. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
langchain npm | All versions | 0.2.19 |
langchain npm | All versions | 0.2.19 |
Products include Langchain Langchain.js.
How do I fix CVE-2024-7774?
Upgrade langchain to 0.2.19 or later.
Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.
Is CVE-2024-7774 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-7774 exists.
Other vulnerabilities in langchain-ai/langchainjs
Sources
Also known as CLEANSTART-2026-JM92402, ECHO-ab50-0af1-5eb2, GHSA-hc5w-c9f8-9cc4, MINI-rqmp-4223-m4gp.