Quick answers
- Is CVE-2026-40087 exploited in the wild?
- No. Junglewise Threat Intelligence has no report of CVE-2026-40087 being exploited in the wild.
- How severe is CVE-2026-40087?
- Medium severity, with a CVSS score of 5.3, published 9 April 2026.
- Which products and versions are affected?
- langchain-core (PyPI) ECOSYSTEM:introduced=0,fixed=0.3.84, ECOSYSTEM:introduced=0,fixed=0.3.84,introduced=1.0.0a1,fixed=1.2.28.
- Is there a fix for CVE-2026-40087?
- Yes. langchain-core (PyPI): upgrade to 0.3.84, 1.2.28 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
- How is CVE-2026-40087 attacked?
- It is attacked over the network, in a software library.
- Am I affected by CVE-2026-40087?
- Check whether you run Langchain Core or langchain-core (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.
How to fix
- langchain-core (PyPI): upgrade to 0.3.84, 1.2.28 or later
pip install "langchain-core>=1.2.28"
Technical details
LangChain's f-string validation failed to properly sanitize input in DictPromptTemplate and ImagePromptTemplate, and failed to reject nested replacement fields within format specifiers. This vulnerability allows for improper neutralization of special elements (CWE-1336) and improper input validation (CWE-20). An attacker who can provide untrusted template strings can use Python attribute access (e.g., .__class__) or indexing to traverse internal objects passed into the template during formatting. This can result in the disclosure of internal fields or sensitive data to the model context or logs. The issue is resolved in langchain-core versions 0.3.84 and 1.2.28 by enforcing consistent f-string safety validation and rejecting nested replacement fields.
Affected products
- LangChain langchain-core < 0.3.83, >= 1.0.0a1, < 1.2.28
Identifiers
- CVE-2026-40087
- GHSA-926x-3r5x-gfhw
- PYSEC-2026-2563
Timeline
- 2026-04-08: advisory: GitHub Advisory GHSA-926x-3r5x-gfhw published
- 2026-04-08: patched: Fixes merged in PR #36612 and #36613
- 2026-04-09: other: NVD published CVE-2026-40087
References
- https://github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw
- https://github.com/langchain-ai/langchain/pull/36612
- https://github.com/langchain-ai/langchain/pull/36613
- https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b
- https://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258
- https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84