GitHub Advisoryadvisory · Packagist

GHSA-2g2g-8p8h-fgwm Twig: XSS in profiler HtmlDumper via unescaped template and profile names

LOW Published 2026-06-05 Modified 2026-06-05 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)

Weakness · CWE (1)

  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness

References