CVE-2026-40087 json
LangChain has incomplete f-string validation in prompt templates
published 2026-04-08 7 mo ago modified 2026-10-25 14 d ago also EUVD-2026-21063 , GHSA-926x-3r5x-gfhw , PYSEC-2026-2563
- cvss
- 5.3
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 0.3%
- EPSS 0.3% chance of exploitation in 30 days, percentile 19%
- public exploits
- 0
- none known
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.
Patch / fix
- pypi langchain-core 0.3.84, 1.2.28
- langchain langchain_core 0.3.83, 1.2.28
- github.com/langchain-ai/langchain@6bab0ba commit
- github.com/langchain-ai/langchain@af2ed47 commit
- github.com/langchain-ai/langchain#36612 pull request
- github.com/langchain-ai/langchain#36613 pull request
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.… release
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.… release
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2026-40087 updated cvss 5.3
langchain: incomplete f-string validation in prompt templates
-
Red Hat Migration Toolkit for Applications 8 redhat-user-workloads/ocp-art-tenant/art-images Red Hat OpenShift Lightspeed openshift-lightspeed/lightspeed-service-api-rhel9 Red Hat Ansible Automation Platform 2 ansible-automation-platform-25/lightspeed-chatbot-rhel8, ansible-automation-platform-24/lightspeed-rhel8-operator Red Hat Enterprise Linux AI (RHEL AI) 3 rhelai3/bootc-cuda-rhel9, rhelai3/bootc-rocm-rhel9, rhelai3/disk-image-cuda-rhel9 Red Hat OpenShift AI (RHOAI) rhoai/odh-mlflow-rhel9, rhoai/odh-llama-stack-core-rhel9, rhoai/odh-trustyai-nemo-guardrails-server-rhel9affected: workaround, no fix available “Fix deferred”
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
CISA SSVC
- Exploitation
- none
- Automatable
- yes
- Technical impact
- partial
- Assessed
- 6 mo ago
Exploit prediction
0.27% chance of exploitation in the next 30 days, higher than 19% of all scored CVEs (FIRST EPSS, 2026-11-08).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 5.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N |
| GitHub | 3.1 | 5.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N |
| OSV | 3.1 | 5.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| pypi | langchain-core | <0.3.84 >=1.0.0a1, <1.2.28 |
0.3.84 1.2.28 |
Affected products
- langchain-ai langchain
Classification
References
-
github.com
/langchain-ai/langchain/pull/36612
web, issue-tracking, patch
-
github.com
/langchain-ai/langchain/pull/36613
web, issue-tracking, patch
-
github.com
/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b
web, patch
-
github.com
/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258
web, patch
-
github.com
/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw
web, mitigation, vendor-advisory
-
github.com
/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84
web, product, release-notes
-
github.com
/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28
web, product, release-notes
-
nvd.nist.gov
/vuln/detail/CVE-2026-40087
advisory
-
github.com
/langchain-ai/langchain
package
-
pypi.org
/project/langchain-core
package
-
github.com
/advisories/GHSA-926x-3r5x-gfhw
advisory
Sources
- CVE List CVE-2026-40087
- GitHub Advisory GHSA-926x-3r5x-gfhw
- NVD CVE-2026-40087
- OSV PYSEC-2026-2563
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.
CPEs and fixed versions use Anchore's correction of NVD's data: Added CPE configurations because not yet analyzed by NVD.