Twig: XSS in profiler HtmlDumper via unescaped template and profile names
Description
Published to the GitHub Advisory Database
Jun 5, 2026
Reviewed
Jun 5, 2026
Last updated
Jun 5, 2026
Description
Twig\Profiler\Dumper\HtmlDumperwritesProfile::getTemplate()andProfile::getName()straight into its HTML output without escaping: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
HtmlDumpernow runs bothProfile::getTemplate()andProfile::getName()throughhtmlspecialchars()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.
References