league/commonmark: Denial of service via colliding heading slugs
A denial of service vulnerability exists in league/commonmark versions 2.0.0 through 2.8.x due to a quadratic algorithmic complexity in the UniqueSlugNormalizer::normalize() function. This function restarts its search for unique slug suffixes from 1 on every collision, causing O(K²) CPU cost for K colliding slugs. The issue affects processing of headings and footnotes when certain extensions are enabled, allowing an attacker to cause significant CPU consumption and service disruption without authentication. Workarounds include disabling slug uniqueness or affected extensions, but upgrading to a patched release is recommended.
AI Analysis
Technical Summary
The UniqueSlugNormalizer in league/commonmark (introduced in 2.0.0) attempts to ensure unique slugs by searching for unused numeric suffixes starting from 1 on each collision, resulting in quadratic time complexity (O(K²)) when many headings collapse to the same base slug. This can be trivially triggered by attacker-controlled Markdown containing many identical or empty headings, causing denial of service by excessive CPU usage. The vulnerability is triggered when HeadingPermalinkExtension, FootnoteExtension, or TableOfContentsExtension are used, as they normalize headings or footnotes with this slug normalizer. No authentication is required. Versions from 2.0.0 up to but not including 2.9.0 are affected. Workarounds include disabling slug uniqueness or the affected extensions, or limiting document size, but the recommended fix is upgrading to a patched version that removes the quadratic behavior while preserving functionality.
Potential Impact
An attacker can cause denial of service by submitting Markdown documents with many colliding headings or footnotes that cause the slug normalization process to consume excessive CPU resources. This leads to service unavailability or degraded performance. There is no impact on confidentiality or integrity. No authentication is required to trigger the vulnerability.
Mitigation Recommendations
A patch is available that removes the quadratic behavior while maintaining unique slug IDs and output correctness. Users should upgrade to a patched release at or beyond version 2.9.0. As temporary workarounds, integrators can disable slug uniqueness by setting slug_normalizer/unique to false, disable the HeadingPermalinkExtension and TableOfContentsExtension (which depends on it), and FootnoteExtension for untrusted Markdown, or limit document size and heading count upstream to avoid triggering the quadratic cost. These workarounds trade off functionality or correctness and are not recommended long-term.
league/commonmark: Denial of service via colliding heading slugs
Description
A denial of service vulnerability exists in league/commonmark versions 2.0.0 through 2.8.x due to a quadratic algorithmic complexity in the UniqueSlugNormalizer::normalize() function. This function restarts its search for unique slug suffixes from 1 on every collision, causing O(K²) CPU cost for K colliding slugs. The issue affects processing of headings and footnotes when certain extensions are enabled, allowing an attacker to cause significant CPU consumption and service disruption without authentication. Workarounds include disabling slug uniqueness or affected extensions, but upgrading to a patched release is recommended.
CVSS v3.1
Score 7.5high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The UniqueSlugNormalizer in league/commonmark (introduced in 2.0.0) attempts to ensure unique slugs by searching for unused numeric suffixes starting from 1 on each collision, resulting in quadratic time complexity (O(K²)) when many headings collapse to the same base slug. This can be trivially triggered by attacker-controlled Markdown containing many identical or empty headings, causing denial of service by excessive CPU usage. The vulnerability is triggered when HeadingPermalinkExtension, FootnoteExtension, or TableOfContentsExtension are used, as they normalize headings or footnotes with this slug normalizer. No authentication is required. Versions from 2.0.0 up to but not including 2.9.0 are affected. Workarounds include disabling slug uniqueness or the affected extensions, or limiting document size, but the recommended fix is upgrading to a patched version that removes the quadratic behavior while preserving functionality.
Potential Impact
An attacker can cause denial of service by submitting Markdown documents with many colliding headings or footnotes that cause the slug normalization process to consume excessive CPU resources. This leads to service unavailability or degraded performance. There is no impact on confidentiality or integrity. No authentication is required to trigger the vulnerability.
Mitigation Recommendations
A patch is available that removes the quadratic behavior while maintaining unique slug IDs and output correctness. Users should upgrade to a patched release at or beyond version 2.9.0. As temporary workarounds, integrators can disable slug uniqueness by setting slug_normalizer/unique to false, disable the HeadingPermalinkExtension and TableOfContentsExtension (which depends on it), and FootnoteExtension for untrusted Markdown, or limit document size and heading count upstream to avoid triggering the quadratic cost. These workarounds trade off functionality or correctness and are not recommended long-term.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-mh25-x5hq-wrqp
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["Packagist"]
- Database Specific Severity
- HIGH
- Cvss Version
- 3.1
Threat ID: 6a7573c1bf8831d539d945c8
Added to database: 08/07/2026, 05:57:21 UTC
Last enriched: 08/07/2026, 06:11:50 UTC
Last updated: 08/07/2026, 07:19:52 UTC
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.