Path Traversal Affecting langchain package, versions [,0.0.353)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.04% (13th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Path Traversal vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-LANGCHAIN-6615703
  • published16 Apr 2024
  • disclosed16 Apr 2024
  • creditninjafit

Introduced: 16 Apr 2024

CVE-2024-3571  (opens in a new tab)
CWE-22  (opens in a new tab)

How to fix?

Upgrade langchain to version 0.0.353 or higher.

Overview

langchain is a Building applications with LLMs through composability

Affected versions of this package are vulnerable to Path Traversal due to improper limitation of a pathname to a restricted directory in its LocalFileStore functionality. An attacker can leverage this vulnerability to read or write files anywhere on the filesystem, potentially leading to information disclosure or remote code execution.

Note: The issue lies in the handling of file paths in the mset and mget methods, where user-supplied input is not adequately sanitized, allowing directory traversal sequences to reach unintended directories.

PoC


from langchain.storage import LocalFileStore

file_store = LocalFileStore("/home")

value = file_store.mget(["/etc/passwd"])

print(value)

CVSS Scores

version 3.1