Validate uncompressed packet size#1527
Merged
electronicboy merged 2 commits intoPaperMC:dev/3.0.0from Mar 14, 2025
jonesdevelopment:fix/compression-bypass
Merged
Validate uncompressed packet size#1527electronicboy merged 2 commits intoPaperMC:dev/3.0.0from jonesdevelopment:fix/compression-bypass
electronicboy merged 2 commits intoPaperMC:dev/3.0.0from
jonesdevelopment:fix/compression-bypass
Conversation
electronicboy
approved these changes
Mar 14, 2025
WiIIiam278
pushed a commit
to WiIIiam278/Velocity
that referenced
this pull request
Mar 24, 2025
* Validate uncompressed packet size * Fix debug using incorrect value
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.
In Minecraft, the client never sends a claimed uncompressed packet size of 0 if the actual size of the packet exceeds the compression threshold. In Velocity, there is no check to confirm that packets are the size they claim to be.
While this is not a huge vulnerability, it can be used to force Velocity to skip packets during compression, therefore potentially allowing people to send arbitrarily large packets.
For reference, this is the decompiled code of MCP for 1.19.2 and 1.21.4 (it's the same for all other version as well):


As you can see, the client uses the actual packet size to determine whether to compress the packet or not. Velocity simply relies on the
claimedUncompressedSize, which can simply be set to0to skip the entire compression process.Velocity/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java
Lines 53 to 58 in c9aa1cc