# 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.

- **Severity:** Medium 6.5 (`CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 29 Oct 2024
- **Updated:** 29 Oct 2024
- **Also known as:** CLEANSTART-2026-JM92402, ECHO-ab50-0af1-5eb2, GHSA-hc5w-c9f8-9cc4, MINI-rqmp-4223-m4gp

## 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.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory), CWE-29 (Path Traversal: '\..\filename')

## Which versions are affected by CVE-2024-7774?

2 open source packages ship an affected version, including langchain. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `langchain` | npm | All versions | 0.2.19 |
| `langchain` | npm | All versions | 0.2.19 |

Products: Langchain Langchain.js.

## How do I fix CVE-2024-7774?

Upgrade langchain to 0.2.19 or later.

## 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

- [CVE-2025-68665](https://insights.sbomify.com/CVE-2025-68665/): LangChain serialization injection vulnerability enables secret extraction (high 8.6)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-7774 and fix it if it is affected.

What it is: 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.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-7774 exists.

Affected packages and fixed versions:
- langchain (npm): affected all versions; fixed in 0.2.19
- langchain (npm): affected all versions; fixed in 0.2.19

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-7774/ (Markdown: https://insights.sbomify.com/CVE-2024-7774/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-7774
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-7774
- OSV: https://osv.dev/vulnerability/CVE-2024-7774

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-7774/
Summaries are generated and may contain mistakes; the official description above is the record.
