CVE-2026-30838: League/commonmark CommonMark Has DisallowedRawHtml Extension Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-4v6x-c7xx-hw9f
CWE-79
Published
Advisory Summary

CVE-2026-30838 is a MODERATE commonmark has disallowedrawhtml extension bypass vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting League/commonmark libraries in the Packagist ecosystem. The issue involves commonmark has disallowedrawhtml extension bypass via whitespace in html tag names. Remediation is available by upgrading affected packages to version 2.8.1.

CVE-2026-30838 at a Glance

CVE Identifier CVE-2026-30838
GHSA Identifier GHSA-4v6x-c7xx-hw9f
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product League/commonmark
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2026-30838

To remediate this vulnerability, upgrade all affected League/commonmark dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

league/commonmark fixed: 2.8.1
Upgrade league/commonmark to 2.8.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for league/commonmark

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-30838, inspect your project dependencies for League/commonmark:

inspect dependencies for league/commonmark

Analyze the terminal output to locate any version of League/commonmark in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.8.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In League/commonmark, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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 `html_input` 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](https://commonmark.thephpleague.com/2.x/security/#additional-filtering))

CVE-2026-30838 Affected League/commonmark Versions

1 component(s)
Fixed Versions:
2.8.1
Product / Package Ecosystem Affected Versions Fixed Version
league/commonmark
Packagist
≥ 2.0.0
< 2.8.1
2.8.1

References

Frequently Asked Questions

What is CVE-2026-30838?
CVE-2026-30838 is a security vulnerability in League/commonmark involving CommonMark has DisallowedRawHtml extension bypass via whitespace in HTML tag names under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which League/commonmark versions are affected?
Affected versions include releases prior to 2.8.1 across affected packages: league/commonmark.
What version fixes CVE-2026-30838?
Upgrading to 2.8.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is league/commonmark affected?
Yes, league/commonmark is affected in releases prior to 2.8.1. Upgrade your dependency to 2.8.1 or later.
What CWE is associated with CVE-2026-30838?
CVE-2026-30838 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Packagist dependencies for CVE-2026-30838?
Run the dependency tree command: 'inspect dependencies for league/commonmark'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4v6x-c7xx-hw9f",
  "modified" : "2026-03-20T21:26:30Z",
  "published" : "2026-03-06T23:27:03Z",
  "aliases" : [ "CVE-2026-30838" ],
  "summary" : "CommonMark has DisallowedRawHtml extension bypass via whitespace in HTML tag names",
  "details" : "### Impact\n\nThe `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.\n\nAll 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.\n\n### Patches\n\nFixed 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.\n\n### Workarounds\n\n- Set the `html_input` configuration option to `'escape'` or `'strip'` to disable all raw HTML, though this is a broader restriction than the `DisallowedRawHtml` extension provides.\n- Pass the rendered HTML through a dedicated HTML sanitizer before serving it to users ([always recommended](https://commonmark.thephpleague.com/2.x/security/#additional-filtering))",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:L/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "league/commonmark"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.8.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.8.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/thephpleague/commonmark/security/advisories/GHSA-4v6x-c7xx-hw9f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-30838"
  }, {
    "type" : "WEB",
    "url" : "https://commonmark.thephpleague.com/extensions/disallowed-raw-html"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/thephpleague/commonmark"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-06T23:27:03Z",
    "nvd_published_at" : "2026-03-07T16:15:56Z"
  }
}