CVE-2026-40087
CVE-2026-40087 is a medium-severity vulnerability in Langchain Langchain Core with a CVSS 3.x base score of 5.3. It is not currently listed as actively exploited by CISA, and its EPSS exploit-prediction score is low. The underlying weakness is classified as CWE-1336.
Key facts
- Severity: Medium (CVSS 3.x base score 5.3)
- EPSS exploit prediction: 0% (18th percentile)
- Actively exploited: Not listed in CISA KEV
- EU (EUVD) id: EUVD-2026-21063
- Weakness: CWE-1336
- Affected product: Langchain Langchain Core
- Published:
- Last modified:
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.
Frequently asked questions
- What is 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.
- How severe is CVE-2026-40087?
- CVE-2026-40087 has a CVSS 3.x base score of 5.3, rated medium severity. It is exploitable over network with low attack complexity, requires no privileges and no user interaction. Impact on confidentiality is low, integrity none, and availability none.
- Is CVE-2026-40087 being actively exploited?
- It is not currently listed in CISA's KEV catalog. Its EPSS exploit-prediction score is 0% (18th percentile), an estimate of the probability of exploitation in the next 30 days.
- What products are affected by CVE-2026-40087?
- CVE-2026-40087 affects Langchain Langchain Core. See the affected-products list for the exact vulnerable versions.
- How do I fix CVE-2026-40087?
- Review the linked vendor and NVD advisories for patched versions and mitigations, then upgrade or apply the recommended workaround.
- Does CVE-2026-40087 have an EU (EUVD) identifier?
- Yes. CVE-2026-40087 is tracked in the ENISA EU Vulnerability Database (EUVD) as EUVD-2026-21063.
- When was CVE-2026-40087 published?
- CVE-2026-40087 was published on 2026-04-09 and last updated on 2026-06-17.
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
Affected products (1)
- cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:*
More vulnerabilities in Langchain Langchain Core
- CVE-2025-68664 — Critical (CVSS 9.3): LangChain is a framework for building agents and LLM-powered applications. Prior to versions 0.3.81 and 1.2.5, a…
- CVE-2026-34070 — High (CVSS 7.5): LangChain is a framework for building agents and LLM-powered applications. Prior to version 1.2.22, multiple functions…
- CVE-2026-26013 — Low (CVSS 3.7): LangChain is a framework for building agents and LLM-powered applications. Prior to 1.2.11, the…
All CVEs affecting Langchain Langchain Core →
Other CWE-1336 vulnerabilities
- CVE-2025-53833 — Critical (CVSS 10.0): LaRecipe is an application that allows users to create documentation with Markdown inside a Laravel app. Versions prior…
- CVE-2024-32651 — Critical (CVSS 10.0): changedetection.io is an open source web page change detection, website watcher, restock monitor and notification…
- CVE-2026-45312 — Critical (CVSS 9.9): RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine. In 0.24.0 and earlier, a Jinja2 template…
- CVE-2026-9558 — Critical (CVSS 9.9): A Server-Side Template Injection (SSTI) vulnerability exists in Mautic's theme engine. The platform renders uploaded…
- CVE-2026-33897 — Critical (CVSS 9.9): Incus is a system container and virtual machine manager. Prior to version 6.23.0, instance template files can be used…
- CVE-2026-1868 — Critical (CVSS 9.9): GitLab has remediated a vulnerability in the Duo Workflow Service component of GitLab AI Gateway affecting all versions…