[PR #4890] [MERGED] Packets past vanilla's decoder limits disconnect #5920

Closed
opened 2026-11-03 05:15:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4890
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: fix/decode-limits


📝 Commits (1)

  • a659893 Packets past vanilla's decoder limits disconnect

📊 Changes

2 files changed (+81 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/lan/conn.rs (+73 -7)
📝 crates/horizon-protocol/src/buf.rs (+8 -2)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Phase 5 of the anticheat work (vanilla's own packet checks, always on as parity): what vanilla's codecs refuse now disconnects here too, as vanilla's decoder exception does (Invalid packet <id>: ...).

  • A custom payload over 32767 bytes, in configuration and in play (DiscardedPayload's codec: Payload may not be larger than 32767 bytes). Horizon's own horizon:quiet_commands batches already keep to this (quiet::MAX_PAYLOAD).
  • A command suggestion request over 32500 characters (ServerboundCommandSuggestionPacket: readUtf(32500)). The game reads it later, so the server ignored a longer one instead of disconnecting. Its codec now runs where the packet arrives.
  • String limits count Java's UTF-16 units (Utf8String.read compares String.length()). A character outside the BMP (an emoji) counts twice; Horizon counted Unicode characters, so a string up to twice vanilla's limit got through (chat, commands, signs, book pages...).

Not in this PR: vanilla also disconnects a keep-alive answer whose id isn't the pending one (disconnect.timeout). That needs the writer thread to share its pending id with the reader, so it's a separate change.

Test

  • lan::conn::tests::payloads_and_suggestions_past_vanillas_limits_are_malformed: 32767 bytes passes and 32768 fails, in play and in configuration; a 32500-character suggestion passes and 32501 fails.
  • buf::tests::strings_positions_and_options: 8 emoji are 16 units, so they pass a limit of 16 and fail one of 15.
  • python3 tools/parity.py dedicated_server server_entities server_player_damage: 3 passed.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 6eac54099, 4 min 48 s)

Check Result
Scope ✅ 2 files, +81 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (49 s)
rustfmt ✅ (4 s)
clippy ✅ (49 s)
tests: horizon-client, horizon-protocol ✅ 1393 passed (2 min 42 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 117 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, breaking_model and 105 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4890 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/decode-limits` --- ### 📝 Commits (1) - [`a659893`](https://github.com/horizon-rust/horizon/commit/a65989354de450e075c272cdaf80000b34165e09) Packets past vanilla's decoder limits disconnect ### 📊 Changes **2 files changed** (+81 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/conn.rs` (+73 -7) 📝 `crates/horizon-protocol/src/buf.rs` (+8 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Phase 5 of the anticheat work (vanilla's own packet checks, always on as parity): what vanilla's codecs refuse now disconnects here too, as vanilla's decoder exception does (`Invalid packet <id>: ...`). - **A custom payload over 32767 bytes**, in configuration and in play (`DiscardedPayload`'s codec: `Payload may not be larger than 32767 bytes`). Horizon's own `horizon:quiet_commands` batches already keep to this (`quiet::MAX_PAYLOAD`). - **A command suggestion request over 32500 characters** (`ServerboundCommandSuggestionPacket`: `readUtf(32500)`). The game reads it later, so the server ignored a longer one instead of disconnecting. Its codec now runs where the packet arrives. - **String limits count Java's UTF-16 units** (`Utf8String.read` compares `String.length()`). A character outside the BMP (an emoji) counts twice; Horizon counted Unicode characters, so a string up to twice vanilla's limit got through (chat, commands, signs, book pages...). Not in this PR: vanilla also disconnects a keep-alive answer whose id isn't the pending one (`disconnect.timeout`). That needs the writer thread to share its pending id with the reader, so it's a separate change. ### Test - `lan::conn::tests::payloads_and_suggestions_past_vanillas_limits_are_malformed`: 32767 bytes passes and 32768 fails, in play and in configuration; a 32500-character suggestion passes and 32501 fails. - `buf::tests::strings_positions_and_options`: 8 emoji are 16 units, so they pass a limit of 16 and fail one of 15. - `python3 tools/parity.py dedicated_server server_entities server_player_damage`: 3 passed. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 6eac54099, 4 min 48 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +81 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (49 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (49 s) | | tests: horizon-client, horizon-protocol | ✅ 1393 passed (2 min 42 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 117 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, breaking_model and 105 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5920
No description provided.