Skip to content

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

Open
WouterGritter wants to merge 2 commits intoPaperMC:dev/3.0.0from
WouterGritter:decompressed-bps-limiter
Open

Add decompressed-bytes-per-second rate limit, update packet limiter defaults#1786
WouterGritter wants to merge 2 commits intoPaperMC:dev/3.0.0from
WouterGritter:decompressed-bps-limiter

Conversation

@WouterGritter
Copy link
Copy Markdown
Contributor

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 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)

Migration: existing configs that already have a [packet-limiter] section configured will have decompressed-bytes-per-second set to -1 to avoid silently changing behavior on servers that tuned already had this configured (manually or by generating a fresh config since 0219993). Config comments have been added to all four options to clarify what each limit measures.

Ported from GemstoneGG#871.

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.

1 participant