CVE-2024-7774: Langchain path traversal in file operations

CVE-2024-7774 · Severity: low · CVSS 3 · Published 2024-10-29

Langchain is a popular library for building applications with large language models. A path traversal vulnerability in its file handling code allows attackers to save, read, overwrite, and delete files anywhere on a system where the application runs, bypassing intended directory restrictions and potentially compromising sensitive data or application integrity.

Vendors: npm.

Quick answers

Is CVE-2024-7774 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2024-7774 being exploited in the wild.
How severe is CVE-2024-7774?
Low severity, with a CVSS score of 3, published 29 October 2024.
Which products and versions are affected?
langchain (npm) SEMVER:introduced=0,fixed=0.2.19.
Is there a fix for CVE-2024-7774?
Yes. langchain (npm): upgrade to 0.2.19 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2024-7774 attacked?
It is attacked over the network.
Am I affected by CVE-2024-7774?
Check whether you run langchain (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • langchain (npm): upgrade to 0.2.19 or later
    npm install langchain@0.2.19

Technical details

A path traversal vulnerability exists in the getFullPath method of langchain (npm package) versions prior to 0.2.19, exploitable through setFileContent, getParsedFile, and mdelete methods. The vulnerability stems from insufficient input sanitization when constructing file paths, allowing attackers to use path traversal sequences (e.g., ../) to escape the intended directory. The attack vector is network-based with no authentication or user interaction required (CVSS 3.0 AV:N/AC:L/PR:N/UI:N). An attacker can read text files, write files to arbitrary locations, overwrite existing files, and delete files on the affected system. A fix was released in version 0.2.19 (commit a0fad77).

Affected products

  • Langchain langchain before 0.2.19

Identifiers

  • CVE-2024-7774
  • GHSA-hc5w-c9f8-9cc4

Timeline

  • 2024-10-29: disclosed
  • 2024-10-29: patched: Fix released in version 0.2.19

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.