Add decompressed-bytes-per-second rate limit, update packet limiter defaults#1786
Open
WouterGritter wants to merge 2 commits intoPaperMC:dev/3.0.0from
Open
Add decompressed-bytes-per-second rate limit, update packet limiter defaults#1786WouterGritter wants to merge 2 commits intoPaperMC:dev/3.0.0from
WouterGritter wants to merge 2 commits intoPaperMC:dev/3.0.0from
Conversation
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.
The
packets-per-secondlimit 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-secondlimit to[packet-limiter], applied after decompression inMinecraftCompressDecoder. 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 havedecompressed-bytes-per-secondset 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.