CVE-2026-47730 — Twig: XSS in twig/twig — CVE Details
Twig: XSS in profiler HtmlDumper via unescaped template and profile names
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.30%). Schedule for your next planned update.
Does your project use an affected twig/twig version?
Paste your composer.lock to check it for CVE-2026-47730 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
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.
Advisory Timeline
- First published June 5, 2026 (174 days ago).
- Last revised September 10, 2026 — 96 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
composer require "twig/twig:^3.26.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: Packagist (1).
| Package | Fixed In |
|---|---|
| twig/twig Packagist · Affected: v3.0.0, v3.0.1, v3.0.2, v3.0.3 (+59 more) | 3.26.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-79Cross-site Scripting (XSS)MITRE
References
- https://github.com/twigphp/Twig/security/advisories/GHSA-2g2g-8p8h-fgwmWEB
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-47730.yamlWEB
- https://github.com/twigphp/TwigPACKAGE
- https://github.com/twigphp/Twig/releases/tag/v3.26.0WEB
- https://symfony.com/cve-2026-47730WEB
Frequently Asked Questions
- What is CVE-2026-47730?
- Twig: XSS in profiler HtmlDumper via unescaped template and profile names. This vulnerability has been assigned a severity rating of LOW.
- How do I check if my project is affected by CVE-2026-47730?
- CVE-2026-47730 affects twig/twig. It has a 0.3% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-47730 and 200,000+ other known vulnerabilities.
Severity & Exploitability
This is a below-median EPSS score — only 14.6% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-24425HIGH
Twig: Possible sandbox bypass when using a source policy
- CVE-2026-46639HIGH
Twig: Sandbox property and method bypass via object-destructuring assignment
- CVE-2026-47732HIGH
Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points
- CVE-2026-46634MEDIUM
Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name
- CVE-2026-48808MEDIUM
Twig: Sandbox property allowlist bypass via the `column` filter under `SourcePolicyInterface`
- CVE-2024-51755LOW
Twig has unguarded calls to `__isset()` and to array-accesses when the sandbox is enabled
- CVE-2026-48805LOW
Twig: Sandbox state regression in deprecated internal wrappers in `src/Resources/core.php`
- CVE-2026-46635LOW
Twig: Sandbox property allowlist bypass via the `column` filter (array_column on objects)