CVE-2024-7774 Path Traversal in langchain-ai/langchainjs

Medium 6.5 Published Updated

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.

Weakness: CWE-22, CWE-29

Which versions are affected by CVE-2024-7774?

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

PackageAffectedFixed in
langchain npmAll versions0.2.19
langchain npmAll versions0.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.

Sources

Also known as CLEANSTART-2026-JM92402, ECHO-ab50-0af1-5eb2, GHSA-hc5w-c9f8-9cc4, MINI-rqmp-4223-m4gp.

Is CVE-2024-7774 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free