GHSA-mj63-m3rc-8ppr: league/commonmark: Denial of service via deeply nested XML output
Impact XmlRenderer pretty-prints XML by emitting depth-proportional indentation whitespace for every opening and closing tag. For a tree of depth n, the indentation alone sums to O(n²) bytes of output (and corresponding memory), reachable through MarkdownToXmlConverter — e.g. strrepeat(' ', $depth) .
Published Aug 6, 2026
Affected packages
league/commonmark
- Ecosystem
- Composer (PHP)
- Affected
- >= 2.0.0, < 2.9.0
- Fixed in
- 2.9.0
- Check
composer show league/commonmark
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Impact
XmlRenderer pretty-prints XML by emitting depth-proportional indentation whitespace for every opening and closing tag. For a tree of depth n, the indentation alone sums to O(n²) bytes of output (and corresponding memory), reachable through MarkdownToXmlConverter — e.g. str_repeat('> ', $depth) . "x\n", a single line of nested blockquotes — or through a direct XmlRenderer::renderDocument() call on an attacker-influenced AST.
This affects applications that convert untrusted Markdown to XML, which is an opt-in output path. The parser's max_nesting_level bounds the depth of *parser-created* trees, but its default is high enough to reach damaging sizes, can be raised by the host application, and does not constrain custom or programmatically built ASTs handed straight to the renderer. The result is a memory / output-size amplification rather than a hard crash, which is why this issue is rated Medium rather than High. No confidentiality or integrity impact. XML rendering was introduced in 2.0.0 (first shipped in 2.0.0-beta1, June 2021) and has emitted depth-proportional indentation ever since, so all 2.x releases are affected (verified against 2.8.x, clean upstream 1902f60f). 1.x has no XML renderer and is not affected.
Workarounds
Applications converting untrusted Markdown to XML should:
- Lower `max_nesting_level` to a conservative value appropriate to expected content, so the parser refuses to build extremely deep trees. This is the most direct lever for parser-produced ASTs, but does not protect trees built programmatically and passed straight to
XmlRenderer. - Cap input size before conversion, since the amplification is driven by input-proportional depth.
- Constrain XML consumers with memory / output-size limits (and streaming or size caps on any downstream XML parser or storage) so one request cannot allocate unbounded output.
- Prefer HTML rendering for untrusted content where XML is not strictly required — the HTML renderer does not emit depth-proportional indentation and is not subject to this amplification.
Credited to GrahamCampbell.
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-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
