CVE-2026-30838: league/commonmark: DisallowedRawHtml extension bypass via whitespace in HTML tag names
Impact
The DisallowedRawHtml extension can be bypassed by inserting a newline, tab, or other ASCII whitespace character between a disallowed HTML tag name and the closing >. For example, <script\n> would pass through unfiltered and be rendered as a valid HTML tag by browsers. This is a cross-site scripting (XSS) vector for any application that relies on this extension to sanitize untrusted user input.
All applications using the DisallowedRawHtml extension to process untrusted markdown are affected. Applications that use a dedicated HTML sanitizer (such as HTML Purifier) on the rendered output are not affected.
Patches
Fixed in 2.8.1. The regex character class [ \/>] was changed to [\s\/>] to match all whitespace characters that browsers accept as valid tag name terminators.
Workarounds
- Set the htmlinput configuration option to 'escape' or 'strip' to disable all raw HTML, though this is a broader restriction than the DisallowedRawHtml extension provides. - Pass the rendered HTML through a dedicated HTML sanitizer before serving it to users (always recommended)
Resources
- CommonMark DisallowedRawHtml documentation - CWE-79: Improper Neutralization of Input During Web Page Generation - CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Other sources
league/commonmark is a PHP Markdown parser. Prior to version 2.8.1, the DisallowedRawHtml extension can be bypassed by inserting a newline, tab, or other ASCII whitespace character between a disallowed HTML tag name and the closing >. For example, <script\n> would pass through unfiltered and be rendered as a valid HTML tag by browsers. This is a cross-site scripting (XSS) vector for any application that relies on this extension to sanitize untrusted user input. All applications using the DisallowedRawHtml extension to process untrusted markdown are affected. Applications that use a dedicated HTML sanitizer (such as HTML Purifier) on the rendered output are not affected. This issue has been patched in version 2.8.1.
— MITRE
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2026-30838?
CVE-2026-30838 is considered a high-severity vulnerability due to its ability to bypass security measures.
How do I fix CVE-2026-30838?
To fix CVE-2026-30838, upgrade the league/commonmark package to version 2.8.1 or later.
What software is affected by CVE-2026-30838?
CVE-2026-30838 affects versions of the league/commonmark package up to and including 2.8.0.
What kind of attack does CVE-2026-30838 enable?
CVE-2026-30838 allows an attacker to inject disallowed raw HTML content into Markdown documents.
Is CVE-2026-30838 a client-side or server-side vulnerability?
CVE-2026-30838 is primarily a server-side vulnerability impacting how Markdown is processed before rendering.