The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
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-24374

CVE-2025-24374: Twig PHP Template XSS Vulnerability

CVE-2025-24374 is a cross-site scripting flaw in Twig PHP template language affecting the ?? operator's output escaping. This vulnerability allows attackers to inject malicious scripts. Learn about affected versions and fixes.

Updated: January 22, 2026

CVE-2025-24374 Overview

CVE-2025-24374 is a Cross-Site Scripting (XSS) vulnerability affecting Twig, a popular template language for PHP. The vulnerability exists due to missing output escaping when using the null-coalesce (??) operator. Specifically, the expression on the left side of the ?? operator was not being properly escaped, which could allow attackers to inject malicious scripts into rendered pages.

Critical Impact

Applications using Twig templates with the ?? operator may be vulnerable to XSS attacks if user-controlled data is passed through the left-hand expression, potentially leading to session hijacking, credential theft, or malicious content injection.

Affected Products

  • Twig versions prior to 3.19.0
  • PHP applications using vulnerable Twig template engine versions
  • Web applications leveraging Twig's null-coalesce operator with user-supplied input

Discovery Timeline

  • 2025-01-29 - CVE-2025-24374 published to NVD
  • 2025-01-29 - Last updated in NVD database

Technical Details for CVE-2025-24374

Vulnerability Analysis

This vulnerability is classified under CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component), commonly referred to as an Injection vulnerability. The flaw resides in Twig's handling of the null-coalesce binary operator (??), which is used to provide default values when a variable is null or undefined.

The issue occurs within the NullCoalesceBinary.php component, where the implementation failed to properly escape output for the left-hand expression of the ?? operator. While Twig typically applies auto-escaping to prevent XSS attacks, this specific code path bypassed the escaping mechanism, creating a potential injection point.

When a template contains an expression like {{ user_input ?? 'default' }}, the user_input variable should be HTML-escaped before rendering. However, due to this bug, malicious HTML or JavaScript in user_input could be rendered without sanitization, enabling XSS attacks against users viewing the affected pages.

Root Cause

The root cause lies in the NullCoalesceBinary class implementation within Twig's expression handling. The class implements OperatorEscapeInterface, which should ensure proper escaping of output. However, the left-hand operand of the null-coalesce operation was not being processed through the escape filter chain, allowing raw, unescaped content to pass through to the final rendered output.

Attack Vector

This vulnerability is exploitable over the network and requires user interaction (such as clicking a malicious link or visiting a compromised page). An attacker could craft input containing malicious JavaScript that, when processed through a Twig template using the ?? operator, would execute in the victim's browser context. The attack does not require authentication and could be leveraged for:

  • Session cookie theft
  • Keylogging and credential harvesting
  • Defacement or content manipulation
  • Redirection to malicious sites
text
# 3.19.0 (2025-XX-XX)

+ * Fix a security issue where escaping was missing when using `??`
 * Deprecate `Token::getType()`, use `Token::test()` instead
 * Add `Token::toEnglish()`
 * Add `ForElseNode`

Source: GitHub Commit - Twig Update

Detection Methods for CVE-2025-24374

Indicators of Compromise

  • Review web application logs for unusual URL parameters or POST data containing HTML tags or JavaScript code
  • Monitor for unexpected <script> tags or event handlers (e.g., onerror, onclick) in request parameters
  • Check for error messages indicating template rendering issues after XSS payloads are submitted
  • Audit user-generated content for suspicious JavaScript or HTML injection patterns

Detection Strategies

  • Implement Web Application Firewall (WAF) rules to detect common XSS payloads in request parameters
  • Use static code analysis tools to identify Twig templates utilizing the ?? operator with user-controlled variables
  • Deploy Content Security Policy (CSP) headers to mitigate successful XSS exploitation and alert on violations
  • Conduct regular dependency audits using tools like Composer's audit command to identify vulnerable Twig versions

Monitoring Recommendations

  • Enable CSP reporting to capture attempted XSS attacks and policy violations
  • Monitor application error logs for template rendering exceptions that may indicate exploitation attempts
  • Implement real-time alerting on WAF detections related to XSS patterns targeting PHP applications
  • Track outbound requests from client browsers that may indicate successful XSS exploitation (data exfiltration)

How to Mitigate CVE-2025-24374

Immediate Actions Required

  • Update Twig to version 3.19.0 or later immediately to address this vulnerability
  • Review all Twig templates using the ?? operator for potential exposure to user-controlled input
  • Implement input validation and sanitization for all user-supplied data processed by templates
  • Deploy or strengthen Content Security Policy headers to reduce XSS impact

Patch Information

The vulnerability has been fixed in Twig version 3.19.0. The security patch modifies the NullCoalesceBinary.php file to ensure proper output escaping for the left-hand expression of the null-coalesce operator. The fix can be reviewed in the GitHub Commit. Additional details are available in the GitHub Security Advisory GHSA-3xg3-cgvq-2xwr.

Workarounds

  • Manually escape variables before using them with the ?? operator: {{ variable|e ?? 'default' }}
  • Implement strict Content Security Policy headers to prevent inline script execution
  • Use input validation to reject or sanitize HTML/JavaScript content in user-supplied data before template processing
bash
# Update Twig using Composer
composer require "twig/twig:^3.19.0"

# Verify the installed version
composer show twig/twig | grep versions

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

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechTwig

  • SeverityMEDIUM

  • CVSS Score4.3

  • EPSS Probability0.14%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityLow
  • AvailabilityNone
  • CWE References
  • CWE-74
  • Technical References
  • GitHub Commit - Twig Update

  • GitHub Security Advisory GHSA-3xg3-cgvq-2xwr
  • Related CVEs
  • CVE-2024-51754: Twig Template Engine RCE Vulnerability

  • CVE-2022-39261: Symfony Twig Path Traversal Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now 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