CVE-2025-65106
Python vulnerability analysis and mitigation

Overview

A template injection vulnerability (CVE-2025-65106) was discovered in LangChain's prompt template system that allows attackers to access Python object internals through template syntax. The vulnerability affects applications using ChatPromptTemplate and related prompt template classes that accept untrusted template strings. The issue was disclosed on November 19, 2025, affecting langchain-core package versions <1.0.6,>=1.0.0 and <=0.3.79, with patches available in versions 1.0.7 and 0.3.80 (GitHub Advisory).

Technical details

The vulnerability exists in three template formats: F-string, Mustache, and Jinja2. The root cause in F-string templates stemmed from using Python's string.Formatter().parse() without proper validation, allowing attribute access and indexing expressions. While method calls with () were not supported, the templates allowed attribute access (.) and indexing ([]) syntax, which could be exploited. For Mustache templates, the issue arose from using getattr() as a fallback for attribute access. Jinja2 templates' default SandboxedEnvironment allowed access to non-dunder attributes and methods. The vulnerability has a CVSS score of 8.3 (High) with a vector string of CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N (GitHub Advisory).

Impact

Attackers who can control template strings can access Python object attributes and internal properties via attribute traversal, extract sensitive information from object internals (e.g., class, globals), and potentially escalate to more severe attacks depending on the objects passed to templates. The impact is particularly significant when using MessagesPlaceholder with chat message objects, as attackers can traverse through object attributes and dictionary lookups to reach sensitive data such as environment variables (GitHub Advisory).

Mitigation and workarounds

The fixes include strict validation for F-string templates to enforce valid Python identifiers and reject attribute access syntax, defensive hardening for Mustache templates to only allow traversal into dict, list, and tuple types, and restricted Jinja2 template capabilities through a _RestrictedSandboxedEnvironment that blocks all attribute/method access. Users should update to patched versions (1.0.7 or 0.3.80), audit code for untrusted template sources, and consider using direct message objects instead of templates where possible. For applications requiring templates with untrusted input, it's recommended to use f-string or mustache templates with the new restrictions instead of Jinja2 (GitHub Advisory).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-65106HIGH8.3
  • PythonPython
  • open-webui
NoYesNov 21, 2025
GHSA-m449-cwjh-6pw7MEDIUM6.6
  • PythonPython
  • pypdf
NoYesNov 24, 2025
CVE-2025-62609MEDIUM5.5
  • PythonPython
  • mlx
NoYesNov 21, 2025
CVE-2025-62608MEDIUM5.5
  • PythonPython
  • mlx
NoYesNov 21, 2025
GHSA-j4gv-6x9v-v23gLOW1.3
  • PythonPython
  • omero-web
NoYesNov 24, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management