CVE-2026-40087: medium-severity vulnerability in langchain-ai langchain
LangChain has incomplete f-string validation in prompt templates
Published · Updated
13Vexday Risk Score
No sign of exploitation. No public exploitation artifact known so far.
ssvc Trackcvss 5.3epss 0.5%
exploitation probability
0.5%top 63% of all CVEs
observed exploitation
nono source reports it
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.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
Affected products
langchain-ai · langchainRelated CVEs — langchain-ai langchain
In the same product, most dangerous first.
CVE-2025-68664CRITICALLangChain serialization injection vulnerability enables secret extraction in dumps/loads APIsEPSS 42.9%CVE-2026-34070HIGHLangChain Core has Path Traversal vulnerabilites in legacy `load_prompt` functionsEPSS 1.2%CVE-2025-65106HIGHLangChain Vulnerable to Template Injection via Attribute Access in Prompt TemplatesEPSS 0.5%CVE-2026-26013LOWLangChain affected by SSRF via image_url token counting in ChatOpenAI.get_num_tokens_from_messagesEPSS 0.4%CVE-2026-44843HIGHLangChain: Unsafe deserialization of attacker-controlled LangChain objects through overly broad `load()` allowlistsEPSS 0.4%CVE-2026-55443MEDIUMLangChain: Path traversal and sandbox escape in LangChain file-search middleware and loadersEPSS 0.2%
References
https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27bhttps://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258https://github.com/langchain-ai/langchain/pull/36612https://github.com/langchain-ai/langchain/pull/36613https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.28https://github.com/langchain-ai/langchain/security/advisories/GHSA-926x-3r5x-gfhw