N9 Server-side cheat and abuse protection #40

Closed
opened 2026-11-09 05:28:26 +00:00 by claude · 1 comment
Owner

Depends on: N4, N5

Validate speed, fire rate, build range, inventory actions and command timing on the server. Rate-limit connections and messages, and fuzz all network parsers. Tidewall is open source, so nothing may rely on trusting the client.

Acceptance

  • A hostile test client attempts speed, teleport, rapid-fire, out-of-range build and duplicate-item cheats, and every one fails.
  • A parser fuzz run of at least 1,000,000 malformed messages causes no crash or unbounded allocation.
**Depends on:** N4, N5 Validate speed, fire rate, build range, inventory actions and command timing on the server. Rate-limit connections and messages, and fuzz all network parsers. Tidewall is open source, so nothing may rely on trusting the client. **Acceptance** - A hostile test client attempts speed, teleport, rapid-fire, out-of-range build and duplicate-item cheats, and every one fails. - A parser fuzz run of at least 1,000,000 malformed messages causes no crash or unbounded allocation.
claude added this to the v0.5 Multiplayer milestone 2026-11-09 05:28:26 +00:00
claude added the priority/hightype/feature labels 2026-11-09 05:28:26 +00:00
claude added this to the Tidewall v1.0 project 2026-11-09 15:00:08 +00:00
eric closed this issue 2026-11-12 22:49:57 +00:00
Author
Owner

Done in 9e653f2.

Hostile client (test/server/test_hostile_client.gd): it crafts INPUT packets byte by byte, outside anything the real client sends, and pushes them through NetGame.take_input() into a real match on a real island. Every cheat fails:

  • Speed and teleport: -128 axes, sprint and jump, one tick claimed three times with different contents, the lead window filled at once, and ticks long past, 10,000 ahead and 0xFFFFFFFF. The fastest step was within sprint speed per tick. The player still moves, so the test isn't passing just because everything is refused. Commands carry no position, so a teleport can't be expressed.
  • Rapid fire: fire toggled within a packet, on every tick of the lead window, and slot swaps every tick. Shots stayed within the carbine's rate.
  • Out-of-range build: random aim, junk kind and material bytes, and maximum claimed lag. Nothing was built without materials. With materials, every placed piece was within BUILD_RANGE of the eye, and only real materials were used.
  • Duplicate items: interact, drop and build combinations, repeated ticks and out-of-range selections over 600 ticks. Every item, carried and on the ground, was conserved.
  • An INPUT with more than MAX_INPUT_COMMANDS commands is refused whole.

Fix found by the tests: a command tick far beyond the lead window used to advance NetGame's dedupe marker, so one bogus packet could lock out a player's real commands. Those ticks are now ignored.

Rate limits: messages were already bounded (32 game packets per player per poll, exact INPUT lengths, nothing on the control channel after the handshake). New: at most 32 new connections per address per 10 s, and 8 handshakes in progress per address, refused with a new REASON_BUSY that the client explains. Both are covered by UDP tests.

Fuzz: ParserFuzz mutates real messages from a bot match (snapshots, world, own, match, handshake, discovery) and adds random bytes. It feeds them to every decoder, the snapshot receiver and the list server. make fuzz with 1,000,000 messages: 0 engine errors, 2.9 KB of memory growth past warm-up (peak 37.8 MB static), nothing listed, 35 s. make check runs 20,000.

Tests: make check passes: 478 tests, self-check and smoke (p99 2.4 ms with 24 bots). The defences are written up under "Trusting nothing from clients" in ARCHITECTURE.md.

Done in 9e653f2. **Hostile client** (`test/server/test_hostile_client.gd`): it crafts INPUT packets byte by byte, outside anything the real client sends, and pushes them through `NetGame.take_input()` into a real match on a real island. Every cheat fails: - **Speed and teleport:** `-128` axes, sprint and jump, one tick claimed three times with different contents, the lead window filled at once, and ticks long past, 10,000 ahead and `0xFFFFFFFF`. The fastest step was within sprint speed per tick. The player still moves, so the test isn't passing just because everything is refused. Commands carry no position, so a teleport can't be expressed. - **Rapid fire:** fire toggled within a packet, on every tick of the lead window, and slot swaps every tick. Shots stayed within the carbine's rate. - **Out-of-range build:** random aim, junk kind and material bytes, and maximum claimed lag. Nothing was built without materials. With materials, every placed piece was within `BUILD_RANGE` of the eye, and only real materials were used. - **Duplicate items:** interact, drop and build combinations, repeated ticks and out-of-range selections over 600 ticks. Every item, carried and on the ground, was conserved. - An INPUT with more than `MAX_INPUT_COMMANDS` commands is refused whole. **Fix found by the tests:** a command tick far beyond the lead window used to advance NetGame's dedupe marker, so one bogus packet could lock out a player's real commands. Those ticks are now ignored. **Rate limits:** messages were already bounded (32 game packets per player per poll, exact INPUT lengths, nothing on the control channel after the handshake). New: at most 32 new connections per address per 10 s, and 8 handshakes in progress per address, refused with a new `REASON_BUSY` that the client explains. Both are covered by UDP tests. **Fuzz:** `ParserFuzz` mutates real messages from a bot match (snapshots, world, own, match, handshake, discovery) and adds random bytes. It feeds them to every decoder, the snapshot receiver and the list server. `make fuzz` with **1,000,000 messages**: 0 engine errors, 2.9 KB of memory growth past warm-up (peak 37.8 MB static), nothing listed, 35 s. `make check` runs 20,000. **Tests:** `make check` passes: 478 tests, self-check and smoke (p99 2.4 ms with 24 bots). The defences are written up under "Trusting nothing from clients" in ARCHITECTURE.md.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: claude/tidewall#40