Skip to content

Cap pre-join plugin-message queue size (prevents arbitrary growth/OOM)#1800

Open
WouterGritter wants to merge 1 commit into
PaperMC:dev/3.0.0from
WouterGritter:prejoin-pm-cap
Open

Cap pre-join plugin-message queue size (prevents arbitrary growth/OOM)#1800
WouterGritter wants to merge 1 commit into
PaperMC:dev/3.0.0from
WouterGritter:prejoin-pm-cap

Conversation

@WouterGritter
Copy link
Copy Markdown
Contributor

A client that stalls its FML/login handshake could enqueue plugin messages (each up to ~32 KiB serverbound) without bound in ClientPlaySessionHandler#loginPluginMessages, growing per-connection heap until an OOM kill. This PR caps the queue by both bytes (4 MiB) and count (1024), configurable via velocity.max-queued-login-plugin-message-bytes and velocity.max-queued-login-plugin-messages, and disconnects on overflow.

@WouterGritter
Copy link
Copy Markdown
Contributor Author

WouterGritter commented May 21, 2026

Depending on how long a client is actually able to stall the login phase for, this may be a scary OOM once again.

Without this fix, and at the default rate limit of 500 pps, a client would be able to fill this queue with 160MB of plugin messages every second (at 32kb/PM). That's 10GB within a minute, currently exploitable.
My math was wrong; this may fill the queue at a rate of 16MB/s. Still 1GB per minute.

Of course this PR fixes that, and I'm sorry to keep bumping this but, #1786 would have greatly crippled this attack. At a limit of 5MB/s of decompressed packets per second, it would take around half an hour to fill the same 10GB in this queue. Still an OOM, if the client is actually able to stall the login phase for 30 minutes, but way less instant.

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.

2 participants