CVE-2024-7774: Langchain Path Traversal Vulnerability
MODERATECVE-2024-7774 is a MODERATE (CVSS 6.5) path traversal vulnerability (CWE-29: Path Traversal: '\..\filename') affecting Langchain libraries in the npm ecosystem. The issue involves langchain path traversal vulnerability. Remediation is available by upgrading affected packages to version 0.2.19.
CVE-2024-7774 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N).
How to Fix CVE-2024-7774
To remediate this vulnerability, upgrade all affected Langchain dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install langchain@0.2.19
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls langchain
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-7774, inspect your project dependencies using npm:
npm ls langchain
Analyze the terminal output to locate any version of Langchain in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.2.19), your application is affected.
Note: The npm ls langchain command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-29: Path Traversal: '\..\filename', where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\..\filename' (leading backslash dot dot) sequences that can resolve to a location that is outside of that directory. In Langchain, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-7774 Affected Langchain Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
langchain
|
npm |
< 0.2.19
|
0.2.19
|
References
Frequently Asked Questions
What is CVE-2024-7774?
Which Langchain versions are affected?
What version fixes CVE-2024-7774?
Is langchain affected?
What is the CVSS score of CVE-2024-7774?
What CWE is associated with CVE-2024-7774?
How can I check npm dependencies for CVE-2024-7774?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-hc5w-c9f8-9cc4",
"modified" : "2024-11-01T15:24:38Z",
"published" : "2024-10-29T15:32:05Z",
"aliases" : [ "CVE-2024-7774" ],
"summary" : "Langchain Path Traversal vulnerability",
"details" : "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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "langchain"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.2.19"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-7774"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langchainjs/commit/a0fad77d6b569e5872bd4a9d33be0c0785e538a9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/langchain-ai/langchainjs"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/langchain/PYSEC-2024-111.yaml"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/8fe40685-b714-4191-af7a-3de5e5628cee"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22", "CWE-29" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-10-29T19:40:07Z",
"nvd_published_at" : "2024-10-29T13:15:09Z"
}
}