VDB
KO
HIGH

GHSA-q6cq-mhr2-jmr5

Netty: [codec-haproxy] Signed-Byte Sentinel Collision in HAProxyMessageDecoder Leads to Unbounded Memory Exhaustion

Quick fix

GHSA-q6cq-mhr2-jmr5 — io.netty:netty-codec-haproxy: upgrade to the fixed version with the command below.

# pom.xml: bump <version>4.2.16.Final</version> for io.netty:netty-codec-haproxy

Details

The `HAProxyMessageDecoder` in netty's `codec-haproxy` module performs protocol version detection by reading the 13th byte of the inbound stream as a signed Java `byte` and widening it to `int` without masking. When an attacker sends a PROXY protocol v2 binary prefix (`0D 0A 0D 0A 00 0D 0A 51 55 49 54 0A`) followed by version byte `0xFF`, the sign extension produces `-1`, which collides with the decoder's "need more data" sentinel value. This collision traps the decoder in a version-detection loop where it perpetually requests more data without consuming any bytes, never instantiates the `HeaderExtractor` that enforces header size limits, and causes `ByteToMessageDecoder` to accumulate all subsequent inbound bytes into an unbounded `cumulation` buffer until the JVM exhausts its direct memory allocation.

Are you affected?

Enter the version of the package you're using.

Affected packages

Maven / io.netty:netty-codec-haproxy
Introduced in: 4.2.0.Final Fixed in: 4.2.16.Final
Fix # pom.xml: bump <version>4.2.16.Final</version> for io.netty:netty-codec-haproxy
Maven / io.netty:netty-codec-haproxy
Introduced in: 4.1.0.Final Fixed in: 4.1.136.Final
Fix # pom.xml: bump <version>4.1.136.Final</version> for io.netty:netty-codec-haproxy

References