
CVE catalog
CVE-2026-40087
LangChain is a framework for building agents and LLM-powered applications. Prior to 0.3.84 and 1.2.28, LangChain's f-string prompt-template validation was incomplete in two respects. First, some promp
- Severity
- Medium · CVSS 5.3
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N - Published
- Source
- [NVD] · [CVE record]
- EPSS
- 0.26% · Oct 25, 2026
A flaw was found in LangChain. A missing validation of f-string prompt templates in some classes, specifically in `DictPromptTemplate` and `ImagePromptTemplate`, can cause the evaluation of attribute access or indexing expressions during template formatting. Also, f-string validation based on parsed top-level field names did not reject nested replacement fields inside format specifiers. A remote attacker can exploit this issue by providing a specially crafted prompt template, potentially leading to information disclosure. langchain: incomplete f-string validation in prompt templates To exploit this vulnerability, an attacker needs to supply a specially crafted input to the `DictPromptTemplate` or `ImagePromptTemplate` classes. The payload must contain Python attribute access expressions (e.g., accessing internal object classes), which bypass the template validator and get executed by the underlying f-string formatter, potentially causing information disclosure. There is no memory corruption or arbitrary code execution. Due to these reasons, this flaw has been rated with a moderate severity. The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Vulnerable and fixed packages
Distribution-reported package versions and fixes. These do not depend on matching against the OpenFactory package catalog.
| Distribution | Package | Release | Version | Status |
|---|---|---|---|---|
| Cpe | langchain_core | Not reported | 0.3.84 | fixed |
| Cpe | langchain_core | Not reported | 1.2.28 | fixed |
| Cpe | langchain_core | Not reported | 1.2.28 | fixed |
Fixed-version evidence
| Distribution | Package | Type | Release | Fixed version | Urgency | Origin | Bugs |
|---|---|---|---|---|---|---|---|
| Cpe | langchain_core | cpe | Not reported | 0.3.84 | Not reported | Not reported | Not reported |
| Cpe | langchain_core | cpe | Not reported | 1.2.28 | Not reported | Not reported | Not reported |
| Cpe | langchain_core | cpe | Not reported | 1.2.28 | Not reported | NVD-CVE-2026-40087 | Not reported |
OpenFactory catalog packages
No matching packages in this catalog.
Observed:
References
- [https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b]
- [https://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258]
- [https://github.com/langchain-ai/langchain/pull/36612]
- [https://github.com/langchain-ai/langchain/pull/36613]
- [https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84]
- [https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28]
- [https://github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw]
- [https://nvd.nist.gov/vuln/detail/CVE-2026-40087]
- [https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40087.json]
- [https://wid.cert-bund.de/.well-known/csaf/white/2026/wid-sec-w-2026-1027.json]
[CERT-Bund public advisories] · [FIRST EPSS] · [National Vulnerability Database (NVD)] · [Red Hat security advisories and VEX]