Skip to content
MediumVulnerabilityLLM-specific

CVE-2026-40087: LangChain prompt template validation bypass in f-string formatting

Identifier
CVE-2026-40087
Published
Record updated
View JSON
Affected
  • langchain-core < 0.3.83, fixed in 0.3.84, released April 8, 2026, 1 day before disclosure
  • langchain-core >= 1.0.0a1, < 1.2.28, fixed in 1.2.28, released April 8, 2026, 1 day before disclosure
Known exploitation
Not listed in the CISA Known Exploited Vulnerabilities catalog at the last check.
EPSS
0.3%

Summary

LangChain versions prior to 0.3.84 and 1.2.28 contain incomplete f-string prompt-template validation (CVE-2026-40087). DictPromptTemplate and ImagePromptTemplate accepted templates with attribute access or indexing expressions and evaluated them during formatting, and validation based on top-level field names did not reject nested replacement fields inside format specifiers.

Mitigation

Fixed in 0.3.84 and 1.2.28.