Vulnerability in Langchain Core
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 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.
Published · last modified .
CVSS v3 metric
CVSS v3 base score 5.3 (Medium). Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
EPSS exploit prediction
EPSS: 0.005 (36.9th percentile), scored .
Very low probability of exploitation in the next 30 days; routine patching cadence is appropriate. 37th percentile — 36.9% of CVEs in the catalogue have a lower EPSS than this one. How to read EPSS.
EPSS over last 30 days · oldest: 0.003 · newest: 0.005 · change: +0.002
Affected products
- Langchain Core
- Langchain-Ai Langchain — versions < 0.3.83, >= 1.0.0a1, < 1.2.28
Weakness classification (CWE)
References
- github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw (Mitigation, Vendor Advisory)
- github.com/langchain-ai/langchain/pull/36612 (Patch, Issue Tracking)
- github.com/langchain-ai/langchain/pull/36613 (Patch, Issue Tracking)
- github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd2… (Patch)
- github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe2… (Patch)
- github.com/langchain-ai/langchain/releases/tag/langchain-core==0.3.84 (Product, Release Notes)
- github.com/langchain-ai/langchain/releases/tag/langchain-core==1.2.28 (Product, Release Notes)
Frequently asked questions
- What is CVE-2026-40087?
- CVE-2026-40087 is a medium-severity vulnerability in Langchain Core, classified under Improper Neutralization of Special Elements Used in a Template Engine. CVSS score: 5.3/10. Published 2026-04-09.
- How severe is CVE-2026-40087?
- Medium severity. CVSS v3 base score is 5.3 out of 10.