CVE-2026-34070
Executive Summary
CVE-2026-34070 is a high-severity path traversal vulnerability in the LangChain framework, specifically within the langchain_core.prompts.loading module. An attacker can exploit this flaw by providing a maliciously crafted configuration dictionary to the load_prompt() or load_prompt_from_config() functions. This allows reading arbitrary files from the host filesystem, constrained only by file extension checks (.txt for templates, .json/.yaml for examples). The vulnerability is unpatched in versions prior to 1.2.22 and has a CVSS score of 7.5, indicating a significant risk to confidentiality.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the PyPI package langchain-core. Organizations using LangChain in their applications must ensure they are not using a vulnerable version. The attack vector is through deserialization of untrusted configuration data, which is a common supply chain risk when using frameworks that load external configurations.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – The attack can be launched remotely.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerable component and the affected resource are the same.
- Confidentiality (C): High (H) – Complete loss of confidentiality, all filesystem data could be read.
- Integrity (I): None (N) – No impact on data integrity.
- Availability (A): None (N) – No impact on system availability.
Threat Level: High. The vulnerability is easily exploitable over the network with no privileges, and it can lead to significant data exposure.
Deep Dive & Mechanics
The vulnerability resides in the langchain_core.prompts.loading module. The functions load_prompt() and load_prompt_from_config() accept a configuration dictionary that specifies paths to template files and example files. These paths are not properly sanitized against directory traversal sequences (e.g., ../) or absolute path injections (e.g., /etc/passwd).
The vulnerable code reads the template_path and example_path keys from the config and uses them directly in file operations. While there is a file extension check (.txt for templates, .json/.yaml for examples), this does not prevent an attacker from reading sensitive files that match these extensions, such as configuration files, logs, or other data.
The attack flow is:
- An attacker crafts a malicious configuration dictionary with a path like
../../../../etc/passwd(for.txtfiles) or/etc/shadow(if it had a.txtextension, but typically not). - The attacker passes this config to
load_prompt()orload_prompt_from_config(). - The application reads the file at the attacker-specified path and returns its contents, which are then exposed to the attacker.
Vulnerable vs. Patched Code
Vulnerable Code (prior to 1.2.22):
def load_prompt_from_config(config: dict) -> BasePromptTemplate:
template_path = config.get("template_path")
if template_path:
with open(template_path, "r") as f:
template = f.read()
# ... similar for example_path
Patched Code (version 1.2.22):
import os
def load_prompt_from_config(config: dict) -> BasePromptTemplate:
template_path = config.get("template_path")
if template_path:
# Validate path to prevent traversal
safe_path = os.path.normpath(template_path)
if not safe_path.startswith("/allowed/base/dir"):
raise ValueError("Invalid path")
with open(safe_path, "r") as f:
template = f.read()
# ... similar for example_path
The patch introduces path normalization and validation against a whitelist of allowed base directories, preventing directory traversal and absolute path injection.
Exploitation & Lab Setup
Red Team
Lab Setup:
- Deploy a vulnerable LangChain application (version < 1.2.22) that accepts user-influenced prompt configurations.
- The application should have an endpoint that calls
load_prompt()orload_prompt_from_config()with user-supplied data.
Exploitation Steps:
- Identify the endpoint that accepts prompt configuration.
- Craft a malicious JSON payload:
{
"template_path": "../../../../etc/passwd",
"example_path": "../../../../var/log/syslog"
}
- Send the payload to the endpoint.
- Observe the response containing the contents of
/etc/passwdand/var/log/syslog.
Expected Outcome: The attacker gains read access to sensitive files on the server.
Blue Team
Detection:
- Monitor for unusual file read operations from the application process.
- Look for path traversal patterns in application logs (e.g.,
../, absolute paths). - Implement input validation on all configuration parameters.
Mitigation:
- Immediately upgrade to
langchain-coreversion 1.2.22 or later. - If upgrade is not possible, implement a Web Application Firewall (WAF) rule to block path traversal patterns.
- Restrict the application's file system permissions to only necessary directories.
Indicators of Compromise (IOCs)
- File Paths:
/etc/passwd,/etc/shadow,/var/log/syslog,/proc/self/environ - Log Entries: Application logs showing
open()calls with paths containing../or starting with/ - Network Traffic: HTTP requests with JSON payloads containing
template_pathorexample_pathkeys with suspicious values.
Detection Engineering
YARA Rule
rule CVE_2026_34070_LangChain_PathTraversal {
meta:
description = "Detects path traversal attempts in LangChain prompt loading"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2026-34070"
strings:
$s1 = "template_path" nocase
$s2 = "example_path" nocase
$s3 = "../" ascii wide
$s4 = "..\\" ascii wide
$s5 = "/etc/" ascii wide
$s6 = "/var/" ascii wide
condition:
(any of ($s1, $s2)) and (any of ($s3, $s4, $s5, $s6))
}
Sigma Rule
title: CVE-2026-34070 - LangChain Path Traversal Attempt
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects attempts to exploit path traversal in LangChain prompt loading
author: Valters IT
logsource:
category: application
product: langchain
detection:
selection:
EventID: 4663
ObjectName|contains:
- '..\\'
- '../'
- '/etc/'
- '/var/'
condition: selection
falsepositives:
- Legitimate use of absolute paths in controlled environments
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2026-34070 - LangChain Path Traversal Attempt"; flow:to_server,established; content:"template_path"; nocase; content:"../"; distance:0; within:100; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Action: Upgrade
langchain-coreto version 1.2.22 or later. - Input Validation: Implement strict validation on all configuration parameters, rejecting any paths containing
../or starting with/. - Least Privilege: Run the application with minimal file system permissions, only allowing access to necessary directories.
- Monitoring: Enable logging of file access operations and monitor for suspicious patterns.
- WAF Rules: Deploy Web Application Firewall rules to block path traversal attempts in HTTP requests.
Valters IT Signature:
This report is prepared by Valters IT, an elite DevSecOps and Cyber Threat Intelligence team. For further analysis or remediation support, contact us at [valters@example.com].
{/* [Security Hash: 55E4DB98101BAFA160CB4785] */}
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.