Skip to content

Validate uncompressed packet size#1527

Merged
electronicboy merged 2 commits intoPaperMC:dev/3.0.0from
jonesdevelopment:fix/compression-bypass
Mar 14, 2025
Merged

Validate uncompressed packet size#1527
electronicboy merged 2 commits intoPaperMC:dev/3.0.0from
jonesdevelopment:fix/compression-bypass

Conversation

@jonesdevelopment
Copy link
Contributor

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

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 to 0 to skip the entire compression process.

int claimedUncompressedSize = ProtocolUtils.readVarInt(in);
if (claimedUncompressedSize == 0) {
// This message is not compressed.
out.add(in.retain());
return;
}

@electronicboy electronicboy merged commit d9f1016 into PaperMC:dev/3.0.0 Mar 14, 2025
1 check passed
WiIIiam278 pushed a commit to WiIIiam278/Velocity that referenced this pull request Mar 24, 2025
* Validate uncompressed packet size

* Fix debug using incorrect value
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