GitHub Advisoryadvisory · Packagist
GHSA-2g2g-8p8h-fgwm Twig: XSS in profiler HtmlDumper via unescaped template and profile names
LOW
Official page ↗
- Aliases
- CVE-2026-47730
- Ecosystem
- Packagist
- Packages
- twig/twig
- Severity
- Low
- Weaknesses
- CWE-79
- Reviewed
- 2026-06-05
Affected packages
• Packagist twig/twig: >= 3.0.0, < 3.26.0 → fixed in 3.26.0
Description
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└ %s', $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.
Related
Alias · CVE (1)
- CVE-2026-47730 Twig is a template language for PHP. vulnerability
Weakness · CWE (1)
- CWE-79 Improper Neutralization of Input During Web Page Generation weakness
References
- https://github.com/twigphp/Twig/security/advisories/GHSA-2g2g-8p8h-fgwm web
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-47730.yaml web
- https://github.com/twigphp/Twig package
- https://github.com/twigphp/Twig/releases/tag/v3.26.0 web
- https://symfony.com/cve-2026-47730 web