# GHSA-5H6F-WP3F-6HMV: DelimiterBasedFrameDecoder non-line delimiter causes quadratic CPU exhaustion via trickled delimiter-free input

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

## Tracked as

- [CVE-2026-142444](https://cve.now/CVE-2026-142444.md): Io.netty/netty-codec-base: io.netty/netty-codec: netty: delimiterbasedframedecoder non-line delimiter causes quadratic cpu exhaustion

## Affected versions

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

## Description

## Summary

`DelimiterBasedFrameDecoder` configured with a non-line delimiter (for example `Delimiters.nulDelimiter()` or any custom delimiter) calls `ByteBufUtil.indexOf` for every delimiter on every `decode()` call, scanning the whole accumulated buffer from the reader index. It keeps no scan-progress offset, so an unauthenticated remote peer that streams delimiter-free bytes one per TCP segment forces a full buffer scan on each byte, producing O(n^2) CPU work up to the configured `maxFrameLength`. The common line-delimited configuration is delegated to `LineBasedFrameDecoder`, which persists a scan offset and is not affected; only the generic-delimiter branch carries this behaviour.

## Root Cause

The generic-delimiter branch has no field that records how far the buffer has already been searched. When no delimiter is found, and while the buffer is below `maxFrameLength`, the decoder returns without consuming any bytes, so the reader index does not advance. The next inbound fragment enlarges the buffer and the decoder rescans it in full from the reader index. The `maxFrameLength` check only discards data once the buffer already exceeds the limit and therefore bounds memory rather than scan progress. The line-delimiter path avoids this because it is routed to `LineBasedFrameDecoder`, which resumes searching from a persisted offset and stays linear.

```text
codec-base/src/main/java/io/netty/handler/codec/DelimiterBasedFrameDecoder.java
  line 229 decode(ctx, buffer): non-line branch (lineBasedDecoder == null)
  line 236-242 loops each delimiter calling indexOf(buffer, delim) => full scan from readerIndex
  line 277-294 below maxFrameLength nothing is consumed; returns null with no reader-index advance
  (the class has no scan-offset field)
Affected function: io.netty.handler.codec.DelimiterBasedFrameDecoder.decode
```

## Impact

An unauthenticated remote peer that can reach a service using `DelimiterBasedFrameDecoder` with a non-line delimiter can exhaust CPU on the event-loop thread that services the connection. Framing runs before application logic, so no authentication is required. Because the per-attempt cost grows as the square of the buffered length up to `maxFrameLength`, and `maxFrameLength` is commonly one megabyte or larger, a few trickle connections can pin all event-loop threads and cause service unavailability. The impact demonstrated is denial of service; no confidentiality or integrity impact was observed or is claimed. The condition is present only when the application configures a non-line delimiter; that configuration is realistic because a NUL delimiter helper ships with the library and NUL and custom delimited protocols are common.

## Proof of Concept

`Requires a TCP peer that can send bytes to a pipeline whose framing stage is a DelimiterBasedFrameDecoder configured with a non-line delimiter. Reproduced against the released 4.2.18.Final artifact with a decoder harness on OpenJDK 17.`

1. Configure `new DelimiterBasedFrameDecoder(maxFrameLength, Delimiters.nulDelimiter())` (or any custom, non-line delimiter).
2. Stream bytes that never contain the delimiter, one byte per inbound read.
3. Each inbound byte triggers one `decode()` call that scans the whole accumulated buffer.

```text
Inbound bytes: n delimiter-free bytes, one per read, using a NUL delimiter
Measured on the released 4.2.18.Final artifact (single-byte reads, OpenJDK 17):
  n =  25,000 -> ~87 ms
  n =  50,000 -> ~181 ms
  n = 100,000 -> ~669 ms
  n = 200,000 -> ~2671 ms   (~4x per doubling => quadratic)
Negative control LineBasedFrameDecoder (persists a scan offset): flat => linear
```

## Attack Chain

1. **Exposure:** An unauthenticated remote peer reaches a shipped pipeline whose framing stage is a `DelimiterBasedFrameDecoder` configured with a non-line delimiter; framing runs before application authentication.
2. **Control:** The peer fully controls the inbound byte stream and its segmentation, so it can stream bytes that never contain the delimiter.
3. **Path:** With `lineBasedDecoder` null, `decode()` calls `indexOf` for each delimiter, and `ByteBufUtil.indexOf` scans the entire readable region from the reader index on every call.
4. **Guard:** The `readableBytes() > maxFrameLength` discard is present but only fires once the buffer exceeds the limit; below the limit the method returns without advancing the reader index, and there is no scan-progress offset.
5. **Primitive:** Each `decode()` rescans the full accumulated buffer from the reader index.
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

No prior advisory addresses `DelimiterBasedFrameDecoder`; the repository advisories and the ecosystem advisories for the affected package were enumerated and none names this class or method. The two related complexity issues in this project are in different classes and modules with independent fixes: CVE-2026-73507 / GHSA-v74w-7mr3-4qg3 concerns `XmlFrameDecoder`, and CVE-2026-75596 / GHSA-fccg-mwvh-qqg4 concerns `SslClientHelloHandler`. This report is therefore a distinct issue rather than an incomplete fix or duplicate. The generic-delimiter branch was read in full and shown to have no scan-offset field, while the line-delimiter path is routed to `LineBasedFrameDecoder`, which resumes from a persisted offset; switching the configuration to a line delimiter removes the quadratic behaviour, confirming the missing offset in the generic branch is the cause. The scaling was reproduced on the released artifact with an offset-guarded control decoder staying linear in the same harness. The strongest counterargument considered, that the cost might be low because it is bounded by `maxFrameLength`, does not hold: `maxFrameLength` is application chosen and commonly one megabyte or larger, giving a large per-attempt quadratic that pins an event-loop thread.

## Affected Versions

- `Ecosystem: maven`
- `Package: io.netty:netty-codec-base`
- `Confirmed affected range: <= 4.2.18.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 adds a scan offset to the generic-delimiter branch)`

The `io.netty:netty-codec-base` artifact exists only on the 4.2.x line, and every published release of it carries the unguarded generic-delimiter branch, so the entire published history through 4.2.18.Final is affected with no lower fix boundary. The same code ships on the 4.1.x line under the pre-split coordinate `io.netty:netty-codec` and is also affected there; that line is not represented in this entry's single package coordinate and was not independently executed, but maintainers should apply the same fix to both artifacts. No fix exists on any line.

## Suggested Fix

Add a persisted scan-progress offset to the generic-delimiter branch so each `decode()` resumes the delimiter search from where the previous call stopped, at parity with the offset already used by `LineBasedFrameDecoder`. As an interim mitigation, deployments can reduce `maxFrameLength` to shrink the quadratic ceiling, prefer the line-delimited configuration where protocol semantics allow, or place the endpoint behind authentication or a rate limiter and 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-5h6f-wp3f-6hmv

Page: https://cve.now/GHSA-5H6F-WP3F-6HMV

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