CVE-2026-46637: Twig: HTML-output filters in twig/* extras incorrectly declared `is_safe => ['all']`

Published May 21, 2026
·
Updated

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>&lt;img src=x onerror=alert(1)&gt;</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

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.

MITRE

Affected Software

3 affected componentsFixes available
composer/twig/cssinliner-extra<3.26.0
3.26.0
composer/twig/markdown-extra<3.26.0
3.26.0
Symfony Twig<3.26.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/twig/cssinliner-extra to a version that resolves this vulnerability.

    Fixed in 3.26.0
  2. Upgrade

    Upgrade composer/twig/markdown-extra to a version that resolves this vulnerability.

    Fixed in 3.26.0
  3. Upgrade

    Upgrade twig/markdown-extra to a version that resolves this vulnerability.

    Fixed in 3.26.0
  4. Upgrade

    Upgrade twig/cssinliner-extra to a version that resolves this vulnerability.

    Fixed in 3.26.0
  5. Configuration

    Remove/adjust the filter’s is_safe declaration so Twig autoescapes html_to_markdown plain-text output in the surrounding context (issue: plain-text output was emitted verbatim due to is_safe => ['all']).

    twig/markdown-extra (html_to_markdown filter) is_safe = no longer claims to be safe in any escaping context; plain-text output is autoescaped for the surrounding context
  6. Configuration

    Change markdown_to_html is_safe from ['all'] to ['html'] so its HTML output is only treated as safe for HTML context, not for JS/CSS/URL contexts.

    twig/markdown-extra (markdown_to_html filter) is_safe = ['html']
  7. Configuration

    Change inline_css is_safe from ['all'] to ['html'] so its inlined-HTML output is only treated as safe for HTML context, not for JS/CSS/URL contexts.

    twig/cssinliner-extra (inline_css filter) is_safe = ['html']

Event History

May 21, 2026
Advisory Published
via GitHub·09:27 PM
Data Sourced
via GitHub·09:27 PM
DescriptionWeaknessAffected Software
Jul 14, 2026
CVE Published
via MITRE·09:25 PM
Data Sourced
via MITRE·09:25 PM
DescriptionWeakness
Data Sourced
via NVD·10:16 PM
RemedyDescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-46637?

CVE-2026-46637 has a risk rating of 52, indicating a moderate severity level.

2

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.

3

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'].

4

Which packages are affected by CVE-2026-46637?

CVE-2026-46637 affects the composer/twig/cssinliner-extra and composer/twig/markdown-extra packages.

5

When was CVE-2026-46637 published?

CVE-2026-46637 was published on May 21, 2026.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203