/

CVE-2026-34070

Severity:

HIGH RISK

(7.5)

Path Traversal in LangChain Prompt Loading Functions

CVE-2026-34070

Modified

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in LangChain's prompt loading utilities allows file paths embedded in deserialized configuration dictionaries to be used without proper validation.

If an application passes user-influenced prompt configurations into load_prompt() or load_prompt_from_config(), an attacker can potentially read arbitrary files from the host filesystem, limited only by basic file-extension checks.

Affected context

This issue arises in applications that:

  • Use LangChain's langchain_core.prompts.loading module
  • Call load_prompt() or load_prompt_from_config() with configuration dictionaries that may include file paths
  • Accept user-controlled or externally sourced prompt configuration (e.g., JSON/YAML from clients, plugins, or remote storage)
  • Run LangChain within an environment where host filesystem access is meaningful (servers, containers, developer machines)

The vulnerability does not create new files or write data; it affects how existing files are read when paths are not constrained to expected directories.

Exploit preconditions

  • Attack surface: Application interfaces that accept or construct prompt configuration dicts (HTTP APIs, CLIs, workflows, plugins, or orchestration code) which are then passed to load_prompt() or load_prompt_from_config().
  • Required access: Ability to influence or control the configuration fields that specify template or example file paths; this could be through authenticated or unauthenticated input, depending on the application's design.
  • Trigger point: Invocation of the prompt-loading functions that deserialize or otherwise consume configuration dicts and read from the filesystem based on the supplied paths.
  • Why exploitation is possible: The functions trust file paths embedded in the configuration without enforcing directory boundaries or rejecting absolute/parent-relative paths, enabling traversal outside intended prompt directories, subject only to filename extension filters.

Why this happens

The core problem is a classic CWE-22: Path Traversal bug: user-influenced data is used to construct filesystem paths without proper normalization, restriction, or validation.

In LangChain's prompt loading utilities, configuration dictionaries can contain file_path-like fields that are treated as authoritative locations for template and example files.

These paths are not constrained to a safe base directory, nor are .., absolute paths, or symlink resolutions comprehensively checked.

As a result, an attacker who can influence config content can direct the loader to read arbitrary files on the host that match expected extensions, breaking the intended trust boundary between configuration data and filesystem resources.

Potential impact

  • Disclosure of sensitive configuration files (e.g., environment-specific configs, internal JSON/YAML files)
  • Exposure of API keys, access tokens, or credentials stored in text-based files
  • Leakage of proprietary prompts, chain configurations, or internal system logic
  • Access to log files that may contain user data or operational details
  • Facilitation of further attacks through information gathering (e.g., reading .env-style files or service metadata where extensions align with allowed types)

General mitigation guidance

Effective mitigation focuses on enforcing strict boundaries between configuration data and filesystem access:

  • Constrain file access to whitelisted directories:
  • Resolve and normalize requested paths against a predefined base directory (e.g., a dedicated prompts/ folder).
  • Explicitly reject any path that escapes the base directory after normalization (e.g., containing .. components or resolving outside allowed roots).
  • Avoid trusting user-controlled paths:
  • Prefer using logical identifiers (prompt IDs, names, or handles) that the application maps to known-safe paths instead of passing raw filesystem paths from user input.
  • Treat any external configuration source as untrusted, even if it is formatted as JSON/YAML.
  • Apply strict validation before file reads:
  • Validate that paths are relative (no absolute paths) and conform to expected patterns.
  • Ensure that extension checks are coupled with directory and path normalization checks, not used as the only control.
  • Limit filesystem exposure of the runtime:
  • Run LangChain-based services with least-privilege filesystem permissions so that only non-sensitive directories are readable.
  • Isolate prompt files from secrets and other sensitive configuration to reduce the blast radius of any file read.
  • Adopt secure-by-default loading utilities:
  • Centralize file-loading logic in a small, well-reviewed module that enforces the above constraints, and ensure application code routes all prompt/file loading through it.

How teams detect issues like this

Detection efforts can focus on both code-level patterns and runtime behavior:

  • Static analysis and code scanning:
  • Search for direct uses of load_prompt() and load_prompt_from_config() where the config input originates from request bodies, untrusted JSON/YAML, or other external sources.
  • Flag patterns where user input is directly mapped into fields like file_path, template_path, or example file references without intermediate validation.
  • Code review cues:
  • During review, scrutinize any code that:
  • Accepts arbitrary config dicts from outside the trusted boundary.
  • Passes these configs straight into LangChain's loading functions.
  • Pay special attention to places where raw paths are concatenated, interpolated, or otherwise composed from user-influenced values.
  • Policy and enforcement:
  • Introduce internal guidelines that prohibit the use of raw, user-provided filesystem paths in application logic.
  • Enforce architectural rules (e.g., via linting or custom checks) requiring all file reads to pass through a central validation layer.
  • Runtime monitoring:
  • Where feasible, monitor access patterns to sensitive files and unexpected directories from LangChain-based services, and alert on anomalous file read behavior.

Sources

SourceLink
github.comgithub.com/langchain-ai/langchain/commit/27add913474e01e33bededf4096151130ba0d47c
github.comgithub.com/langchain-ai/langchain/releases/tag/langchain-core==1.2.22
github.comgithub.com/langchain-ai/langchain/security/advisories/GHSA-qh6h-p6c9-ff54
access.redhat.comaccess.redhat.com/errata/RHSA-2026:24766
access.redhat.comaccess.redhat.com/errata/RHSA-2026:37275
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-34070
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2453287
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-34070.json

Frequently asked

questions

It can be, if a remote user can influence the prompt configuration dictionaries that your application passes to load_prompt() or load_prompt_from_config(). In that case, an attacker could craft configurations that cause the server-side process to read unintended files.

The attacker needs the ability to shape or supply configuration data that eventually feeds into the prompt loading functions. This might be via an API endpoint that accepts configuration, a plugin system, or any workflow where external JSON/YAML is deserialized into config dicts. Direct shell or filesystem access is not required.

The most robust approach is to stop treating user-controlled values as raw filesystem paths. Instead, use stable prompt identifiers that are resolved to known-safe paths on the server, and enforce strict base-directory constraints and path normalization for any file access performed by prompt-loading code.

Design APIs and configuration formats so that untrusted input never directly dictates file paths. Centralize all filesystem access behind a well-audited abstraction that:

  • Validates inputs,
  • Restricts access to whitelisted directories,
  • Rejects absolute and parent-relative paths, and
  • Operates under least-privilege permissions.

Regular static analysis, security-focused code review, and clear internal guidelines on file handling further reduce the likelihood of path traversal bugs.

Find out what's already
exploitable in your codebase.