GHSA-97jj-33gv-5xf9: league/commonmark: DisallowedRawHtml bypassed when a disallowed tag name ends the raw-HTML literal
Summary The DisallowedRawHtml extension does not escape a disallowed tag when the tag name is the last thing in the raw HTML. A Markdown line containing just with a junk works the same way and does not need a later in the page. Control: is correctly escaped to <script src="/evil.js"</script. Affected versions 1.3.0 (when the extension was added) through the current release. The , and untouched.
Published Sep 30, 2026
Affected packages
league/commonmark
- Ecosystem
- Composer (PHP)
- Affected
- >= 1.3.0, <= 2.10.1
- Fixed in
- 2.10.2
- Check
composer show league/commonmark
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
The DisallowedRawHtml extension does not escape a disallowed tag when the tag name is the last thing in the raw HTML. A Markdown line containing just <script is emitted unchanged, and the next block can supply its attributes. With the shipped GFM defaults this allows stored XSS by anyone who can post Markdown.
Details
DisallowedRawHtmlRenderer escapes tags with this regex:
/<(\/?(?:title|textarea|style|xmp|iframe|noembed|noframes|script|plaintext)[\s\/>])/iThe trailing character class requires one character after the tag name. The block parser does not: RegexHelper::PARTIAL_HTMLBLOCKOPEN accepts end of line after a tag name, so <script alone opens an HTML block. Because a rendered HtmlBlock has no trailing newline, the regex has nothing to match and the < passes through.
In the browser the newline is still present, so the tag name terminates there and whatever follows becomes attributes.
This is the same filter that GHSA-4v6x-c7xx-hw9f fixed in 2.8.1. That fix widened the character class but still requires one character, so this case was not covered.
Reproduction
Render this with GithubFlavoredMarkdownConverter and default settings:
<script
Output:
<script
A browser parses that as <script src="/evil.js"> with a junk ` works the same way and does not need a later ` in the page.
Control: <script src="/evil.js"></script> is correctly escaped to <script src="/evil.js"></script>.
Affected versions
1.3.0 (when the extension was added) through the current release. The </style and mid-line forms are only affected as continuation lines inside an already-open HTML block.
Preconditions
html_inputisallow(the default)- The
DisallowedRawHtmlextension is active, which the GFM extension enables automatically - Untrusted users can post Markdown
Setting html_input to escape or strip fully mitigates this.
Suggested fix
Allow end of string after the tag name:
$regex = \sprintf('/<(\/?(?:%s))([\s\/>]|$)/i', \implode('|', \array_map('preg_quote', $tags)));
return \preg_replace($regex, '<$1$2', $rendered);This escapes every bypass shape above and leaves `, and ` untouched. The existing unit test only covers tag names followed by another character, so a case for a bare tag name should be added.
Credited to 4n86rakam1.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Composer (PHP) vulnerabilities
All Composer (PHP) entriesGHSA-3q6v-r5mr-hxv8
league/commonmark: Quadratic-time denial of service in the GitHub Flavored Markdown Table extension block-start scan
high7.5Sep 30, 2026GHSA-8rr7-cvq3-gmfh
league/commonmark: Denial of service via distinctly-named attributes in the Attributes extension
high7.5Sep 1, 2026GHSA-f8fg-pg57-v4j8
league/commonmark XSS: `on*` event-handler filter in `AttributesExtension` bypassed with a U+000C form feed
high7.2Sep 1, 2026GHSA-j8pm-gj4c-rq4x
league/commonmark: Denial of service via crafted code fences, reference links, and emphasis delimiters
high7.5Sep 1, 2026GHSA-jjv6-8j6v-6j52
league/commonmark: Denial of service in the SmartPunct and Attributes extensions
high7.5Sep 1, 2026CVE-2026-71478
league/commonmark: AttributesExtension href/src unsafe-link filter bypass via embedded control bytes
medium6.1Aug 6, 2026
