CVE-2026-34070: LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions
langchain-core before 1.2.22 reads files from paths inside prompt config dicts without checking for absolute paths or .. sequences. If an app passes untrusted prompt configs to load_prompt() or load_prompt_from_config(), an attacker can read .txt, .json, .yaml and .yml files on the host. Upgrade to 1.2.22.
Published Mar 27, 2026 · Updated Mar 31, 2026 · Analysis Oct 31, 2026
What an attacker can do
The legacy loader in langchain_core/prompts/loading.py follows file paths named in the config. _load_template() reads template_path, suffix_path and prefix_path (.txt files). _load_examples() reads a string examples value, and _load_few_shot_prompt() reads example_prompt_path (.json, .yaml and .yml files). None of them rejected an absolute path such as /tmp/secret.txt or a traversal such as ../../etc/secret.txt.
The attacker needs a way to get a config into the loader. Low-code AI builders and API wrappers that expose load_prompt_from_config() to users are the realistic cases. No account, no user interaction and no privileges are needed on such an endpoint, hence a network CVSS vector of 7.5 with confidentiality impact only.
The file extension limits what can be read, but the reachable files are valuable: mounted secrets like /mnt/secrets/api_key.txt, requirements.txt, system prompts, and ~/.docker/config.json, ~/.azure/accessTokens.json, Kubernetes manifests and CI/CD configs. The flaw reads files. It does not write or run anything. Applications that only load prompts from trusted code are unaffected in practice.
Who is affected
langchain-core below 1.2.22. Affected functions: load_prompt, load_prompt_from_config and the legacy .save() method on prompt classes, which are undocumented APIs. Apps that never call them with untrusted input are not exposed. Check the version:
pip show langchain-corelangchain-core
- Ecosystem
- PyPI
- Affected
- < 1.2.22
- Fixed in
- 1.2.22
- Check
pip show langchain-core
How to fix it
Upgrade to langchain-core 1.2.22:
pip install --upgrade "langchain-core>=1.2.22"The fix rejects absolute paths and .. sequences by default. A keyword argument, allow_dangerous_paths=True, exists on load_prompt() and load_prompt_from_config() for trusted inputs only; do not set it for user-supplied configs. The legacy APIs are deprecated and will be removed in 2.0.0. Move to dumpd, dumps, load and loads from langchain_core.load, which do not read the filesystem and use an allowlist.
How to tell if you were hit
Search your code for load_prompt and load_prompt_from_config, and trace whether the config comes from users or external storage. Review request logs for prompt configs containing template_path, suffix_path, prefix_path, example_prompt_path, or an examples string pointing at a path with .. or a leading slash. Check whether secret files such as cloud tokens sat on hosts that ran these endpoints, and rotate them if exposure is possible.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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 key | Loaded by | Readable 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
- jiayuqi7813 reporter
- VladimirEliTokarev reporter
- Rickidevs reporter
- Kenneth Cox ([email protected]) reporter
Credited to jiayuqi7813, VladimirEliTokarev, Rickidevs, kennethkcox.
Questions
- Is CVE-2026-34070 exploitable in a normal LangChain app?
Only if the app passes user-influenced prompt configs to the legacy loader. The functions are undocumented legacy APIs, so most apps never expose them.
- Which files can be read?
Files ending in .txt for templates, and .json, .yaml or .yml for examples and example prompts. Other extensions are blocked by the loader's checks.
- What does allow_dangerous_paths do?
It turns the new path validation off for one call. The advisory says to use it only for trusted inputs.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More LangChain vulnerabilities
All LangChain entriesCVE-2026-55443
LangChain: Path traversal and sandbox escape in LangChain file-search middleware and loaders
medium5.1Jun 16, 2026CVE-2026-45134
LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary warning
high7.1May 13, 2026CVE-2026-44843
LangChain vulnerable to unsafe deserialization of attacker-controlled objects through overly broad `load()` allowlists
high8.2May 8, 2026CVE-2026-40087
LangChain has incomplete f-string validation in prompt templates
medium5.3Apr 8, 2026CVE-2026-27795
LangChain Community: redirect chaining can lead to SSRF bypass via RecursiveUrlLoader
medium4.1Feb 25, 2026CVE-2026-26013
LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages
low3.7Feb 11, 2026
