CVE-2026-46637: HTML-output filters in twig/* extras incorrectly declared `is_safe => ['all']`
Description
Several filters in the twig/ extras packages are registered with issafe => ['all'], which tells Twig's autoescaper to treat their output as safe in every context (html, js, css, url, ...). The output of these filters is plain text or HTML markup, neither of which is safe in every escaping context.
Affected filters:
- htmltomarkdown (twig/markdown-extra) emits plain Markdown text. league/html-to-markdown decodes HTML entities when producing code spans and fenced blocks, so an attacker-controlled <code><img src=x onerror=alert(1)></code> becomes <img src=x onerror=alert(1)> , which renders live when interpolated into an HTML page. - markdowntohtml (twig/markdown-extra) emits HTML. Safe in an HTML context but not in JS, CSS or URL contexts (e.g. when interpolated into an inline <script> block). - inlinecss (twig/cssinliner-extra) emits HTML with inlined styles. Same constraint as markdowntohtml.
In all three cases, issafe => ['all'] causes the autoescaper to emit the output verbatim in any context, even when the developer never wrote |raw. In a context such as a JS string or a URL parameter, this produces unescaped HTML and is exploitable as XSS.
Resolution
- htmltomarkdown no longer claims to be safe in any escaping context; its plain-text output is now autoescaped for the surrounding context. - markdowntohtml and inlinecss are now declared issafe => ['html'], asserting only what they actually guarantee.
Credits
Twig would like to thank Claude Mythos Preview (via Project Glasswing) for reporting the issue and providing the fix for htmltomarkdown and markdowntohtml in twig/markdown-extra, and Christophe Coevoet for extending the audit to inlinecss in twig/cssinliner-extra.
Other sources
HTML-output filters in twig/ extras incorrectly declared issafe => ['all']
— Packagist
Twig is a template language for PHP. Prior to 3.26.0, several filters in twig/markdown-extra and twig/cssinliner-extra are registered with issafe => [all], causing Twig to treat plain text or HTML output as safe in HTML, JavaScript, CSS, URL, and other contexts where the output is not properly escaped. This issue is fixed in version 3.26.0.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/twig/cssinliner-extrato a version that resolves this vulnerability.Fixed in 3.26.0 - Upgrade
Upgrade
composer/twig/markdown-extrato a version that resolves this vulnerability.Fixed in 3.26.0 - Upgrade
Upgrade
debian/php-twigto a version that resolves this vulnerability.Fixed in 3.5.1-1+deb12u3Fixed in 3.27.0-0+deb13u1Fixed in 3.30.0-1 - Upgrade
Upgrade
Twig extrasto a version that resolves this vulnerability.Fixed in 3.26.0
Event History
Frequently Asked Questions
What is the severity of CVE-2026-46637?
CVE-2026-46637 has a risk rating of 52, indicating a moderate severity level.
What type of vulnerability is CVE-2026-46637?
CVE-2026-46637 is an XSS (Cross-Site Scripting) vulnerability due to improper handling of filters in Twig's extras packages.
How do I fix CVE-2026-46637?
To mitigate CVE-2026-46637, review and update the Twig extras packages to secure versions that do not register filters with 'is_safe' set to ['all'].
Which packages are affected by CVE-2026-46637?
CVE-2026-46637 affects the composer/twig/cssinliner-extra and composer/twig/markdown-extra packages.
When was CVE-2026-46637 published?
CVE-2026-46637 was published on May 21, 2026.