Summary
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 <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\/>])/i
The 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:
<div>
<script
<span src="/evil.js">
Output:
<div>
<script
<span src="/evil.js">
A browser parses that as <script src="/evil.js"> with a junk <span attribute, and the script runs. <iframe with <span onload="..."> works the same way and does not need a later </script> 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.
Impact
Untrusted input reaches a shell command, allowing arbitrary commands to run on the host. Typical impact: code execution in the application's environment.
GHSA-97JJ-33GV-5XF9 has a CVSS score of 6.1 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (2.10.2); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
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 <div>, <scripts> and <span class="a"> untouched. The existing unit test only covers tag names followed by another character, so a case for a bare tag name should be added.
Frequently Asked Questions
- What is GHSA-97JJ-33GV-5XF9? GHSA-97JJ-33GV-5XF9 is a medium-severity OS command injection vulnerability in league/commonmark (composer), affecting versions >= 1.3.0, <= 2.10.1. It is fixed in 2.10.2. Untrusted input reaches a shell command, allowing arbitrary commands to run on the host.
- How severe is GHSA-97JJ-33GV-5XF9? GHSA-97JJ-33GV-5XF9 has a CVSS score of 6.1 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of league/commonmark are affected by GHSA-97JJ-33GV-5XF9? league/commonmark (composer) versions >= 1.3.0, <= 2.10.1 is affected.
- Is there a fix for GHSA-97JJ-33GV-5XF9? Yes. GHSA-97JJ-33GV-5XF9 is fixed in 2.10.2. Upgrade to this version or later.
- Is GHSA-97JJ-33GV-5XF9 exploitable, and should I be worried? Whether GHSA-97JJ-33GV-5XF9 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-97JJ-33GV-5XF9 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-97JJ-33GV-5XF9? Upgrade
league/commonmarkto 2.10.2 or later.