{"cve":"CVE-2026-40087","nvd":{"published":"2026-04-09T20:16:27.400","modified":"2026-10-25T23:10:00.167","status":"Analyzed","description":"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_v4":null,"cvss_v3":{"version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N","score":5.3},"cwes":["CWE-1336"],"references":["https://github.com/langchain-ai/langchain/commit/6bab0ba3c12328008ddca3e0d54ff5a6151cd27b","https://github.com/langchain-ai/langchain/commit/af2ed47c6f008cdd551f3c0d87db3774c8dfe258","https://github.com/langchain-ai/langchain/pull/36612","https://github.com/langchain-ai/langchain/pull/36613","https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.84"],"products":["langchain:langchain_core"],"source":"nvd","synced_at":"2026-10-25T23:44:33.281319194+00:00"},"epss":{"cve":"CVE-2026-40087","score":0.00262,"percentile":0.17795,"date":"2026-10-26"},"kev":null,"osv":[{"id":"GHSA-926x-3r5x-gfhw","url":"https://osv.dev/vulnerability/GHSA-926x-3r5x-gfhw","summary":"LangChain has incomplete f-string validation in prompt templates","modified":"2026-09-10T03:51:01.352737245Z","packages":[{"ecosystem":"PyPI","name":"langchain-core","purl":"pkg:pypi/langchain-core","ranges":["<0.3.84"],"fixed":["0.3.84"]},{"ecosystem":"PyPI","name":"langchain-core","purl":"pkg:pypi/langchain-core","ranges":[">=1.0.0a1 <1.2.28"],"fixed":["1.2.28"]}]},{"id":"PYSEC-2026-2563","url":"https://osv.dev/vulnerability/PYSEC-2026-2563","summary":"LangChain has incomplete f-string validation in prompt templates","modified":"2026-07-13T16:31:48.838699776Z","packages":[{"ecosystem":"PyPI","name":"langchain-core","purl":"pkg:pypi/langchain-core","ranges":["<0.3.84",">=1.0.0a1 <1.2.28"],"fixed":["0.3.84","1.2.28"]}]}],"attribution":["This product uses the NVD API but is not endorsed or certified by the NVD.","EPSS scores: FIRST Exploit Prediction Scoring System, https://www.first.org/epss","Known exploited vulnerabilities: CISA Known Exploited Vulnerabilities Catalog, https://www.cisa.gov/known-exploited-vulnerabilities-catalog","Package advisories: OSV (https://osv.dev), from the GitHub Advisory Database, PyPA, Go, RustSec and other ecosystem databases, under CC-BY 4.0 or CC0","CVE records: the CVE Program's CVE List (https://www.cve.org), under its terms of use (https://www.cve.org/Legal/TermsOfUse). CVE is a registered trademark of The MITRE Corporation; this product is not affiliated with the CVE Program."]}