Skip to content

Add decompressed-bytes-per-second rate limit, update packet limiter defaults - #1786

Merged
electronicboy merged 4 commits into
PaperMC:dev/3.0.0from
WouterGritter:decompressed-bps-limiter
May 24, 2026
Merged

Add decompressed-bytes-per-second rate limit, update packet limiter defaults#1786
electronicboy merged 4 commits into
PaperMC:dev/3.0.0from
WouterGritter:decompressed-bps-limiter

Conversation

@WouterGritter

@WouterGritter WouterGritter commented May 4, 2026

Copy link
Copy Markdown
Member

The packets-per-second limit was introduced to mitigate compression bomb attacks, where an attacker floods the proxy with small packets that decompress to the maximum allowed size. It's the wrong metric for this, though: 500 packets/s at 2 MiB each is 1 GiB/s of decompressed data, which kills the proxy just as effectively. At the same time, legitimate clients with chatty mods (e.g. heavy plugin-message traffic) were getting disconnected despite consuming far less than any attacker would.

This PR adds a decompressed-bytes-per-second limit to [packet-limiter], applied after decompression in MinecraftCompressDecoder. This directly measures what was causing OOM issues, rather than using a proxy metric. With a default of 5 MiB/s over a 7-second window (35 MiB of headroom per window), legitimate clients should never get close to this limit, while any compression bomb is caught well before it causes memory pressure.

Default config changes (config version 2.7 -> 2.8):

  • packets-per-second: 500 -> -1 (disabled)
  • bytes-per-second: unchanged (-1)
  • decompressed-bytes-per-second: new field, defaults to 5242880 (5 MiB/s)

A migration for this has also been added, overriding the previous defaults if the config version was 2.7 or older, including comments explaining each metric.

Ported from GemstoneGG#871.

@WouterGritter

Copy link
Copy Markdown
Member Author

This PR also reverts ab8333d, see #1792. This commit is no longer needed as this PR resolves any threat of a decompression attack, this commit would kill legitimate connections way too soon.

@electronicboy
electronicboy merged commit 25fbd83 into PaperMC:dev/3.0.0 May 24, 2026
1 check passed
@WouterGritter
WouterGritter deleted the decompressed-bps-limiter branch May 24, 2026 19:47
DartCZ pushed a commit to DartCZ/Velocity that referenced this pull request Jun 4, 2026
…efaults (PaperMC#1786)

* Add decompressed-bytes-per-second packet limiter, update defaults
* Revert "Add compression ratio limiter"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants