Skip to main content
Menu
Advisories

HttpContentDecompressor Brotli maxAllocation incomplete fix permits 64 KiB output buffers below configured cap

GHSA-J23P-MH75-24RXPublished Updated GitHub

Description

io.netty.handler.codec.http.HttpContentDecompressor(int maxAllocation) documents maxAllocation as the maximum size of the decompression buffer. For Content-Encoding: br, current supported Netty releases pass that value to new BrotliDecoder(maxAllocation).

In Netty, BrotliDecoder(int) treats the argument as the input-buffer size, not the output-buffer cap. It delegates to the two-argument constructor with CompressionUtil.DEFAULT_MAX_FORWARD_BYTES as the output-buffer size. That default is 64 KiB. As a result, an application that configures new HttpContentDecompressor(1024) can still receive 65,536-byte decompressed HTTP content buffers from a Brotli body.

This appears to be a residual incomplete fix for GHSA-f6hv-jmp6-3vwv / CVE-2026-42587, which addressed HttpContentDecompressor maxAllocation bypasses for Brotli, Snappy, and Zstd. The current Brotli callsite is wired to the wrong constructor semantic, so the HTTP/1 API still does not enforce sub-64KiB decompression-buffer caps for br.

The original unbounded Brotli bypass appears to have been reduced, but supported releases currently listed as patched for CVE-2026-42587 still violate the HTTP/1 maxAllocation contract for configured caps below 64 KiB.

Technical Details

Current HTTP/1 HttpContentDecompressor uses:

.handlers(new BrotliDecoder(maxAllocation))

But BrotliDecoder(int inputBufferSize) does not set the output cap:

public BrotliDecoder(int inputBufferSize) {
    this(inputBufferSize == 0 ? DEFAULT_INPUT_BUFFER_SIZE : inputBufferSize, DEFAULT_MAX_FORWARD_BYTES);
}

The max-allocation value therefore changes the Brotli decoder input buffer, while decompressed output remains capped at the 64 KiB default.

PoC

Add pov/HttpContentDecompressorBrotliMaxAllocationPovTest.java to codec-http/src/test/java/io/netty/handler/codec/http/, then run:

./mvnw -pl codec-http -am -Dtest=HttpContentDecompressorBrotliMaxAllocationPovTest -Dsurefire.failIfNoSpecifiedTests=false -DskipNativeTests -DskipAutobahnTests -Dmaven.antrun.skip=true test

Observed on current 4.2 head:

Tests run: 3, Failures: 1, Errors: 0, Skipped: 0
HttpContentDecompressorBrotliMaxAllocationPovTest.brotliContentEncodingExceedsConfiguredMaxAllocation
AssertionFailedError: observed decompressed chunk size 65536 ==> expected: <true> but was: <false>

The two control tests pass:

  • gzip rejects the same oversized decompression under maxAllocation=1024.
  • direct new BrotliDecoder(8192, 1024) emits buffers no larger than 1024 bytes.

Impact

A remote peer controlling a Brotli-compressed HTTP body can bypass a sub-64KiB decompression-buffer cap chosen by the Netty application and force Netty to allocate and forward 64 KiB decompressed buffers. This weakens the maxAllocation protection for memory-constrained HTTP deployments that set low caps to reduce decompression-bomb pressure.

The supplied local PoV uses a 128 KiB plaintext body compressed with Brotli and sends it through HttpContentDecompressor(1024). Netty emits a 65,536-byte HttpContent chunk. The same PoV shows that gzip with the same maxAllocation=1024 rejects with DecompressionException, and that direct new BrotliDecoder(8192, 1024) respects the 1024-byte output cap.

This is availability-only. No confidentiality or integrity impact was identified.

Affected Package/Versions

  • Package: io.netty:netty-codec-http
  • Primary surface: HTTP/1 HttpContentDecompressor
  • Confirmed affected:
  • current 4.2 branch 7bae566a93e69409697fe57fa807910ba5c9720e
  • 4.2.15.Final a41f7b289ce1d697c50846f3ade3983e22b2ed40
  • 4.1.135.Final f05f765d81460799c53123a207f665bf3b465171
  • 4.2.13.Final b3844c8108b42f68d56144b36d4d1ed96078a688, listed as patched for CVE-2026-42587
  • 4.1.133.Final fb13125f135ab53203513ff603872a3abe84d38d, listed as patched for CVE-2026-42587

Recommended Fix

A local control on 4.2.15.Final passed the PoV after changing the Brotli HTTP/1 callsite to use the two-argument constructor when a nonzero max allocation is configured:

private static final int BROTLI_INPUT_BUFFER_SIZE = 8 * 1024;

.handlers(maxAllocation == 0
        ? new BrotliDecoder()
        : new BrotliDecoder(BROTLI_INPUT_BUFFER_SIZE, maxAllocation))

This preserves the previous unlimited behavior for maxAllocation == 0 and uses maxAllocation as the Brotli output-buffer cap when a limit is configured.

Workarounds

Until a patched release is available, applications that require strict sub-64KiB HTTP/1 decompression-buffer caps should avoid relying on Brotli through HttpContentDecompressor.

Possible mitigations:

  • do not advertise or accept Content-Encoding: br on paths protected by low maxAllocation values;
  • omit Brotli support from the runtime so Brotli.isAvailable() is false;
  • use a custom HTTP decompression handler that instantiates BrotliDecoder(inputBufferSize, outputBufferSize) with the intended output cap;
  • if operationally acceptable, configure maxAllocation >= 65536 so the current Brotli output chunk size does not exceed the configured cap.

Suggested Severity

  • Severity: Medium
  • CVSS v3.1: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L = 5.3
  • CWE: CWE-400 / CWE-770

The issue is remotely triggerable by a peer that can send a Brotli-compressed HTTP body through a Netty pipeline using HttpContentDecompressor with a small nonzero maxAllocation. The impact is resource consumption / availability only, bounded here by the 64 KiB Brotli forward-buffer default rather than arbitrary memory corruption or data disclosure.

Affected versions

References

GitHub · netty/netty