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.
NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.
CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.
CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.
CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.
A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.
CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.