A Leader in the 2026 Gartner® Magic Quadrant™ for Endpoint Protection. Six years running.Six years. Gartner® Magic Quadrant™ Leader.Find Out Why
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2025-65106

CVE-2025-65106: LangChain Template Injection Vulnerability

CVE-2025-65106 is a template injection vulnerability in LangChain that allows attackers to access Python object internals. This article covers the technical details, affected versions, security impact, and mitigation.

Updated: May 19, 2026

CVE-2025-65106 Overview

CVE-2025-65106 is a template injection vulnerability in LangChain, a widely used framework for building agents and Large Language Model (LLM) powered applications. The flaw resides in the prompt template system and allows attackers to access Python object internals through template syntax. Applications that accept untrusted template strings, not just template variables, in ChatPromptTemplate and related prompt template classes are exposed. The issue affects versions 0.3.79 and prior, plus versions 1.0.0 through 1.0.6. Maintainers have addressed the flaw in versions 0.3.80 and 1.0.7. The weakness is classified as [CWE-1336] (Improper Neutralization of Special Elements Used in a Template Engine).

Critical Impact

Attackers supplying untrusted template strings can traverse arbitrary Python object attributes, leading to information disclosure and potential code execution paths within the host application.

Affected Products

  • LangChain langchain-core versions 0.3.79 and earlier (0.3.x branch)
  • LangChain langchain-core versions 1.0.0 through 1.0.6
  • Applications using ChatPromptTemplate and related prompt template classes with untrusted template strings

Discovery Timeline

  • 2025-11-21 - CVE-2025-65106 published to NVD
  • 2026-04-15 - Last updated in NVD database

Technical Details for CVE-2025-65106

Vulnerability Analysis

The vulnerability resides in libs/core/langchain_core/utils/mustache.py, the module that resolves variable references inside LangChain prompt templates. When resolving a dotted path such as {{ user.profile.name }}, the resolver walked into the current scope by first attempting dictionary subscripting, then falling back to getattr, and finally to list indexing. The fallback to getattr against any Python object meant template strings could traverse into arbitrary object attributes. An attacker who controls the template string, rather than only the variable values passed into it, can pivot through Python internals such as __class__, __mro__, __globals__, and __builtins__ to reach sensitive data or callable references inside the application process.

Root Cause

The root cause is unrestricted attribute traversal in the mustache-style scope resolver. The resolver treated any object as a valid traversal target and used getattr without an allowlist. This violates the template engine principle that user-controlled templates must not expose host language internals [CWE-1336].

Attack Vector

Exploitation requires the application to accept attacker-controlled template strings and render them through a LangChain prompt template. This is common in agent frameworks that allow tools, plugins, or end users to define prompt scaffolding dynamically. The attack is network-reachable, requires no authentication, and no user interaction. Successful exploitation primarily impacts confidentiality through disclosure of in-process Python objects and may extend to further abuse depending on what objects are reachable from the template scope.

python
# Security patch in libs/core/langchain_core/utils/mustache.py
# Before: getattr fallback allowed traversal into arbitrary Python objects.
# After: only dict, list, and tuple traversal is permitted.

if resolved_scope in (0, False):
    return resolved_scope
# Move into the scope
if isinstance(resolved_scope, dict):
    try:
        resolved_scope = resolved_scope[child]
    except (KeyError, TypeError):
        # Key not found - will be caught by outer try-except
        msg = f"Key {child!r} not found in dict"
        raise KeyError(msg) from None
elif isinstance(resolved_scope, (list, tuple)):
    try:
        resolved_scope = resolved_scope[int(child)]
    except (ValueError, IndexError, TypeError):
        # Invalid index - will be caught by outer try-except
        msg = f"Invalid index {child!r} for list/tuple"
        raise IndexError(msg) from None
else:
    # Reject everything else for security
    # This prevents traversing into arbitrary Python objects
    msg = (
        f"Cannot traverse into {type(resolved_scope).__name__}. "
    )
# Source: https://github.com/langchain-ai/langchain/commit/c4b6ba254e1a49ed91f2e268e6484011c540542a

Detection Methods for CVE-2025-65106

Indicators of Compromise

  • Prompt template strings containing dunder attribute references such as __class__, __mro__, __subclasses__, __globals__, or __builtins__.
  • Unexpected stack traces from langchain_core.utils.mustache referencing attribute lookups on non-dict objects.
  • Application logs showing rendered prompts that contain serialized Python type names or module paths.

Detection Strategies

  • Inventory all call sites where template strings, not just template variables, originate from untrusted sources such as users, plugins, tool descriptions, or retrieval results.
  • Statically scan repositories for ChatPromptTemplate.from_template, PromptTemplate.from_template, and related constructors that receive non-literal arguments.
  • Inspect dependency manifests (requirements.txt, pyproject.toml, poetry.lock) for langchain-core versions at or below 0.3.79 and between 1.0.0 and 1.0.6.

Monitoring Recommendations

  • Log raw template strings before rendering and alert on the presence of mustache or f-string syntax pointing to dunder attributes.
  • Monitor outbound LLM payloads for leaked internal class names, file paths, or environment variable values that suggest object traversal.
  • Track exceptions raised from mustache.py to identify reconnaissance attempts that probe attribute paths.

How to Mitigate CVE-2025-65106

Immediate Actions Required

  • Upgrade langchain-core to version 0.3.80 for the 0.3.x branch or 1.0.7 for the 1.0.x branch.
  • Audit application code to ensure template strings are never sourced from untrusted input; pass user content only as template variables.
  • Review agent tools, plugins, and retrieval-augmented generation pipelines for any path that concatenates untrusted data into a prompt template definition.

Patch Information

LangChain maintainers shipped the fix in commits c4b6ba2 and fa7789d. The fix removes the getattr fallback in the scope resolver and restricts traversal to dict, list, and tuple types. Details are published in GitHub Security Advisory GHSA-6qv9-48xg-fc7f.

Workarounds

  • Treat all template strings as code; load them only from trusted, version-controlled sources.
  • Validate and sanitize any dynamic template construction to reject mustache or f-string expressions containing . traversal of dunder attributes.
  • Run LangChain workloads under least-privilege Python environments with sensitive secrets isolated from the interpreter that renders prompts.
bash
# Upgrade to a patched release
pip install --upgrade "langchain-core>=1.0.7"

# Or, for the 0.3.x branch
pip install --upgrade "langchain-core>=0.3.80,<1.0.0"

# Verify installed version
python -c "import langchain_core; print(langchain_core.__version__)"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechLangchain

  • SeverityHIGH

  • CVSS Score8.3

  • EPSS Probability0.05%

  • Known ExploitedNo
  • CVSS Vector
  • 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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • CWE References
  • CWE-1336
  • Technical References
  • GitHub LangChain Commit Update

  • GitHub LangChain Commit Change

  • GitHub Security Advisory GHSA-6qv9-48xg-fc7f
  • Related CVEs
  • CVE-2026-30617: LangChain-ChatChat 0.3.1 RCE Vulnerability

  • CVE-2026-40087: LangChain RCE Vulnerability

  • CVE-2025-46059: LangChain GmailToolkit RCE Vulnerability

  • CVE-2024-46946: Langchain-experimental RCE Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English