CVE-2026-40087

LangChain has incomplete f-string validation in prompt templates

MEDIUM
5.3
CVSS Score
Published: April 9, 2026 at 07:34 PM UTC
Updated: October 25, 2026 at 11:10 PM UTC
2 products affected across 2 vendorsLangchain CoreLangChain

Using langchain by langchain-ai?

Get instant alerts when new vulnerabilities affect langchain - before attackers find them.

Real-time alertsTrack your software stackFree plan available
Severity
MEDIUM5.3
Exploit prediction
EPSS 0.3%
SSVC
No known exploit

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.

Affected

Our own answer: ranges merged, affected separated from platform-only, with confidence and review flags.

v < 0.3.841.0.0 ≤ v < 1.2.28
v < 0.3.83
Affected range stops below 0.3.83, so it looks safe — our inference, not a vendor statement
Affected range stops below 1.2.28, so it looks safe — our inference, not a vendor statement

References (7)

SSVC — Action Prioritization

SSVCNo known exploitAutomatablePartial impact

SSVC signals action urgency (what to patch first), separate from CVSS which measures severity.

CVSS

5.3MEDIUMGitHub_M
Attack Vector
NETWORK
Complexity
LOW
Privileges
NONE
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
LOW
Integrity
NONE
Availability
NONE
Vector?

Quick Info

StatusANALYZED
CWE
CWE-1336

Get alerted

Stop reading CVE feeds looking for your own stack

Track the products you run and VulnTracker tells you when a new CVE affects them — with what is known about fixing it, and nothing about the rest.

Free plan, no card