# GHSA-35QR-V9MM-35C5: XmlFrameDecoder quadratic CPU exhaustion via trickled unbalanced element (incomplete fix of CVE-2026-73507)

- Database: GitHub
- Severity: CVSS 7.5 (High)
- Published: 2026-12-02
- Modified: 2026-12-02

## Tracked as

- [CVE-2026-142445](https://cve.now/CVE-2026-142445.md): Io.netty/netty-codec-xml: netty: xmlframedecoder quadratic cpu exhaustion via trickled unbalanced element (incomplete fix of cve-2026-73507)

## Affected versions

- io.netty:netty-codec-xml (Maven): from 4.2.0.Final, through 4.2.18.Final
- io.netty:netty-codec-xml (Maven): through 4.1.138.Final

## Description

## Summary

`XmlFrameDecoder` accumulates inbound bytes until a complete, balanced XML element is present and then emits it as a frame. It does not persist how far it has already scanned, so every `decode()` invocation rescans the entire accumulated buffer starting from the reader index. An unauthenticated remote peer that opens an element (for example `<a>`) and then trickles element content one byte per TCP segment keeps the element permanently unbalanced, so the reader index never advances and each of the n `decode()` calls rescans the whole buffer, producing O(n^2) CPU work on a single event-loop thread. A prior fix for a different trigger of this decoder (CVE-2026-73507 / GHSA-v74w-7mr3-4qg3, released in 4.2.16.Final and 4.1.136.Final) removed only the closing-tag forward scan and did not add a saved scan-progress offset, so this input still runs quadratically on the patched releases.

## Root Cause

The decoder holds no cross-invocation parser state. The only instance field is `maxFrameLength`; all parser variables are re-initialised as locals at the top of every `decode()` call, and the scan loop restarts from the current reader index each time. The reader index advances only when a balanced element is consumed or when the size cap is exceeded, so a dripped, never-balanced element causes the same growing buffer to be rescanned from the start on each call. The size cap `maxFrameLength` bounds total memory but is not a scan-progress guard, so it does not prevent the repeated full rescans.

```text
codec-xml/src/main/java/io/netty/handler/codec/xml/XmlFrameDecoder.java
  line 87  decode(...) declares all parser state as fresh locals (no saved offset)
  line 106 for (int i = in.readerIndex(); i < bufferLength; i++)  // rescans from readerIndex every call
  line 190-208 bytes are consumed only when the element balances (openBracketsCount == 0)
Affected function: io.netty.handler.codec.xml.XmlFrameDecoder.decode
```

## Impact

An unauthenticated remote peer that can reach a pipeline containing `XmlFrameDecoder` can exhaust CPU on the event-loop thread that services the connection. Because framing runs before application logic, no authentication is required. Feeding an opening element followed by trickled content bytes forces quadratic rescanning up to the configured `maxFrameLength`; the referenced prior advisory notes that a 1 MB `maxFrameLength` is sufficient to hang a thread. A small number of connections can pin all event-loop threads, causing service unavailability. The impact demonstrated is denial of service; no confidentiality or integrity impact was observed or is claimed.

## Proof of Concept

`Requires only a TCP peer that can send bytes to a pipeline containing XmlFrameDecoder. The following was reproduced by compiling the 4.2.18.Final decoder source against the released 4.2.18.Final artifacts and driving it with a decoder harness on OpenJDK 17.`

1. Configure `new XmlFrameDecoder(maxFrameLength)` (a large `maxFrameLength` widens the window; the constructor requires a value).
2. Send the three bytes `<a>` to open an unbalanced element.
3. Stream content bytes that are not `<`, `/`, or `>` (for example the byte `x`), one byte per inbound read, without ever closing the element.
4. Each inbound byte triggers one `decode()` call that rescans the whole accumulated buffer.

```text
Inbound bytes: "<a>" then n single-byte reads of 'x' (no closing tag)
Measured on the patched 4.2.18.Final decoder (single-byte reads, OpenJDK 17):
  n =  25,000 -> ~519 ms
  n =  50,000 -> ~1215 ms
  n = 100,000 -> ~4675 ms
  n = 200,000 -> ~18631 ms   (~4x per doubling => quadratic)
Negative control LineBasedFrameDecoder (which persists a scan offset):
  n =  25,000 -> ~17 ms ... n = 200,000 -> ~43 ms   (flat => linear)
```

## Attack Chain

1. **Exposure:** An unauthenticated remote peer reaches a shipped pipeline whose framing stage is `XmlFrameDecoder`; framing runs before application authentication.
2. **Control:** The peer fully controls the inbound byte stream and its segmentation, so it can send an opening element and then drip arbitrary non-markup content bytes.
3. **Path:** The opening element sets `openBracketsCount` to one and marks that at least one element was found; the trailing content bytes match no branch, so the element never balances and the consume block is never reached.
4. **Guard:** The `maxFrameLength` size cap is present but only bounds buffer size; it does not persist scan progress. The prior fix added a fast fail that requires `inClosingTag`, which is set only when a `<` is immediately followed by `/`; the payload contains no `</`, so that fast fail and the removed closing-tag scan are both unreachable.
5. **Primitive:** The scan loop at line 106 restarts from the reader index on every `decode()` call, rescanning the entire growing buffer.
6. **Result:** Summed over n dripped bytes the work is O(n^2), bounded by `maxFrameLength` squared, exhausting an event-loop thread and, across a few connections, all such threads.

## Bypass Evidence

The prior advisory (CVE-2026-73507 / GHSA-v74w-7mr3-4qg3) names the general root cause, that parser state is not saved between `decode()` invocations so the decoder repeatedly rescans the accumulated buffer, but the released remediation changed only the closing-tag handling: it added an `inClosingTag && '<'` fast fail and removed the inner forward scan for `>`. Both of those code paths are reached only after a `<` is immediately followed by `/`. The input used here (`<a>` followed by content bytes with no `</`) never sets `inClosingTag`, so neither the fast fail nor the removed loop applies, and the outer per-call rescan loop was left unchanged with no saved offset. This was verified by reading the shipped 4.2.18.Final source (the fast fail and the absence of any offset field) and by reproducing the quadratic scaling on that patched artifact while an offset-guarded control decoder stayed linear in the same harness. Attempts to refute the finding failed: removing the opening element makes the first content byte fail the pre-start check and drains the buffer, confirming the unbalanced open element is a necessary and attacker-suppliable precondition rather than a blocker.

## Affected Versions

- `Ecosystem: maven`
- `Package: io.netty:netty-codec-xml`
- `Confirmed affected range: >= 4.1.136.Final || >= 4.2.16.Final`
- `Latest release checked: 4.2.18.Final (Maven Central; source byte-identical to the released tag netty-4.2.18.Final)`
- `Fix status: not fixed (no released version addresses this trigger on any maintained line)`

The affected range begins at the releases that carry the incomplete fix (4.2.16.Final on the 4.2.x line and 4.1.136.Final on the 4.1.x line). Earlier releases are affected by the original CVE-2026-73507 range and are already covered there. The 4.2.x boundary was verified by executing the exact published 4.2.18.Final artifact; the 4.1.x boundary is derived from the prior advisory recording the same fix applied at 4.1.136.Final to identical code, and is stated as an inference rather than an independently executed result. No upper bound applies because no maintained line ships a fix and the current development head carries byte-identical decoder code.

## Suggested Fix

Persist a scan-progress offset across `decode()` invocations so previously scanned bytes are not re-examined, mirroring the offset field used by `LineBasedFrameDecoder`. Resuming the scan from the saved offset addresses the root cause named by the original advisory (repeated full-buffer rescans) rather than only the closing-tag trigger. As an interim mitigation, deployments can reduce `maxFrameLength` to shrink the quadratic ceiling, place the XML endpoint behind authentication or a rate limiter, or terminate connections that do not complete a frame promptly, though none of these fully removes the quadratic behaviour.

Reported by zx (GitHub: @manus-pi).

## References

- https://github.com/netty/netty/security/advisories/GHSA-35qr-v9mm-35c5

Page: https://cve.now/GHSA-35QR-V9MM-35C5

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
