CVE-2026-40087

MEDIUM EPSS 17.5%
Published Apr 9, 20262mo ago · Modified Jun 17, 20262w ago
5.3 CVSS 3.1
Medium
Find Similar
Published Apr 9, 2026 2mo ago
Last Modified Jun 17, 2026 2w ago

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 Details

Base Score
5.3
Exploitability
3.9
Impact
1.4
Vector string
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
Attack Vector Network
Attack Complexity Low
Privileges Required None
User Interaction None
Scope Unchanged
Confidentiality Low
Integrity None
Availability None

Threat Intelligence

EPSS Exploit Probability
17.5% percentile
Exploit & Patch Status
No Known Exploit
Patch Available

Weaknesses 1

CWE-1336

Affected Products 2

VendorProductVersionRange
langchainlangchain_core* <0.3.84
langchainlangchain_core*≥1.0.0  –  <1.2.28

References 7

  • github.com https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b
    Patch
  • github.com https://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258
    Patch
  • github.com https://github.com/langchain-ai/langchain/pull/36612
    Issue TrackingPatch
  • github.com https://github.com/langchain-ai/langchain/pull/36613
    Issue TrackingPatch
  • github.com https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84
    ProductRelease Notes
  • github.com https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28
    ProductRelease Notes
  • github.com https://github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw
    MitigationVendor Advisory

Remediation

  • github.com https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b
    Patch
  • github.com https://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258
    Patch
  • github.com https://github.com/langchain-ai/langchain/pull/36612
    Issue TrackingPatch
  • github.com https://github.com/langchain-ai/langchain/pull/36613
    Issue TrackingPatch