Mend.io Vulnerability Database
The largest open source vulnerability database
What is a Vulnerability ID?
New vulnerability? Tell us about it!
CVE-2026-40087
Published:April 09, 2026
Updated:April 25, 2026
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 Packages
https://github.com/langchain-ai/langchain.git (GITHUB):
Affected version(s) >=langchain-core==0.1.47 <langchain-core==0.3.84
Fix Suggestion:
Update to version langchain-core==0.3.84
https://github.com/langchain-ai/langchain.git (GITHUB):
Affected version(s) >=langchain-core==1.0.0a1 <langchain-core==1.2.28
Fix Suggestion:
Update to version langchain-core==1.2.28
langchain-core (PYTHON):
Affected version(s) >=0.0.1 <0.3.84
Fix Suggestion:
Update to version 0.3.84
langchain-core (PYTHON):
Affected version(s) >=1.0.0a1 <1.2.28
Fix Suggestion:
Update to version 1.2.28
Do you need more information?
Contact Us
CVSS v4
Base Score:
6.9
Attack Vector
NETWORK
Attack Complexity
LOW
Attack Requirements
NONE
Privileges Required
NONE
User Interaction
NONE
Vulnerable System Confidentiality
LOW
Vulnerable System Integrity
NONE
Vulnerable System Availability
NONE
Subsequent System Confidentiality
NONE
Subsequent System Integrity
NONE
Subsequent System Availability
NONE
CVSS v3
Base Score:
5.3
Attack Vector
NETWORK
Attack Complexity
LOW
Privileges Required
NONE
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
LOW
Integrity
NONE
Availability
NONE
Weakness Type (CWE)
Improper Input Validation
Improper Neutralization of Special Elements Used in a Template Engine
EPSS
Base Score:
0.05