CVE-2026-40087: langchain-ai langchain
Vulnerability summary
CVE-2026-40087 is a medium (CVSS 5.3) vulnerability in langchain-ai langchain. EPSS estimates a 0.45% chance of exploitation in the next 30 days, higher than 38% of scored vulnerabilities.
Advisory lineage
Upstream 0 · Downstream 0 · Related 1Timeline
- 09-04-2026PublishedVulnerability first disclosed.
- 14-04-2026Last modifiedVulnerability information updated.
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.
CVSS metrics
5 scores · 5 sources · 1 version- OSV · PypiEcosystem advisory · calculated5.3MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
- OSV · WolfiEcosystem advisory · calculated5.3MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
- OSV · ChainguardEcosystem advisory · calculated5.3MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
- NVDNIST5.3MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
EPSS trend
Probability
0.45%
Chance of exploitation in the next 30 days
Percentile
38%
Versus all other CVEs
30-day change
+0.19 pp
From 0.26% on 19-09-2026
Known exploited
Compare KEV catalogsNot in any of the 3 tracked catalogs.
Public exploits
0 foundNo public exploits indexed.
Weaknesses
CWE · root causeAffected systems
Chainguard6 products
- open-webui< 0.8.12-r3
- py3-langchain< 1.3.0-r0
- py3.10-langchain< 1.3.0-r0
- py3.11-langchain< 1.3.0-r0
- py3.12-langchain< 1.3.0-r0
Langchain1 product
- langchain_core< 0.3.84 | ≥ 1.0.0, < 1.2.28
Langchain-ai1 product
- langchain< 0.3.83 | ≥ 1.0.0a1, < 1.2.28
PyPI1 product
- langchain-core< 0.3.84 | ≥ 1.0.0a1, < 1.2.28
Wolfi1 product
- open-webui< 0.8.12-r3
5 vendors · 10 products
References
12 links- github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhwX Refsource CONFIRMWEBAdvisoryMitigationVendor Advisory
- github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27bX Refsource MISCWEBFIXPatch
- github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258X Refsource MISCWEBFIXPatch
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84X Refsource MISCWEBProductRelease Notes
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28X Refsource MISCWEBProductRelease Notes