[GH-ISSUE #4179] Server: one client can exhaust memory by flooding packets (unbounded per-player inbox) #1228

Closed
opened 2026-11-02 15:45:15 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @ludovic111 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4179

Originally assigned to: @ludovic111 on GitHub.

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

A single client can make a Horizon server run out of memory by sending more packets than the server handles. The other abuses tried here (teleport floods, chunk-batch-ack floods, crossing chunks at the speed limit) are already stopped or cost nothing measurable. This follows rdbt's report that one person could crash a server "by spamming chunks". It is part of the server plan (#3989) after W4.

How it was measured

  • Machine: playhorizon (Linux, 8 vCPU EPYC). Server on CPUs 0-3 only, dedicated build --profile fast --no-default-features, main + the W4 PRs.
  • Load: 20 mixed horizon-bots plus one abuser, horizon-bots --bots 1 --behaviour <abuse> (branch tools/bots-abusive-client, PR to follow), 30 s warm-up and a 60 s window. 2–3 rounds of each case, interleaved with runs that have no abuser.
  • What each run reports: MSPT from per-tick spans, TPS from game time, server RSS at the end, the abuser's fate from the server log, and the chunks the crowd received.
Abuse (one bot) Rounds MSPT avg tick_lan ms Server RSS at end Crowd chunks Abuser
none 5 32.6–41.2 5.7–6.4 932–1041 MB 27.6k–33.9k —
flood-move: 100 position packets a tick, each 64–256 blocks away 2 31.3, 41.2 5.5 965, 1029 MB 30.4k–33.6k kicked on its first tick (invalid_player_movement, a second position packet in one tick)
flood-acks: 100 ChunkBatchReceived a tick asking for 64 chunks, while exploring 2 36.9, 43.9 5.6 963, 1057 MB 28.8k–29.8k not kicked; the ack clamp holds, no gain over a normal explorer
flood-chunks: one move a tick, 9.9 blocks straight ahead (the speed limit), never waiting for chunks 3 48.4*, 30.7, 29.3 4.7–7.3 996–1050 MB 27.1k–27.9k not kicked; gets about 400 chunks, all near spawn; moves into unloaded chunks are refused
flood-packets: 1000 MovePlayerRot a tick 2 35.7, 40.8 — 1066, 1113 MB 29.7k–30.1k not kicked
flood-packets: 10 000 MovePlayerRot a tick 3 36.6–43.1 10.0–12.9 1921–2120 MB 28.5k–30.4k not kicked

* The first flood-chunks round was the one where the abuser was pulled back every tick (990 times). It is within the noise of the no-abuser runs: mob count, 460–830 at the end, drives MSPT here.

The finding: an unbounded per-player inbox

HubState::process_inbox (lan/hub.rs) handles at most 400 packets per player per tick. Anything above that waits in Guest::inbox, a VecDeque with no limit, and the network thread keeps filling it. A client sending 10 000 packets a tick adds about 9 600 a tick, so the server grows by about 16 MB a second, for as long as the connection lasts:

  • a 4 GB VPS is gone in minutes;
  • even fryedcheese's 64 GB box is gone in about an hour.

tick_lan also doubles, from about 6 ms to 10–13 ms. Part of that is probably move_queued, which scans the whole inbox. Every other player's tick pays for it.

rate-limit (vanilla's RateKickingConnection) would catch the flood, but it is off by default, as in vanilla, and hardly anyone sets it.

Plan (small PRs)

  1. horizon-bots: the four abusive behaviours, so this stays reproducible (skip-release).
  2. Cap each player's inbox: past a backlog no real client builds (several seconds of the per-tick budget), disconnect with disconnect.exceeded_packet_rate, as rate-limit does, and drop the backlog. A fresh A/B with flood-packets 10000: RSS stays flat and the abuser is gone within a second.
  3. Measure again with a costlier packet type than rotations (use-item, container clicks, command suggestions), and give those per-tick budgets if one client can still raise others' MSPT.
  4. Movement and chunk acks: no change needed by these numbers. Moves into unloaded chunks are refused, a second position packet in a tick kicks, and acks are clamped.

Clean room: black-box measurements of Horizon only. No anticheat's or other server's code was read.

Originally created by @ludovic111 on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4179 Originally assigned to: @ludovic111 on GitHub. > 🤖 Filed by Ludovic's AI agent (Claude), not by Ludovic himself. A single client can make a Horizon server run out of memory by sending more packets than the server handles. The other abuses tried here (teleport floods, chunk-batch-ack floods, crossing chunks at the speed limit) are already stopped or cost nothing measurable. This follows rdbt's report that one person could crash a server "by spamming chunks". It is part of the server plan (#3989) after W4. ## How it was measured - Machine: playhorizon (Linux, 8 vCPU EPYC). Server on CPUs 0-3 only, dedicated build `--profile fast --no-default-features`, main + the W4 PRs. - Load: 20 `mixed` horizon-bots plus one abuser, `horizon-bots --bots 1 --behaviour <abuse>` (branch `tools/bots-abusive-client`, PR to follow), 30 s warm-up and a 60 s window. 2–3 rounds of each case, interleaved with runs that have no abuser. - What each run reports: MSPT from per-tick spans, TPS from game time, server RSS at the end, the abuser's fate from the server log, and the chunks the crowd received. | Abuse (one bot) | Rounds | MSPT avg | `tick_lan` ms | Server RSS at end | Crowd chunks | Abuser | |---|---|---|---|---|---|---| | none | 5 | 32.6–41.2 | 5.7–6.4 | 932–1041 MB | 27.6k–33.9k | — | | `flood-move`: 100 position packets a tick, each 64–256 blocks away | 2 | 31.3, 41.2 | 5.5 | 965, 1029 MB | 30.4k–33.6k | kicked on its first tick (`invalid_player_movement`, a second position packet in one tick) | | `flood-acks`: 100 `ChunkBatchReceived` a tick asking for 64 chunks, while exploring | 2 | 36.9, 43.9 | 5.6 | 963, 1057 MB | 28.8k–29.8k | not kicked; the ack clamp holds, no gain over a normal explorer | | `flood-chunks`: one move a tick, 9.9 blocks straight ahead (the speed limit), never waiting for chunks | 3 | 48.4*, 30.7, 29.3 | 4.7–7.3 | 996–1050 MB | 27.1k–27.9k | not kicked; gets about 400 chunks, all near spawn; moves into unloaded chunks are refused | | `flood-packets`: 1000 `MovePlayerRot` a tick | 2 | 35.7, 40.8 | — | 1066, 1113 MB | 29.7k–30.1k | not kicked | | `flood-packets`: **10 000** `MovePlayerRot` a tick | 3 | 36.6–43.1 | **10.0–12.9** | **1921–2120 MB** | 28.5k–30.4k | not kicked | \* The first `flood-chunks` round was the one where the abuser was pulled back every tick (990 times). It is within the noise of the no-abuser runs: mob count, 460–830 at the end, drives MSPT here. ## The finding: an unbounded per-player inbox `HubState::process_inbox` (`lan/hub.rs`) handles at most 400 packets per player per tick. Anything above that waits in `Guest::inbox`, a `VecDeque` with no limit, and the network thread keeps filling it. A client sending 10 000 packets a tick adds about 9 600 a tick, so the server grows by about 16 MB a second, for as long as the connection lasts: - a 4 GB VPS is gone in minutes; - even fryedcheese's 64 GB box is gone in about an hour. `tick_lan` also doubles, from about 6 ms to 10–13 ms. Part of that is probably `move_queued`, which scans the whole inbox. Every other player's tick pays for it. `rate-limit` (vanilla's RateKickingConnection) would catch the flood, but it is off by default, as in vanilla, and hardly anyone sets it. ## Plan (small PRs) 1. horizon-bots: the four abusive behaviours, so this stays reproducible (`skip-release`). 2. Cap each player's inbox: past a backlog no real client builds (several seconds of the per-tick budget), disconnect with `disconnect.exceeded_packet_rate`, as rate-limit does, and drop the backlog. A fresh A/B with `flood-packets 10000`: RSS stays flat and the abuser is gone within a second. 3. Measure again with a costlier packet type than rotations (use-item, container clicks, command suggestions), and give those per-tick budgets if one client can still raise others' MSPT. 4. Movement and chunk acks: no change needed by these numbers. Moves into unloaded chunks are refused, a second position packet in a tick kicks, and acks are clamped. Clean room: black-box measurements of Horizon only. No anticheat's or other server's code was read.
bsakaguchi 2026-11-02 15:45:15 +07:00
  • closed this issue
  • added the
    server
    label
Author
Owner

@ludovic111 commented on GitHub (Oct 30, 2026):

/claim

<!-- gh-comment-id:6515074761 --> @ludovic111 commented on GitHub (Oct 30, 2026): /claim
Author
Owner

@ludovic111 commented on GitHub (Oct 30, 2026):

🤖 Agent: #4181 (horizon-bots behaviours) and #4185 (inbox cap: RSS under a 10 000-packet flood goes from 1937–1960 MB to 963–1039 MB, and the flooder is kicked 2 s after joining) are open.

<!-- gh-comment-id:6515293991 --> @ludovic111 commented on GitHub (Oct 30, 2026): 🤖 Agent: #4181 (horizon-bots behaviours) and #4185 (inbox cap: RSS under a 10 000-packet flood goes from 1937–1960 MB to 963–1039 MB, and the flooder is kicked 2 s after joining) are open.
Author
Owner

@ludovic111 commented on GitHub (Oct 30, 2026):

🤖 Agent: step 3, costly packets. Setup: one abuser among 20 mixed bots on playhorizon, main + #4185, 60 s window. The abuser sends 390 packets a tick (just under the 400 a tick handled) unless the table says otherwise. Behaviours from #4181 (pushed 6edf1ff46).

Flood (one bot) MSPT avg tick_lan ms RSS max Abuser Verdict
none (3 runs) 38.2–45.4 5.6–7.0 957–1043 MB — —
flood-use: place and break stone in reach 38.7 6.2 955 MB kicked in 1 s by #4185's cap (a use or dig followed by a move waits for the next tick, so the inbox fills) already stopped
flood-click: inventory clicks with a stale state 34.7 6.6 925 MB stays no effect
flood-recipe: recipe book placements 34.5 5.8 946 MB stays no effect
flood-sign: four 384-character lines 38.4 7.5 966 MB stays ("tried to change non-editable sign") no effect
flood-book: 100 pages × 1024 characters 35.6 7.8 1736 MB kicked after 8 000 packets, about 800 MB of them hole: the cap counts packets, not bytes → #4185 second commit
flood-book at 20 a tick 48.7 (725 mobs) 7.7 1056 MB stays within noise
flood-suggest at 20 a tick 40.3 8.6 961 MB stays small (+3 ms tick_lan)
flood-suggest at 100 a tick 61.6, 16.1 TPS 25.8 1012 MB stays hole: every request parsed → #4200
flood-suggest 390 --no-read 40.2 7.0 979 MB kicked by the cap —
flood-click 390 --no-read 33.7 5.8 958 MB stays replies don't pile up
idle --no-read 32.0 5.1 930 MB stays 60 s see below

Fixes, each with an A/B in its PR:

  • #4200: one suggestion answer a tick, the latest, as vanilla's ServerCommandSuggestionsProvider. With 100 requests a tick: main 17.7–17.9 TPS, MSPT 55–56, tick_lan 22.3 → 20.0 TPS, MSPT 33.5–34.6, tick_lan 5.6–6.0.
  • #4185: inbox capped in bytes too (16 MB). With 390 books a tick: RSS max 1735–1753 → 985–1081 MB.

Left as is: a client that stops reading but stays quiet is not disconnected within 60 s. Vanilla times out after 15 s without a keep-alive answer. Horizon's keep-alive lives in the writer thread, which a full socket blocks. It costs no MSPT or memory in these runs, so I'm noting it here and not fixing it now.

Back to W4 (collision shapes) after these land.

<!-- gh-comment-id:6516132919 --> @ludovic111 commented on GitHub (Oct 30, 2026): 🤖 Agent: step 3, costly packets. Setup: one abuser among 20 `mixed` bots on playhorizon, main + #4185, 60 s window. The abuser sends 390 packets a tick (just under the 400 a tick handled) unless the table says otherwise. Behaviours from #4181 (pushed 6edf1ff46). | Flood (one bot) | MSPT avg | `tick_lan` ms | RSS max | Abuser | Verdict | |---|---|---|---|---|---| | none (3 runs) | 38.2–45.4 | 5.6–7.0 | 957–1043 MB | — | — | | `flood-use`: place and break stone in reach | 38.7 | 6.2 | 955 MB | kicked in 1 s by #4185's cap (a use or dig followed by a move waits for the next tick, so the inbox fills) | already stopped | | `flood-click`: inventory clicks with a stale state | 34.7 | 6.6 | 925 MB | stays | no effect | | `flood-recipe`: recipe book placements | 34.5 | 5.8 | 946 MB | stays | no effect | | `flood-sign`: four 384-character lines | 38.4 | 7.5 | 966 MB | stays ("tried to change non-editable sign") | no effect | | `flood-book`: 100 pages × 1024 characters | 35.6 | 7.8 | **1736 MB** | kicked after 8 000 packets, about 800 MB of them | **hole: the cap counts packets, not bytes** → #4185 second commit | | `flood-book` at 20 a tick | 48.7 (725 mobs) | 7.7 | 1056 MB | stays | within noise | | `flood-suggest` at 20 a tick | 40.3 | 8.6 | 961 MB | stays | small (+3 ms `tick_lan`) | | `flood-suggest` at 100 a tick | 61.6, **16.1 TPS** | **25.8** | 1012 MB | stays | **hole: every request parsed** → #4200 | | `flood-suggest` 390 `--no-read` | 40.2 | 7.0 | 979 MB | kicked by the cap | — | | `flood-click` 390 `--no-read` | 33.7 | 5.8 | 958 MB | stays | replies don't pile up | | idle `--no-read` | 32.0 | 5.1 | 930 MB | **stays 60 s** | see below | Fixes, each with an A/B in its PR: - **#4200**: one suggestion answer a tick, the latest, as vanilla's `ServerCommandSuggestionsProvider`. With 100 requests a tick: main 17.7–17.9 TPS, MSPT 55–56, `tick_lan` 22.3 → 20.0 TPS, MSPT 33.5–34.6, `tick_lan` 5.6–6.0. - **#4185**: inbox capped in bytes too (16 MB). With 390 books a tick: RSS max 1735–1753 → 985–1081 MB. Left as is: a client that stops reading but stays quiet is not disconnected within 60 s. Vanilla times out after 15 s without a keep-alive answer. Horizon's keep-alive lives in the writer thread, which a full socket blocks. It costs no MSPT or memory in these runs, so I'm noting it here and not fixing it now. Back to W4 (collision shapes) after these land.
Author
Owner

@ludovic111 commented on GitHub (Oct 30, 2026):

🤖 Agent: correction and follow-up on non-reading clients. In my table, "idle --no-read: stays 60 s" was wrong: that client was dropped at 30 s, because its writer wasn't blocked. The real case is a client that stops reading while the server keeps writing to it. Its writer thread blocks in a write and never reaches its keep-alive check, so on main 5 such clients held their slots until they quit themselves (61 s, the end of the run). #4217 moves the timeout to the game thread and closes the socket under the blocked writer: they are dropped at 31–32 s with "Timed out", as vanilla. Memory stayed within noise.

<!-- gh-comment-id:6516703744 --> @ludovic111 commented on GitHub (Oct 30, 2026): 🤖 Agent: correction and follow-up on non-reading clients. In my table, "idle `--no-read`: stays 60 s" was wrong: that client was dropped at 30 s, because its writer wasn't blocked. The real case is a client that stops reading while the server keeps writing to it. Its writer thread blocks in a write and never reaches its keep-alive check, so on main 5 such clients held their slots until they quit themselves (61 s, the end of the run). #4217 moves the timeout to the game thread and closes the socket under the blocked writer: they are dropped at 31–32 s with "Timed out", as vanilla. Memory stayed within noise.
Author
Owner

@levzzz5154 commented on GitHub (Oct 30, 2026):

🤖 Agent: Triage by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Every step of the plan is merged: the abusive-client bots (#4181), the inbox cap in packets and bytes (#4185), one command-suggestion answer a tick (#4200) and the timeout for clients that stop reading (#4217). Reopen if a flood still takes the server down on the latest nightly.

<!-- gh-comment-id:6529350031 --> @levzzz5154 commented on GitHub (Oct 30, 2026): 🤖 Agent: Triage by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Every step of the plan is merged: the abusive-client bots (#4181), the inbox cap in packets and bytes (#4185), one command-suggestion answer a tick (#4200) and the timeout for clients that stop reading (#4217). Reopen if a flood still takes the server down on the latest nightly.
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#1228
No description provided.