GHSA-c2pc-g5qf-rfrf: league/commonmark's quadratic complexity bugs may lead to a denial of service
Impact Several polynomial time complexity issues in league/commonmark may lead to unbounded resource exhaustion and subsequent denial of service. Malicious users could trigger that inefficient code with carefully crafted Markdown inputs that are specifically designed to ensure the worst-case performance is reached.
Published Dec 9, 2024
Affected packages
league/commonmark
- Ecosystem
- Composer (PHP)
- Affected
- < 2.6.0
- Fixed in
- 2.6.0
- Check
composer show league/commonmark
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Impact
Several polynomial time complexity issues in league/commonmark may lead to unbounded resource exhaustion and subsequent denial of service.
Malicious users could trigger that inefficient code with carefully crafted Markdown inputs that are specifically designed to ensure the worst-case performance is reached. Sending multiple such requests in parallel could tie up all available CPU resources and/or PHP-FPM processes, leading to denial of service for legitimate users.
Patches
These vulnerabilities have been patched in version 2.6.0. All users on older versions are highly encouraged to upgrade as soon as possible.
Workarounds
If you cannot upgrade, you may be able to mitigate the issues by:
- Setting very low
memory_limitandmax_execution_timePHP configurations to prevent runaway resource usage - Implementing rate-limiting, bot protection, or other approaches to reduce the risk of simultaneous bad requests hitting your site
- Limiting the size of inputs fed into this library (specifically the max length of each line)
- Limiting the use of this library to trusted users
References
Most of these issues were discovered in other Markdown parsers. You can read more about them here:
- https://github.com/commonmark/commonmark.js/issues/129
- https://github.com/commonmark/commonmark.js/issues/157
- https://github.com/commonmark/commonmark.js/issues/172
- https://github.com/github/cmark-gfm/security/advisories/GHSA-r572-jvj2-3m8p
- https://github.com/github/cmark-gfm/security/advisories/GHSA-24f7-9frr-5h2r
- https://github.com/github/cmark-gfm/security/advisories/GHSA-29g3-96g3-jg6c
- https://github.com/github/cmark-gfm/security/advisories/GHSA-r8vr-c48j-fcc5
- https://github.com/github/cmark-gfm/security/advisories/GHSA-w4qg-3vf7-m9x5
- https://github.com/github/cmark-gfm/security/advisories/GHSA-66g8-4hjf-77xh
For general information about this type of issue:
- https://en.wikipedia.org/wiki/Time_complexity
- https://cwe.mitre.org/data/definitions/407.html
References
- https://github.com/github/cmark-gfm/security/advisories/GHSA-24f7-9frr-5h2r
- https://github.com/github/cmark-gfm/security/advisories/GHSA-29g3-96g3-jg6c
- https://github.com/github/cmark-gfm/security/advisories/GHSA-66g8-4hjf-77xh
- https://github.com/github/cmark-gfm/security/advisories/GHSA-r572-jvj2-3m8p
- https://github.com/github/cmark-gfm/security/advisories/GHSA-r8vr-c48j-fcc5
- https://github.com/github/cmark-gfm/security/advisories/GHSA-w4qg-3vf7-m9x5
- https://github.com/thephpleague/commonmark/security/advisories/GHSA-c2pc-g5qf-rfrf
- https://github.com/commonmark/commonmark.js/issues/129
- https://github.com/commonmark/commonmark.js/issues/157
- https://github.com/commonmark/commonmark.js/issues/172
- https://github.com/advisories/GHSA-c2pc-g5qf-rfrf
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-97jj-33gv-5xf9
league/commonmark: DisallowedRawHtml bypassed when a disallowed tag name ends the raw-HTML literal
medium6.1Sep 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, 2026
