Aug 7, 2026·7 min read·23 visits
Unconstrained XML indentation allows remote attackers to trigger quadratic CPU and memory exhaustion by supplying deeply nested Markdown input.
A Denial of Service vulnerability exists in the league/commonmark package for PHP when using the XML rendering subsystem. Due to unconstrained indentation based on AST depth, rendering deeply nested elements leads to asymmetric resource consumption (quadratic output size complexity).
The PHP package league/commonmark provides a highly extensible Markdown parser and renderer. Starting in version 2.0.0, the package introduced the XmlRenderer component, which is responsible for converting the abstract syntax tree (AST) generated from a Markdown document into a structured XML representation. This module is typically accessed programmatically through the MarkdownToXmlConverter class or by invoking XmlRenderer::renderDocument directly.
The vulnerability resides within the pretty-printing mechanism of the XML rendering logic. When generating XML output, the renderer formats elements by indenting them proportionally to their nesting level within the document tree. However, prior to version 2.9.0, the rendering engine did not place any upper limit on the maximum indentation depth.
An attacker can exploit this structural behavior by crafting a Markdown payload that contains extreme levels of nesting. When parsed and passed to the XML renderer, the lack of constraints on indentation depth results in asymmetric resource consumption. This issue is tracked under the identifier GHSA-mj63-m3rc-8ppr.
The root cause of GHSA-mj63-m3rc-8ppr is an algorithmic complexity vulnerability classed under CWE-405: Asymmetric Resource Consumption (Amplification). The XmlRenderer class traverses the node tree using an event-driven loop that tracks whether the engine is entering or exiting a node. For each entering event of a non-self-closing tag, the renderer calculates the current nesting depth and emits a matching sequence of space characters for indentation formatting.
The vulnerability manifests in how the indentation string is constructed. The system calculates the number of spaces by repeating a predefined indentation constant a number of times equal to the current depth. As the depth $n$ increases, the number of space characters emitted for a single node is proportional to $n$. Across a tree of depth $n$, the total space characters generated across all nodes grows quadratically, specifically $O(n^2)$.
While the library features a max_nesting_level parser constraint, this configuration is insufficient to prevent the flaw. First, the default value is high enough to allow significant resource exhaustion before being triggered. Second, it can be customized or disabled by developers. Third, the parser constraint only limits block-level structures and does not restrict nested inline sequences or abstract syntax trees constructed programmatically by downstream applications before being serialized to XML.
The vulnerable version of XmlRenderer.php processed node formatting without any boundary verification. The code relied entirely on the tracker variable $indent to determine string expansion size:
// Vulnerable implementation in XmlRenderer.php
if ($event->isEntering()) {
$attrs = $renderer->getXmlAttributes($node);
// Indentation expands indefinitely based on current depth
$xml .= "\n" . \str_repeat(self::INDENTATION, $indent);
$xml .= self::tag($tagName, $attrs, $selfClosing);
...
} elseif (! $closeImmediately) {
$indent--;
// Indentation scales quadratically as depth increases
$xml .= "\n" . \str_repeat(self::INDENTATION, $indent);
$xml .= self::tag('/' . $tagName);
}The patch committed in version 2.9.0 addresses the vulnerability by decoupling the cosmetic visual indentation from the actual syntactic nesting level. The developer introduced a configuration option xml/max_indentation_level, which is initialized with a safe default value of 16.
// Patched implementation in XmlRenderer.php
$maxIndent = $this->getMaxIndentationLevel();
...
if ($event->isEntering()) {
$attrs = $renderer->getXmlAttributes($node);
// Indentation multiplier is bounded by maxIndent
$xml .= "\n" . \str_repeat(self::INDENTATION, \min($indent, $maxIndent));
$xml .= self::tag($tagName, $attrs, $selfClosing);
...
} elseif (! $closeImmediately) {
$indent--;
// Multiplier is safely capped, restoring linear complexity
$xml .= "\n" . \str_repeat(self::INDENTATION, \min($indent, $maxIndent));
$xml .= self::tag('/' . $tagName);
}By wrapping the $indent multiplier within a \min() constraint, the maximum memory allocated per line for structural whitespace is strictly bounded. The overall complexity of the output payload is reduced from quadratic $O(n^2)$ back to linear $O(n)$ relative to the input depth, completely neutralizing the amplification vector while keeping the generated XML structurally valid.
An attack targeting this vulnerability is executed through the network vector by transmitting a specially crafted input to an application endpoint that converts user-supplied Markdown into XML format. The primary prerequisite is that the target application must instantiate the XML rendering module and expose it to unauthenticated user input.
To trigger the amplification, the attacker generates a payload consisting of deep recursive blockquotes or inline nesting sequences. A payload with a nesting depth of 1,000 blocks can be constructed using repeating blockquote characters:
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >When the PHP runtime processes this input, the parser creates an AST with 1,000 nested levels. During serialization, XmlRenderer repeats the standard 4-character indentation string up to 1,000 times for each nested element. This results in the generation of several megabytes of pure whitespace characters within the PHP memory space.
The consequence is a rapid exhaustion of available memory allocated to the PHP worker process, triggering an Out-of-Memory (OOM) error. Alternatively, the CPU becomes saturated performing repetitive string allocation and copying routines, stalling the application container and preventing it from handling legitimate web requests.
The security impact of GHSA-mj63-m3rc-8ppr is limited to service availability, with a calculated CVSS v3.1 base score of 5.3 (Medium). The vector string is CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
Because the vulnerability occurs within the boundaries of the PHP runtime environment, it does not lead to remote code execution, privilege escalation, or unauthorized access to sensitive application data. The scope remains unchanged because the impact is restricted to the resources allocated to the executing PHP application process.
However, on high-traffic systems, exploiting this vulnerability can cause a complete Denial of Service (DoS) of the web application. A single malicious request can block a PHP-FPM worker thread indefinitely or trigger process termination. Under continuous submission of the payload, an attacker can exhaust the pool of available workers, rendering the entire web service unresponsive.
The recommended remediation for this vulnerability is to upgrade the league/commonmark dependency to version 2.9.0 or higher. This release implements the xml/max_indentation_level restriction by default, bounding the maximum pretty-printing space duplication to a safe value of 16.
For environments where immediate package upgrades are not possible, several temporary workarounds can be applied. Developers should limit the global parsing depth of block structures by lowering the max_nesting_level configuration setting to a value of 50 or less.
// Custom environment configuration workaround
use League\CommonMark\Environment\Environment;
$config = [
'max_nesting_level' => 50,
];
$environment = new Environment($config);In addition, implementing strict length validation on incoming Markdown payloads before they are passed to the parser represents an effective mitigation. Restricting the input payload size to 10 kilobytes or less ensures that the maximum potential AST depth is bounded, thereby eliminating the possibility of high-ratio resource amplification.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
league/commonmark thephpleague | >= 2.0.0, < 2.9.0 | 2.9.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-405 |
| Attack Vector | Network (AV:N) |
| CVSS Score | 5.3 (Medium) |
| Vulnerability Type | Denial of Service (DoS) |
| Exploit Status | None |
| CISA KEV Status | Not Listed |
The software does not properly control the allocation of resources, specifically output buffer size and CPU cycles, when processing inputs with deep structural nesting.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.
CVE-2026-128077 (GHSA-r99w-jh2x-3mg9) is an authorization bypass and interpretation conflict vulnerability affecting Nuxt and its underlying @nuxt/nitro-server package in versions 4.6.0 through 4.6.3. When an incoming HTTP request path begins with a double forward slash (e.g., //x/admin), the WHATWG URL parser within the Nuxt server-side page renderer interprets the initial segment as a network host/authority and resolves the remaining path (/admin) against the application's page router. Because Nitro server middleware, route-scoped serverHandlers, and Nitro routeRules evaluate the unparsed request path (//x/admin), path-based access controls, redirects, and security header policies configured for /admin fail to match and are bypassed.
Prior to version 2.10.2, the sqlite3-ruby gem explicitly cast 64-bit Ruby string lengths (long) to 32-bit signed integers (int) when invoking the underlying SQLite C API. On 64-bit platforms, providing a string of 4 GiB (2^32 bytes) or larger causes integer truncation, instructing SQLite to process only a prefix of the string. This flaw affects SQL query preparation, bound parameter values, and return values from custom Ruby-defined SQL functions and aggregates, allowing trailing SQL clauses such as WHERE restrictions to be silently dropped under specific conditions.
CVE-2026-128068 (GHSA-cpgf-5mjf-73p7) is a Regular Expression Denial of Service (ReDoS) vulnerability in the rails-html-sanitizer Ruby gem affecting versions 1.0.3 through 1.7.1. The flaw resides in the Rails::HTML::PermitScrubber#scrub_attribute method, which uses the multiline regular expression /^\s*[^#\s].*/m to enforce local-only URI fragment references on SVG elements. On Ruby runtimes prior to version 3.2 (CRuby <= 3.1 and JRuby), evaluating an attribute value composed of repeated newline and whitespace characters without a hash character triggers quadratic backtracking O(n^2). Applications are only vulnerable if their sanitization allowlist is explicitly configured to permit SVG reference elements such as <use> alongside href or xlink:href attributes.
CVE-2026-126360 (GHSA-mf5v-w3w3-f6cg) is an algorithmic complexity vulnerability (Regular Expression Denial of Service) in the trace context propagation logic of the opentelemetry-api package within the OpenTelemetry Python ecosystem. In versions prior to 1.45.2, the TraceContextTextMapPropagator.extract() method utilizes a regular expression susceptible to quadratic-time backtracking when parsing malformed W3C traceparent headers containing long sequences of whitespace followed by an embedded newline character. In Python applications—particularly those using single-threaded asynchronous event loops—an unauthenticated remote attacker transmitting payloads over newline-preserving carriers can monopolize CPU execution and induce application-level Denial of Service.
CVE-2026-126359 (GHSA-3gg2-335m-rxc6) is an improper input neutralization vulnerability (CWE-79) in the Hono web framework (`honojs/hono`). Versions from 3.12.0 prior to 4.13.16 evaluate and escape interpolated strings in the `hono/css` helper individually before concatenating template chunks and stripping CSS comments. When a `<` character and a `/style>` sequence are split across template boundaries, adjacent interpolations, or separated by a CSS comment, the sanitizer fails to escape the closing tag sequence. During Server-Side Rendering (SSR), the `<Style />` component outputs an unescaped `</style>` delimiter, permitting an attacker to break out of the CSS raw text context and execute arbitrary HTML and JavaScript in the victim's browser.