cve.bz

CVE-2026-40087 langchain langchain core

5.3 mediumEPSS 0.3%Fix available

Medium (5.3) in langchain langchain core. EPSS 0.3% estimated probability of exploitation activity in the next 30 days. Fixed in langchain-core 0.3.84, 1.2.28.

On this page
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.

Severity

CVSS 3.1

5.3 medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
EPSS
0.3% (unchanged from 0.3% a week ago; 0.5% 30 days ago) estimated probability of exploitation activity in the next 30 days; 20th percentile. Scored 2026-11-17. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: none · Automatable: yes · Technical impact: partial, assessed 2026-04-14. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWE
CWE-1336 Improper Neutralization of Special Elements Used in a Template Engine
Published
Modified
NVD analysis
Analyzed
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2026-40087 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2026-40087?via=ask-ai-copy and https://cve.bz/cve/CVE-2026-40087?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2026-40087 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
langchain:langchain_corebefore 0.3.84
langchain:langchain_corefrom 1.0.0 before 1.2.28

Packages (OSV)

AdvisoryEcosystemPackageAffectedFixed in
GHSA-926x-3r5x-gfhwPyPIlangchain-core<0.3.840.3.84
GHSA-926x-3r5x-gfhwPyPIlangchain-core>=1.0.0a1 <1.2.281.2.28
PYSEC-2026-2563PyPIlangchain-core<0.3.84
>=1.0.0a1 <1.2.28
0.3.84, 1.2.28

Red Hat

Red Hat rates this Moderate.

Red Hat's statement

To exploit this vulnerability, an attacker needs to supply a specially crafted input to the `DictPromptTemplate` or `ImagePromptTemplate` classes. The payload must contain Python attribute access expressions (e.g., accessing internal object classes), which bypass the template validator and get executed by the underlying f-string formatter, potentially causing information disclosure. There is no memory corruption or arbitrary code execution. Due to these reasons, this flaw has been rated with a moderate severity.

Red Hat's mitigation

To mitigate this vulnerability, validate and sanitize any user-supplied input before it is passed into a DictPromptTemplate or ImagePromptTemplate. Reject any input containing curly braces unless they are strictly necessary and controlled. Furthermore, strip or reject input strings that attempt to use nested replacement fields (e.g., fields hidden within format specifiers like {value:{nested_format}}).

ProductPackageStateAdvisory
Migration Toolkit for Applications 8redhat-user-workloads/art-imagesFix deferred
OpenShift Lightspeedopenshift-lightspeed/lightspeed-service-api-rhel9Fix deferred
Red Hat Ansible Automation Platform 2ansible-automation-platform-24/lightspeed-rhel8-operatorFix deferred
Red Hat Ansible Automation Platform 2ansible-automation-platform-25/lightspeed-chatbot-rhel8Fix deferred
Red Hat Enterprise Linux AI (RHEL AI) 3rhelai3/bootc-cuda-rhel9Fix deferred
Red Hat Enterprise Linux AI (RHEL AI) 3rhelai3/bootc-rocm-rhel9Fix deferred
Red Hat Enterprise Linux AI (RHEL AI) 3rhelai3/disk-image-cuda-rhel9Fix deferred
Red Hat OpenShift AI (RHOAI)rhoai/odh-llama-stack-core-rhel9Fix deferred
Red Hat OpenShift AI (RHOAI)rhoai/odh-mlflow-rhel9Fix deferred
Red Hat OpenShift AI (RHOAI)rhoai/odh-trustyai-nemo-guardrails-server-rhel9Fix deferred

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2026-40087.

References

Check your stackJSON