CVE-2026-47730: Twig: XSS in profiler HtmlDumper via unescaped template and profile names
Description
Twig\Profiler\Dumper\HtmlDumper writes Profile::getTemplate() and Profile::getName() straight into its HTML output without escaping:
php 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.
Other sources
Twig is a template language for PHP. From 3.0.0 until 3.26.0, Twig\Profiler\Dumper\HtmlDumper writes Profile::getTemplate() and Profile::getName() into HTML output without escaping, allowing attacker-controlled template or profile names to inject arbitrary HTML when a browser renders the profiler dump. This issue is fixed in version 3.26.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/twig/twigto a version that resolves this vulnerability.Fixed in 3.26.0 - Upgrade
Upgrade
Twigto a version that resolves this vulnerability.Fixed in 3.26.0
Event History
Frequently Asked Questions
What is the severity of CVE-2026-47730?
CVE-2026-47730 has a risk rating of 33, indicating a moderate severity level.
How do I fix CVE-2026-47730?
To mitigate CVE-2026-47730, you should update Twig to the latest version that has addressed this vulnerability.
What type of vulnerability is CVE-2026-47730?
CVE-2026-47730 is classified as an XSS (Cross-Site Scripting) vulnerability.
Which software is affected by CVE-2026-47730?
CVE-2026-47730 affects the composer/twig/twig software library.
When was CVE-2026-47730 published?
CVE-2026-47730 was published on June 5, 2026.