5.3

CVE-2026-40087: LangChain has incomplete f-string validation in prompt templates

Analyzed
AliasesGHSA-926x-3r5x-gfhwPYSEC-2026-2563CGA-h9qq-qw3w-4vcv
Published 09-04-2026Last modified 14-04-2026

Vulnerability summary

CVE-2026-40087 is a medium (CVSS 5.3) vulnerability in langchain-ai langchain. EPSS estimates a 0.28% chance of exploitation in the next 30 days, higher than 21.6% of scored vulnerabilities.

Priority
Routine

Not severe (CVSS 5.3, network access); no exploitation reported by the 5 checked sources

Source freshness unavailable

How is this decided?
CVSS score
5.3/10
010
Medium · v3.1 (CVE.org)
EPSS score
0.28%
0%100%
Low · +0.02 pp in 30 days
KEVNot listedNot listed by any tracked catalog.
RansomwareNot flaggedNo ransomware use recorded.
Public exploits0No public exploits recorded

Advisory lineage

Upstream 0 · Downstream 0 · Related 1

Timeline

  1. 09-04-2026
    PublishedVulnerability first disclosed.
  2. 14-04-2026
    Last 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

EPSS trend

Probability

0.28%

Chance of exploitation in the next 30 days

Percentile

22%

Versus all other CVEs

30-day change

Increase +0.02 pp

From 0.26% on 04-11-2026

04-11-202604-12-2026

Known exploited

Compare KEV catalogs
CISA KEV

Not in the CISA KEV catalog.

ENISA CNW

Not in the ENISA CNW catalog.

CIRCL

Not in the CIRCL catalog.

Public exploits

0 found

No public exploits indexed.

Weaknesses

CWE · root cause

Affected systems

Version check

Known conditions: network-reachable, no authentication, no user interaction (CVSS vector). Other conditions: not stated in public data.

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-ai1 product
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
Show all 12 references