CVE-2026-40087LangChain has incomplete f-string validation in prompt templates
- 5.3MediumCVSS base score
- 0.27%Exploitation in 30 daysEPSS · top 80% of all CVEs
- NoKnown exploitednot in CISA's KEV catalog
- NonePublic exploitsnone known yet
Description
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 prompt template classes accepted f-string templates and formatted them without enforcing the same attribute-access validation as PromptTemplate. In particular, DictPromptTemplate and ImagePromptTemplate could accept templates containing attribute access or indexing expressions and subsequently evaluate those expressions during formatting. Second, f-string validation based on parsed top-level field names did not reject nested replacement fields inside format specifiers. In this pattern, the nested replacement field appears in the format specifier rather than in the top-level field name. As a result, earlier validation based on parsed field names did not reject the template even though Python formatting would still attempt to resolve the nested expression at runtime. This vulnerability is fixed in 0.3.84 and 1.2.28.
Timeline
ID reserved
By GitHub_M
Published
- 5 days later
· 5 days later
Record updated
Changes after publication (a new score, a public exploit, EPSS crossing 1, 10 or 50 %, leaving KEV) are kept since November 2026; earlier ones are not known.
Scores
| Scored by | CVSS | Score | Vector |
|---|---|---|---|
| GitHub_MCNA (assigner) | 3.1 | Medium5.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N |
| NVDNVD · Analyzed | 3.1 | Medium5.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N |
- EPSS (exploitation in 30 days)
- 0.27% · top 80% of all CVEs (12 Nov 2026)
- CISA SSVC
- Exploitation: none · Automatable: yes · Technical impact: partial
The list uses the assigner's score when there is one, then CISA's, then NVD's: Medium 5.3.
Affected products
- affected < 0.3.83
- affected >= 1.0.0a1, < 1.2.28
Affected packages
From reviewed advisories of the GitHub Advisory Database.
- PyPIlangchain-coreGHSA-926x-3r5x-gfhw (opens in a new tab)
References
References7
- https://github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw (opens in a new tab)x_refsource_CONFIRM
- https://github.com/langchain-ai/langchain/pull/36612 (opens in a new tab)x_refsource_MISC
- https://github.com/langchain-ai/langchain/pull/36613 (opens in a new tab)x_refsource_MISC
- https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b (opens in a new tab)x_refsource_MISC
- https://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258 (opens in a new tab)x_refsource_MISC
- https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84 (opens in a new tab)x_refsource_MISC
- https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28 (opens in a new tab)x_refsource_MISC
Sources
The same CVE in the primary databases and aggregators, to check against.
- CVE.org record (opens in a new tab)
- CVE List JSON (GitHub) (opens in a new tab)
- NVD (opens in a new tab)
- FIRST EPSS (opens in a new tab)
- EUVD EUVD-2026-21063 (opens in a new tab)
- OSV.dev (opens in a new tab)
- GitHub Advisory GHSA-926x-3r5x-gfhw (opens in a new tab)
- CIRCL Vulnerability-Lookup (opens in a new tab)
Badge for a README or a ticket
[](https://cveledger.app/cve/CVE-2026-40087)Record last updated .