CVE-2026-40087: LangChain has incomplete f-string validation in prompt templates
langchain-ai · langchain
Affected: langchain-ai · Exploitation: unlikely (under 1%)
Not in CyberSIXT coverage yet: no article names this CVE. This page shows the public record.
Higher than 19% of scored CVEs
DescriptionCVE.org
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.
Affected products1
From the CVE record. A product or version that is not listed is unknown, not unaffected.
- langchain-ai · langchain< 0.3.83; >= 1.0.0a1, < 1.2.28
On the Atlas
Every published CVE is on the CyberSIXT Atlas, grouped by weakness, vendor and month.
- Exploitation
- Unlikely (under 1%). EPSS under 1%, or no score yet.
- CISA KEV
- Not listed
- Public check
- No public nuclei template
- Weakness
- Improper Neutralization of Special Elements Used in a Template Engine · Command and Code Injection
- Vendor
- langchain-ai
- Published
- April 2026
CoverageNo articles yet
No CyberSIXT article names CVE-2026-40087 yet, so there is no coverage timeline, action brief or change log for it. Everything on this page comes from the public CVE record, CISA KEV, EPSS and the nuclei template index. Search the archive or see the CVEs in the news.
References
- NVD entrynvd.nist.gov
- CVE recordcve.org
- Weakness CWE-1336cwe.mitre.org
- github.com/langchain-ai/langchain/security/advisories/GHSA-926x-github.com
- github.com/langchain-ai/langchain/pull/36612github.com
- github.com/langchain-ai/langchain/pull/36613github.com
- github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3egithub.com
- github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0github.com
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3Dgithub.com
- github.com/langchain-ai/langchain/releases/tag/langchain-core%3Dgithub.com