compression: enforce maximum uncompressed packet size#1498
Open
VasilisDragon wants to merge 1 commit into
Open
compression: enforce maximum uncompressed packet size#1498VasilisDragon wants to merge 1 commit into
VasilisDragon wants to merge 1 commit into
Conversation
The decompressor inflated packets with no bound on the output size, so a peer could send a small packet that expands to an unbounded synchronous allocation. Cap the inflate at the protocol maximum (2^23 bytes) via zlib's maxOutputLength and reject packets whose declared length already exceeds it.
b493dc7 to
d816de5
Compare
extremeheat
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Decompressorinsrc/transforms/compression.jsinflates compressed packets withzlib.unzipSync(..., { finishFlush: 2 })and no bound on the output size. The declareduncompressed length is read but only used for a
console.error, never enforced, so a peer cansend a small, highly compressible packet that inflates to an arbitrarily large synchronous
allocation and OOMs the process. This is the behavior reported in #664 ("Players know about
this bug, and are actively exploiting it to ... effectively 'ban' them"); the earlier #729
capped only the outbound
Compressorand was closed, so the inbound path is still unbounded.Resolves #664.
The transform is shared by both pipelines, so this affects clients/bots (malicious server) and
any
node-minecraft-protocolserver (malicious client) symmetrically.Fix
Enforce the protocol's maximum uncompressed packet size of
2 ** 23(8388608) bytes — the valuevanilla applies in
NettyCompressionDecoder:maxOutputLengthtozlib.unzipSync, so a packet that inflates past the cap throwsERR_BUFFER_TOO_LARGEand is dropped by the existing error handler instead of allocatingwithout bound; and
No behavior change for spec-compliant traffic — every legitimate packet is ≤ 8 MiB uncompressed,
and anything larger is already rejected by a vanilla client.
Test
New
test/compressionTest.js, exercising the transforms directly (no server jar):value === 0) passthrough — the no-regression cases;emitted — the assertion fails on
master, which inflates and forwards it;2 ** 23-byte packet still round-trips, since the cap rejects only outputpast the maximum — legitimate max-size packets are unaffected.
npm testgreen locally (standardplus mocha).Scope
Intentionally narrow. The
Splitterinframing.jsalso buffers an attacker-declared framelength with no maximum — the same class of issue, but a separate change; I'll propose a
max-frame-size cap in a follow-up PR rather than widen this one.