Twig Extras CVE-2026-46637
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSupply HTML entity-encoded payload in user input
-
DeliveryContent stored and later passed to html_to_markdown or markdown_to_html filter
-
Exploitleague/html-to-markdown decodes entities or filter emits raw HTML
-
ExecutionTwig autoescaper suppresses re-encoding due to is_safe=['all']
-
PersistUnescaped output rendered in browser JS/CSS/HTML context
-
ImpactXSS payload executes
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding for downstream
|
| Exploitation Conditions | Exploitation requires three concurrent conditions: (1) attacker-controlled input must reach one of the three affected filters - html_to_markdown, markdown_to_html, or inline_css - in a Twig template; (2) the filter's output must be interpolated into a non-HTML escaping context (a JS string literal, a CSS value, or a URL parameter) for markdown_to_html and inline_css, or any HTML-rendering context for html_to_markdown given the entity-decoding gadget; and (3) the application must be running twig/markdown-extra or twig/cssinliner-extra below version 3.26.0. Exploitation is limited by the fact that many deployments using these filters operate only in HTML body contexts, where markdown_to_html and inline_css are genuinely safe; only the html_to_markdown vector is exploitable in a pure HTML body context via the entity-decoding path. Authentication requirements are not confirmed from available data, as no CVSS vector is provided - exploitability depends entirely on whether the attacker can supply input to the affected filter pipeline, which varies by application design. |
| Impact | No CVSS vector or score is available for this CVE, so quantitative risk scoring cannot be applied. No EPSS probability is available. The vulnerability is not listed in the CISA KEV catalog and no public exploit code has been identified at time of analysis. Despite the absence of CVSS data, the qualitative risk profile is meaningful: exploitability requires attacker-controlled content to pass through an affected filter and then be interpolated into a JS, CSS, or URL context in a Twig template - a combination that is plausible in content-management and email-rendering applications built on Symfony/Twig. The html_to_markdown vector is especially noteworthy because it creates a persistent XSS path that bypasses developer intent (no |raw was written), making it harder to audit by code review alone. The fix is available as version 3.26.0 with no known workaround complexity, which lowers the remediation cost and argues for prompt patching over detective controls. Overall: moderate-to-high priority for applications that render user-supplied content through these filters; low priority for applications where filter inputs are fully trusted. |
| Exploit ScenarioDerived | An attacker submits content containing a crafted HTML code element such as '<code><img src=x onerror=alert(document.cookie)></code>' to a web application that stores and later renders user content through Twig's html_to_markdown filter. When the template interpolates the filter output into a page - even inside what appears to be an HTML body context - the league/html-to-markdown library decodes the entities into a live backtick-wrapped image tag, which the misconfigured autoescaper emits verbatim, executing the payload in the victim's browser. A second path exists for markdown_to_html or inline_css if a developer embeds their output inside an inline script block, where the unescaped HTML characters break out of the JavaScript string context. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – May 21, 2026
Cross-site scripting in twig/markdown-extra and twig/cssinliner-extra arises from three filters - html_to_markdown, markdown_to_html, and inline_css - being incorrectly registered with is_safe => ['all'], which instructs Twig's autoescaper to suppress output encoding in every context including JS, CSS, and URL. When attacker-controlled content flows through these filters and the result is interpolated into a non-HTML context such as an inline script block, the autoescaper emits the raw output verbatim, enabling XSS without the developer ever using the explicit |raw bypass. Notably, html_to_markdown has an additional entity-decoding gadget via league/html-to-markdown that converts encoded HTML entities back to live markup during code span generation, creating a secondary injection path even in HTML contexts. No public exploit identified at time of analysis and no CISA KEV listing.
RemediationAI
Vendor-released patch: 3.26.0 for both twig/markdown-extra and twig/cssinliner-extra. Upgrade both packages using Composer: run 'composer update twig/markdown-extra twig/cssinliner-extra' and verify the installed version reaches 3.26.0 or higher. The fix retracts the is_safe => ['all'] claim: html_to_markdown now declares no safe context (its output is re-escaped for the surrounding context), and markdown_to_html and inline_css are narrowed to is_safe => ['html']. If an immediate upgrade is not feasible, the most targeted compensating control is to audit every Twig template that uses these three filters and confirm the filter output is only ever interpolated inside an HTML body context, never inside a script block, style attribute, or URL parameter - manually adding |escape('js'), |escape('css'), or |url_encode as appropriate for non-HTML contexts. Note that this manual audit is error-prone and does not address the html_to_markdown entity-decoding vector; upgrading to 3.26.0 is strongly preferred. The full advisory is at https://github.com/twigphp/Twig/security/advisories/GHSA-jv8m-2544-3pg3.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 2 packages in composer
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Twig's autoescaper assigns each registered filter a set of safe output contexts via the is_safe metadata flag, allowing it to skip re-encoding filter output in those contexts. CWE-116 (Improper Encoding or Escaping of Output) is the root cause: the three affected filters overclaim their safety guarantee by declaring is_safe => ['all'] rather than the narrower is_safe => ['html'] that their actual output (HTML markup or Markdown text) warrants. The affected Composer packages are pkg:composer/twig/markdown-extra and pkg:composer/twig/cssinliner-extra, both below version 3.26.0. The html_to_markdown filter introduces a compounding issue through its dependency league/html-to-markdown, which decodes HTML entities when generating code spans and fenced code blocks - meaning HTML entity-encoded payloads survive the HTML-to-Markdown conversion as live markup rather than inert text. The markdown_to_html and inline_css filters emit HTML, which is safe within an HTML escaping context but becomes unescaped content when Twig interpolates it into a JavaScript string literal, CSS property value, or URL parameter.
Know when the next one hits your stack
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
Primary rating from Vendor (https://github.com/twigphp/Twig) · only source for this CVE.
CVSS VectorVendor: https://github.com/twigphp/Twig
Lifecycle Timeline
1DescriptionCVE.org
Description
Several filters in the twig/* extras packages are registered with is_safe => ['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:
html_to_markdown(twig/markdown-extra) emits plain Markdown text.league/html-to-markdowndecodes 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.markdown_to_html(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).inline_css(twig/cssinliner-extra) emits HTML with inlined styles. Same constraint asmarkdown_to_html.
In all three cases, is_safe => ['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
html_to_markdownno longer claims to be safe in any escaping context; its plain-text output is now autoescaped for the surrounding context.markdown_to_htmlandinline_cssare now declaredis_safe => ['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 html_to_markdown and markdown_to_html in twig/markdown-extra, and Christophe Coevoet for extending the audit to inline_css in twig/cssinliner-extra.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.
GHSA-jv8m-2544-3pg3
NVD
CVE.org
EPSS
Exploit-DB