LangChain has incomplete f-string validation in prompt templates
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Code execution
- Confidentiality · integrity · availability
- Low · None · None
- Fix status
- Partial Red Hat: 5 without a fix
Attack profile from CVSS 3.1 · CNA. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-1336.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- Yes
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| langchain-ai | langchain | before 0.3.83; 1.0.0a1 to before 1.2.28 | 0.3.83, 1.2.28 | Patch available | CNA |
| — | langchain-core (PyPI) | before 0.3.84 | 0.3.84 | Patch available | GHSA-926x-3r5x-gfhw |
| — | langchain-core (PyPI) | 1.0.0a1 to before 1.2.28 | 1.2.28 | Patch available | GHSA-926x-3r5x-gfhw |
- langchain Vendorlangchain-ai Affected before 0.3.83; 1.0.0a1 to before 1.2.28 Fixed in 0.3.83, 1.2.28 Patch available CNA
- langchain-core (PyPI) Vendor— Affected before 0.3.84 Fixed in 0.3.84 Patch available GHSA-926x-3r5x-gfhw
- langchain-core (PyPI) Vendor— Affected 1.0.0a1 to before 1.2.28 Fixed in 1.2.28 Patch available GHSA-926x-3r5x-gfhw
CPE configurations NVD · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:* | before 0.3.84; 1.0.0 to before 1.2.28 | Vulnerable | langchain-ai |
- cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:* Versions before 0.3.84; 1.0.0 to before 1.2.28 Vulnerable ·langchain-ai
Remediation
- Fix · CNA langchain (langchain-ai) Fixed in 0.3.83, 1.2.28
- Fix · GHSA-926x-3r5x-gfhw langchain-core (PyPI) Fixed in 0.3.84 Advisory →
- Fix · GHSA-926x-3r5x-gfhw langchain-core (PyPI) Fixed in 1.2.28 Advisory →
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Migration Toolkit for Applications 8 | Affected | No fix yet: Fix deferred |
| OpenShift Lightspeed | Affected | No fix yet: Fix deferred |
| Red Hat Ansible Automation Platform 2 | Affected | No fix yet: Fix deferred |
| Red Hat Enterprise Linux AI (RHEL AI) 3 | Affected | No fix yet: Fix deferred |
| Red Hat OpenShift AI (RHOAI) | Affected | No fix yet: Fix deferred |
Timeline
- 2026-10-02 Threatist record created from CVE-2026-40087
- 2026-10-03 Alias added: GHSA-926x-3r5x-gfhw
References
Patch 4
Advisory 2
More langchain-ai Langchain Core vulnerabilities
- TI-2025-42157 LangChain serialization injection vulnerability enables secret extraction in dumps/loads APIs CVSS 3.1CRITICAL 9.3
- TI-2026-26395 LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions CVSS 3.1HIGH 7.5
- TI-2026-21027 LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages CVSS 3.1LOW 3.7
Sources
- CVE-2026-40087 · CVE Program
- CVE-2026-40087 · NVD
- FIRST EPSS
- GHSA-926x-3r5x-gfhw · GitHub Advisory Database · CC BY 4.0
- CVE-2026-40087 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences