PyPI: langchain-core

CVE-2025-65106

Safety vulnerability ID: SFTY-20251120-50282

Safety legacy ID: pyup.io-81791

Affected versions of the langchain-core package are vulnerable to Template Injection due to improper neutralization of attribute access and indexing expressions in prompt templates constructed from untrusted input. The ChatPromptTemplate class and related prompt template implementations for f-string, Mustache, and Jinja2 formats allow attacker-controlled template strings such as {msg.class.name} or {{question.parse_raw}} to traverse Python object attributes and dictionary-style lookups, exposing internal properties like class metadata or globals when complex objects such as HumanMessage or other message objects are passed into the template context.

Created at: Dec 9, 2025Updated at: Dec 9, 2025

Overview

LangChain Vulnerable to Template Injection via Attribute Access in Prompt Templates

Advisory

Affected versions of the langchain-core package are vulnerable to Template Injection due to improper neutralization of attribute access and indexing expressions in prompt templates constructed from untrusted input. The ChatPromptTemplate class and related prompt template implementations for f-string, Mustache, and Jinja2 formats allow attacker-controlled template strings such as {msg.class.name} or {{question.parse_raw}} to traverse Python object attributes and dictionary-style lookups, exposing internal properties like class metadata or globals when complex objects such as HumanMessage or other message objects are passed into the template context.

Affected Package

Affecting langchain-core package, versions
>=1.0.0,<=1.0.6
<=0.3.79

Also affects

---

How to Fix

Upgrade
langchain-core
to
1.0.7
0.3.80
or higher.

Mitigation and Workarounds

---

Vulnerable Functions

Functions linked to known vulnerabilities.

Vulnerable function data is available for Enterprise customers

Book a call with us to see Safety in action.

Safety

Verified by Safety

Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.

Learn more