CVE-2026-40087 — LangChain has incomplete f-string validation in prompt templates
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.
Who exploits it and how urgent it is
A 0–100 score combining confirmed exploitation, ransomware and APT use, public exploits, EPSS and severity.
How the score was calculated
- EPSS 0.5% (30-day exploitation probability)+6
- Technical severity (medium)+3
- Automatable exploitation (SSVC)+3
The score orders the patch queue; it does not replace your asset context (internet exposure, criticality, compensating controls).
Triage
Is it exploited, how likely is exploitation, what does it touch, and how severe do the sources call it.
CISA SSVC assessment CISA
Three decision points CISA publishes for the CVEs it assesses (SSVC 2.0.3). A stakeholder decision, not a severity score.
Remediation
Fixes and mitigations documented by the sources — linked to the original advisory.
- Documented patch — github.com (NIST National Vulnerability Database)
- Documented patch — github.com (NIST National Vulnerability Database)
- Documented patch — github.com (NIST National Vulnerability Database)
- Documented patch — github.com (NIST National Vulnerability Database)
- Documented mitigation — github.com (NIST National Vulnerability Database)
First 24 hours
Ordered from the record’s own fields — exposure first, because you cannot patch what you have not found. A rule-generated starting point.
- Identify exposed assets running the affected vendor/product/version combinations (Langchain Langchain Core, Langchain-ai Langchain-ai/langchain).
- The attack is network-based and needs no privileges: restrict exposure (ACLs, VPN, WAF) until patched.
- Apply the fixed version or the patch documented under Remediation.
- Search available logs for exploit probes, errors and authentication anomalies.
Affected scope
Vendor, product and versions as the sources word them.
| Vendor | Product | Versions | Status | Source |
|---|---|---|---|---|
| Langchain | Langchain Core | < 0.3.84≥ 1.0.0 and < 1.2.28 | Vulnerable | NIST National Vulnerability Database |
| Langchain-ai | Langchain-ai/langchain | version < 0.3.83version >= 1.0.0a1, < 1.2.28 | Vulnerable | CVE Program (cve.org) e CISA ADP |
Attack characteristics
The CVSS vector, decoded. It describes the attack, not your exposure to it.
Every base score collected
Sources score independently and may disagree; each row says who scored it and under which version.
| Score | Version | Severity | Expl. | Impact | Scored by |
|---|---|---|---|---|---|
| 5.3 | CVSS 3.1 | Medium | 3.9 | 1.4 | security-advisories@github.com via NIST National Vulnerability Database |
| 5.3 | CVSS 3.1 | Medium | — | — | GitHub_M via CVE Program (cve.org) e CISA ADP |
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N (score shown at the top: security-advisories@github.com) Weakness MITRE
Weakness class according to MITRE’s CWE catalog.
EPSS over time FIRST
Oct 13, 2026 → Oct 14, 2026 · 2 reading(s) · max 0.45%
Detection
Read off the CVSS vector and the weakness class. Starting points, not tested rules.
- Prioritize edge telemetry for the network-reachable component (proxy, WAF, IDS/IPS).
Timeline
What happened to this CVE, newest first.
- 2026
- Affected products added · langchain-ai/langchain
- SSVC assessment updated
- Record published
- Fix documented
- CVSS changed · 5.3
- Source status changed · → Analyzed
- Record created in this database
- CVE published
Source activity
Repeated readings are counted rather than listed.
- 1× Official description updated · Oct 13, 2026 – Oct 13, 2026
References
7 on the record
- github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw
- github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27
- github.com/langchain-ai/langchain/pull/36612
- github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe25
- github.com/langchain-ai/langchain/pull/36613
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28
Elsewhere on this site
Related CVEs (same products)
- Medium CVE-2026-55443 LangChain: Path traversal and sandbox escape in LangChain file-search middleware and loaders Jun 22, 2026
- High CVE-2026-44843 LangChain: Unsafe deserialization of attacker-controlled LangChain objects through overly broad `load()` allowlists May 26, 2026
- High CVE-2026-34070 LangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functions Mar 31, 2026
- Low CVE-2026-26013 LangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messages Feb 10, 2026
- High CVE-2024-58340 LangChain <= 0.3.1 MRKLOutputParser ReDoS Jan 12, 2026
- Critical CVE-2025-68665 LangChain serialization injection vulnerability enables secret extraction Dec 23, 2025
Not in any source we poll
Listed rather than left blank: an empty field and an unmeasured one look identical on screen, and only one is a reason to look elsewhere.
- No confirmed IOCs, IP addresses, domains, file hashes, or malware artifacts supplied.
- No organization-specific asset inventory, compensating-control status, or patch deployment evidence supplied.
- No exploit packet captures, log samples, or incident case IDs supplied.
Answered from this record
Text assembled only from the fields above — no additional claims.
What should defenders know first?
CVE-2026-40087 is "LangChain has incomplete f-string validation in prompt templates", rated Medium. It affects Langchain Core (Langchain); versions are in the scope table. It is not in CISA KEV, which does not rule out exploitation. CVSS 5.3 describes technical severity. EPSS 0.45% estimates the probability of exploitation in 30 days; neither replaces your asset context. First verify whether exposed or business-critical assets run the affected versions, apply vendor fixes or mitigations, and preserve logs for review.
Comments
Moderated technical discussion. Read the community guidelines.
No comments yet.
Sign in or create an account to comment and suggest corrections.