Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
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-2022-39261

CVE-2022-39261: Symfony Twig Path Traversal Vulnerability

CVE-2022-39261 is a path traversal vulnerability in Symfony Twig that allows attackers to read arbitrary files outside template directories using namespace bypasses. This article covers technical details, affected versions, and patches.

Published: February 18, 2026

CVE-2022-39261 Overview

CVE-2022-39261 is a path traversal vulnerability affecting Twig, a popular template language for PHP. The vulnerability exists in the filesystem loader component when template names are derived from user input. An attacker can exploit the source or include statements to read arbitrary files from outside the designated templates directory by using a specially crafted namespace path containing directory traversal sequences like @somewhere/../some.file. When such a malformed namespace is used, the validation mechanism is bypassed, allowing unauthorized file access.

Critical Impact

Attackers can read arbitrary sensitive files from the server filesystem, potentially exposing configuration files, credentials, source code, and other confidential data through template injection attacks.

Affected Products

  • Symfony Twig versions 1.x prior to 1.44.7
  • Symfony Twig versions 2.x prior to 2.15.3
  • Symfony Twig versions 3.x prior to 3.4.3
  • Drupal Core (dependent on vulnerable Twig versions)
  • Fedora 35, 36, and 37
  • Debian Linux 10.0 and 11.0

Discovery Timeline

  • 2022-09-28 - CVE-2022-39261 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-39261

Vulnerability Analysis

This path traversal vulnerability (CWE-22) occurs in Twig's filesystem loader component. The core issue lies in the order of operations when validating template names that contain namespace prefixes. When a template name using a namespace format (e.g., @namespace/path) is processed, the validation function was being called on the full name including the namespace prefix, rather than on the resolved shortname after namespace parsing.

This ordering flaw means that an attacker can craft a template path using a namespace prefix followed by directory traversal sequences (../) that bypass the security validation entirely. The validation checks the namespace-prefixed string, which appears valid, but the actual file resolution uses the shortname which can traverse outside the intended template directory.

The vulnerability enables unauthorized reading of arbitrary files on the filesystem where the web application has read permissions. This could expose sensitive configuration files, database credentials, application source code, environment variables, and other confidential data stored on the server.

Root Cause

The root cause is improper sequencing of input validation in the FilesystemLoader.php file. The original code called validateName($name) before parsing the namespace and extracting the shortname. This meant validation occurred against the raw user-supplied input containing the namespace prefix, rather than against the actual filesystem path that would be loaded. The namespace prefix effectively "masked" the traversal sequences from the validation routine.

Attack Vector

The attack can be executed remotely over the network without requiring authentication. An attacker needs to find an application endpoint where user-controlled input is used as a template name with the source or include Twig statements. By supplying a malicious template path like @somewhere/../../../etc/passwd, the attacker can read files outside the configured templates directory. The attack requires no user interaction and can be automated.

php
// Original vulnerable code flow in FilesystemLoader.php
// Validation was performed BEFORE namespace parsing
$this->validateName($name);  // Validates "@namespace/../secret.file" - passes!
list($namespace, $shortname) = $this->parseName($name);
// shortname now contains "../secret.file" - traversal succeeds

// Fixed code flow - validation occurs AFTER parsing
list($namespace, $shortname) = $this->parseName($name);
$this->validateName($shortname);  // Now validates "../secret.file" - correctly rejected

Source: GitHub Commit

Detection Methods for CVE-2022-39261

Indicators of Compromise

  • Web server access logs containing template paths with @ namespace prefixes followed by ../ sequences
  • Error logs showing attempts to access files outside the templates directory
  • Unusual file read operations targeting sensitive system files like /etc/passwd or application configuration files
  • HTTP requests with encoded directory traversal patterns such as %2e%2e%2f or ..%2f in template-related parameters

Detection Strategies

  • Implement web application firewall (WAF) rules to detect and block requests containing directory traversal patterns (../, ..\, encoded variants) in URL parameters and POST data
  • Deploy application-level logging to monitor template loading operations and flag any attempts to load templates with namespace prefixes containing path separators
  • Use file integrity monitoring (FIM) on sensitive configuration files to detect unauthorized read access attempts
  • Configure SentinelOne Singularity to monitor PHP process activity for suspicious file read operations outside expected directories

Monitoring Recommendations

  • Enable verbose logging in Twig/Symfony applications to capture template loading errors and access attempts
  • Monitor for anomalous spikes in file read operations from web server processes
  • Set up alerts for any access to sensitive files from web application contexts
  • Review application logs regularly for patterns indicating exploitation attempts against template rendering endpoints

How to Mitigate CVE-2022-39261

Immediate Actions Required

  • Upgrade Twig immediately to version 1.44.7, 2.15.3, or 3.4.3 depending on your installed major version
  • For Drupal installations, apply the security update referenced in Drupal Security Advisory SA-CORE-2022-016
  • Audit application code to identify any locations where user input is used in template names for source or include statements
  • Implement input validation at the application layer to reject any template names containing ../ sequences before passing to Twig

Patch Information

The vulnerability is fixed in Twig versions 1.44.7, 2.15.3, and 3.4.3. The fix reorders the validation logic to ensure validateName() is called on the parsed shortname after namespace extraction, rather than on the raw input. The security patch is available via the GitHub commit 35f3035c5deb0041da7b84daf02dea074ddc7a0b. Additional vendor advisories are available from Debian Security Advisory DSA-5248 and through Fedora package announcements.

Workarounds

  • There are no known workarounds aside from upgrading to the patched versions according to the official security advisory
  • As a defense-in-depth measure, avoid passing user-controlled input directly to template loading functions
  • Implement strict allowlisting of permitted template names at the application level if user input must influence template selection
  • Use application-level path validation to strip or reject any input containing directory traversal sequences before Twig processing
bash
# Upgrade Twig via Composer to the latest patched version
composer require twig/twig:^3.4.3

# For Twig 2.x installations
composer require twig/twig:^2.15.3

# For legacy Twig 1.x installations
composer require twig/twig:^1.44.7

# Verify installed version after upgrade
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
  • TypePath Traversal

  • Vendor/TechTwig

  • SeverityHIGH

  • CVSS Score7.5

  • EPSS Probability2.19%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • CWE References
  • CWE-22
  • Technical References
  • GitHub Security Advisory

  • Debian LTS Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Debian Security Advisory
  • Vendor Resources
  • GitHub Commit Change

  • Drupal Security Advisory
  • Related CVEs
  • CVE-2024-51754: Twig Template Engine RCE Vulnerability

  • CVE-2025-24374: Twig PHP Template XSS 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