Path Traversal Vulnerability in langchain

langchain Updated 02 Oct 2025

Summary

16/04/2024
Yes i
Moderate
6.5

CVE-2024-3571: langchain vulnerable to path traversal. Affects langchain versions < 0.0.353. Fixed in 0.0.353. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

langchain is an open-source Python package available on PyPI. It provides functionality for handling file paths in its LocalFileStore feature. However, langchain is vulnerable to a path traversal attack, which allows an attacker to read or write files outside of the intended directory. This can lead to information disclosure or remote code execution. The vulnerability arises from inadequate sanitization of user-supplied input in the mset and mget methods, enabling directory traversal sequences to access unintended directories.

Vulnerability Detail

The path traversal vulnerability in langchain's LocalFileStore functionality allows an attacker to manipulate file paths and access files outside of the restricted directory. By exploiting this vulnerability, an attacker can potentially read sensitive information or inject malicious code into the system. The issue stems from the improper handling of file paths in the mset and mget methods, where user input is not properly sanitized.

How To Fix

Latest published version: 1.4.7 as of 22 Oct 2026

pip install --upgrade "langchain==1.4.7"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.0.353

This is the first release that contains the fix.

pip install --upgrade "langchain==0.0.353"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, developers can implement input validation and sanitization manually before passing user-supplied input to the mset and mget methods. This can involve checking for directory traversal sequences and restricting file access to the intended directory only. Here is an example of input validation in Python:

import os

def sanitize_path(path):
    # Remove any directory traversal sequences
    sanitized_path = os.path.normpath(path)
    # Ensure the path is within the intended directory
    if not sanitized_path.startswith('/restricted_directory/'):
        raise ValueError('Invalid file path')
    return sanitized_path

Conclusion

The path traversal vulnerability in langchain's LocalFileStore functionality can have serious consequences, including information disclosure and remote code execution. It is crucial to update langchain to the latest version and implement proper input validation to mitigate this vulnerability. For further assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for langchain →

Share this vulnerability

FAQ

The path traversal vulnerability in langchain can lead to information disclosure or remote code execution. An attacker can read or write files outside of the intended directory, potentially accessing sensitive data or injecting malicious code into the system.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using only the Pipfile.lock file without requiring access to the code or installation.

The CVSS score of this vulnerability is 6.5, indicating a moderate severity level.

Yes, a fix is available for this vulnerability. It is recommended to update langchain to version 0.0.353 or later to mitigate the path traversal vulnerability.

As a temporary workaround, developers can implement input validation and sanitization manually before using the affected methods. This can help prevent path traversal attacks by ensuring that user-supplied input is restricted to the intended directory.

Related vulnerabilities

Recent vulnerabilities recorded for langchain.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Latest published version: 1.4.7 as of 22 Oct 2026

pip install --upgrade "langchain==1.4.7"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.0.353

This is the first release that contains the fix.

pip install --upgrade "langchain==0.0.353"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback