VYPR
High severityNVD Advisory· Published Oct 19, 2021· Updated Aug 4, 2024

CVE-2021-37136

CVE-2021-37136

Description

The Bzip2 decompression decoder function doesn't allow setting size restrictions on the decompressed output data (which affects the allocation size used during decompression). All users of Bzip2Decoder are affected. The malicious input can trigger an OOME and so a DoS attack

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Netty's Bzip2Decoder lacks size limits on decompressed data, allowing remote attackers to cause OutOfMemoryError and denial of service via crafted input.

Vulnerability

The Bzip2Decoder in Netty (versions prior to the fix) does not enforce a maximum size on decompressed output. The decoder allocates a buffer based on the block length from the compressed data without validation, leading to excessive memory allocation. All users of Bzip2Decoder are affected. [1][2]

Exploitation

An attacker can send a specially crafted Bzip2 compressed stream that declares a large block length. When the decoder processes this input, it allocates a buffer of that size, potentially exceeding available memory. No authentication or special privileges are required; the attacker only needs to deliver the malicious payload to a Netty-based service that uses Bzip2Decoder. [2]

Impact

Successful exploitation results in an OutOfMemoryError (OOME), causing a denial of service (DoS) as the application crashes or becomes unresponsive. The vulnerability affects availability only; confidentiality and integrity are not directly compromised. [1][2]

Mitigation

The fix was introduced in Netty commit 41d3d61 (merged into version 4.1.68.Final and later). The patch adds a check that throws a DecompressionException if the block length exceeds MAX_BLOCK_LENGTH (defined as MAX_BLOCK_SIZE * BASE_BLOCK_SIZE). Users should upgrade to Netty 4.1.68.Final or later. No workaround is available other than avoiding the use of Bzip2Decoder. [2][3]

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
io.netty:netty-codecMaven
< 4.1.68.Final4.1.68.Final
org.jboss.netty:nettyMaven
>= 0
io.netty:nettyMaven
>= 0

Affected products

12

Patches

1
41d3d61a6160

Merge pull request from GHSA-grg4-wf29-r9vv

https://github.com/netty/nettyNorman MaurerSep 9, 2021via ghsa
3 files changed · +15 7
  • codec/src/main/java/io/netty/handler/codec/compression/Bzip2BlockDecompressor.java+5 0 modified
    @@ -228,6 +228,11 @@ boolean decodeHuffmanData(final Bzip2HuffmanStageDecoder huffmanDecoder) {
                     bwtBlock[bwtBlockLength++] = nextByte;
                 }
             }
    +        if (bwtBlockLength > MAX_BLOCK_LENGTH) {
    +            throw new DecompressionException("block length exceeds max block length: "
    +                    + bwtBlockLength + " > " + MAX_BLOCK_LENGTH);
    +        }
    +
             this.bwtBlockLength = bwtBlockLength;
             initialiseInverseBWT();
             return true;
    
  • codec/src/main/java/io/netty/handler/codec/compression/Bzip2Constants.java+2 0 modified
    @@ -49,6 +49,8 @@ final class Bzip2Constants {
         static final int MIN_BLOCK_SIZE = 1;
         static final int MAX_BLOCK_SIZE = 9;
     
    +    static final int MAX_BLOCK_LENGTH = MAX_BLOCK_SIZE * BASE_BLOCK_SIZE;
    +
         /**
          * Maximum possible Huffman alphabet size.
          */
    
  • codec/src/main/java/io/netty/handler/codec/compression/Bzip2Decoder.java+8 7 modified
    @@ -291,26 +291,27 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
                     }
     
                     final int blockLength = blockDecompressor.blockLength();
    -                final ByteBuf uncompressed = ctx.alloc().buffer(blockLength);
    -                boolean success = false;
    +                ByteBuf uncompressed = ctx.alloc().buffer(blockLength);
                     try {
                         int uncByte;
                         while ((uncByte = blockDecompressor.read()) >= 0) {
                             uncompressed.writeByte(uncByte);
                         }
    -
    +                    // We did read all the data, lets reset the state and do the CRC check.
    +                    currentState = State.INIT_BLOCK;
                         int currentBlockCRC = blockDecompressor.checkCRC();
                         streamCRC = (streamCRC << 1 | streamCRC >>> 31) ^ currentBlockCRC;
     
                         out.add(uncompressed);
    -                    success = true;
    +                    uncompressed = null;
                     } finally {
    -                    if (!success) {
    +                    if (uncompressed != null) {
                             uncompressed.release();
                         }
                     }
    -                currentState = State.INIT_BLOCK;
    -                break;
    +                // Return here so the ByteBuf that was put in the List will be forwarded to the user and so can be
    +                // released as soon as possible.
    +                return;
                 case EOF:
                     in.skipBytes(in.readableBytes());
                     return;
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

26

News mentions

0

No linked articles in our index yet.