[PR #5365] [MERGED] Anticheat: ban a player at a check's ban_after kick (combat: the second) #6241

Closed
opened 2026-11-03 06:16:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/anticheat-bans


📝 Commits (3)

  • c9ed92a Anticheat: ban at a check's ban_after kick (combat: the second)
  • 4e7e1ba Anticheat: a player already leaving counts no second strike; no ban list kicks
  • 2a25c68 Merge main into #5365

📊 Changes

8 files changed (+267 additions, -26 deletions)

View changed files

📝 crates/horizon-anticheat/src/lib.rs (+74 -9)
📝 crates/horizon-client/src/game/dedicated.rs (+49 -0)
📝 crates/horizon-client/src/game/lan.rs (+3 -0)
📝 crates/horizon-client/src/lan/anticheat.rs (+83 -9)
📝 crates/horizon-client/src/lan/hub.rs (+6 -0)
📝 crates/horizon-server/src/config.rs (+4 -2)
📝 docs/anticheat.md (+18 -4)
📝 tools/anticheat_e2e.py (+30 -2)

📄 Description

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

Fixes #5363: the anticheat's certain checks ban on a repeat, not just kick.

What changes

  • Strikes. Each player's kicks are counted per check and kept across sessions and restarts ([anticheat] strikes = "anticheat-strikes.json").
  • ban_after. Every [anticheat.<check>] table gets ban_after: the kick that reaches it bans instead. The player goes into banned-players.json through the server's normal ban list, as /ban would put them: source "Horizon anticheat", reason "Horizon anticheat: ". They are disconnected with vanilla's ban message, and a later login is refused with it.
  • Defaults. combat (attacks with no swing, two targets in one client tick, which no vanilla client sends) bans at its second kick: the first kick warns. timer, ground and prediction keep ban_after = 0 while they only log.
  • Pardon. A ban resets the count, so a player an op /pardons is kicked once before any new ban.
  • Every action is reported. Every kick and ban writes its line in logs/anticheat.log with the evidence, plus a console warning and an alert to online operators (alert_level), even with alert = 0, so luzW or bunchy7s can pardon a mistake:
    [Anticheat] NoSwing0 failed combat (VL 20.5): attacked without swinging (1 more attacks than swings in a tick), kicked (1 of 2 before a ban)
    [Anticheat] NoSwing0 failed combat (VL 20.5): attacked without swinging (1 more attacks than swings in a tick), banned
    Banned NoSwing0: Horizon anticheat: combat
    
  • Also: a fix in hub.rs's packet loop. It had two S::Attack arms: the anticheat's, and #5123's, which keeps the moves queued behind an attack for the next tick. The anticheat's arm came first, so #5123's was unreachable (an unreachable pattern warning) and #4524's fix never ran. They are one arm now, and both apply.

Per-tick cost: none. The new code runs only when a check kicks; the strikes file is read on the first kick and written on each kick.

Tests

  • horizon-anticheat: the_kick_that_reaches_ban_after_bans, covering the count, the ban, and the reset after it. lan::anticheat: the UUID format of banned-players.json.
  • tools/anticheat_e2e.py --check combat, on a real dedicated server with bots:
    • the no-swing and two-target bots are flagged, their attacks dropped, and kicked (1 of 2 before a ban);
    • they come back, cheat again and are banned: exactly 2 entries in banned-players.json, with the reason and source above;
    • a third login is refused with multiplayer.disconnect.banned.reason / "Horizon anticheat: combat";
    • the fair bot attacked 72 times and was never flagged.
    combat: the no-swing and two-target bots are flagged, their attacks dropped, and kicked; back, they cheat again and are banned, then refused; the fair bot attacked 72 times, never flagged
    

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at d6e8bd67a, 29 min 36 s)

Check Result
Scope ✅ 8 files, +239 −30
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 499 passed (4 min 25 s)
rustfmt ❌ failed (22 s): one format! line, fixed since (cargo fmt --all -- --check passes on this head)
clippy ✅ (5 min 15 s)
tests: horizon-anticheat, horizon-client, horizon-server ❌ 1423 passed, 8 failed (15 min 53 s): all 8 in lan_bot, and the same 8 fail on main d6e8bd67a without this PR (#5364, fixed by its own PR). With that fix applied here, lan_bot passes 14/14
doc tests ✅ 0 passed (1 min 8 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 ➖ 37 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, held_item_stack, lan_auth and 25 more

Clean-room: vanilla 26.3 only (UserBanList, ServerGamePacketListenerImpl), no other project's code.

🤖 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/5365 **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:** `feat/anticheat-bans` --- ### 📝 Commits (3) - [`c9ed92a`](https://github.com/horizon-rust/horizon/commit/c9ed92a2a927657da2d55885d6380d94ac7d4ecf) Anticheat: ban at a check's ban_after kick (combat: the second) - [`4e7e1ba`](https://github.com/horizon-rust/horizon/commit/4e7e1ba84a27b62ba1f9fd36f93fa4933114441d) Anticheat: a player already leaving counts no second strike; no ban list kicks - [`2a25c68`](https://github.com/horizon-rust/horizon/commit/2a25c6815951b88c97578027386cec60d0458b09) Merge main into #5365 ### 📊 Changes **8 files changed** (+267 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-anticheat/src/lib.rs` (+74 -9) 📝 `crates/horizon-client/src/game/dedicated.rs` (+49 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+3 -0) 📝 `crates/horizon-client/src/lan/anticheat.rs` (+83 -9) 📝 `crates/horizon-client/src/lan/hub.rs` (+6 -0) 📝 `crates/horizon-server/src/config.rs` (+4 -2) 📝 `docs/anticheat.md` (+18 -4) 📝 `tools/anticheat_e2e.py` (+30 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #5363: the anticheat's certain checks ban on a repeat, not just kick. ## What changes - **Strikes.** Each player's kicks are counted per check and kept across sessions and restarts (`[anticheat] strikes = "anticheat-strikes.json"`). - **`ban_after`.** Every `[anticheat.<check>]` table gets `ban_after`: the kick that reaches it bans instead. The player goes into `banned-players.json` through the server's normal ban list, as `/ban` would put them: source "Horizon anticheat", reason "Horizon anticheat: <check>". They are disconnected with vanilla's ban message, and a later login is refused with it. - **Defaults.** `combat` (attacks with no swing, two targets in one client tick, which no vanilla client sends) bans at its **second** kick: the first kick warns. `timer`, `ground` and `prediction` keep `ban_after = 0` while they only log. - **Pardon.** A ban resets the count, so a player an op `/pardon`s is kicked once before any new ban. - **Every action is reported.** Every kick and ban writes its line in `logs/anticheat.log` with the evidence, plus a console warning and an alert to online operators (`alert_level`), even with `alert = 0`, so luzW or bunchy7s can pardon a mistake: ``` [Anticheat] NoSwing0 failed combat (VL 20.5): attacked without swinging (1 more attacks than swings in a tick), kicked (1 of 2 before a ban) [Anticheat] NoSwing0 failed combat (VL 20.5): attacked without swinging (1 more attacks than swings in a tick), banned Banned NoSwing0: Horizon anticheat: combat ``` - **Also: a fix in `hub.rs`'s packet loop.** It had two `S::Attack` arms: the anticheat's, and #5123's, which keeps the moves queued behind an attack for the next tick. The anticheat's arm came first, so #5123's was unreachable (an `unreachable pattern` warning) and #4524's fix never ran. They are one arm now, and both apply. Per-tick cost: none. The new code runs only when a check kicks; the strikes file is read on the first kick and written on each kick. ## Tests - `horizon-anticheat`: `the_kick_that_reaches_ban_after_bans`, covering the count, the ban, and the reset after it. `lan::anticheat`: the UUID format of `banned-players.json`. - `tools/anticheat_e2e.py --check combat`, on a real dedicated server with bots: - the no-swing and two-target bots are flagged, their attacks dropped, and kicked (`1 of 2 before a ban`); - they come back, cheat again and are banned: exactly 2 entries in `banned-players.json`, with the reason and source above; - a third login is refused with `multiplayer.disconnect.banned.reason` / "Horizon anticheat: combat"; - the fair bot attacked 72 times and was never flagged. ``` combat: the no-swing and two-target bots are flagged, their attacks dropped, and kicked; back, they cheat again and are banned, then refused; the fair bot attacked 72 times, never flagged ``` **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at d6e8bd67a, 29 min 36 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +239 −30 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 499 passed (4 min 25 s) | | rustfmt | ❌ failed (22 s): one `format!` line, fixed since (`cargo fmt --all -- --check` passes on this head) | | clippy | ✅ (5 min 15 s) | | tests: horizon-anticheat, horizon-client, horizon-server | ❌ 1423 passed, 8 failed (15 min 53 s): all 8 in `lan_bot`, and the same 8 fail on main d6e8bd67a without this PR (#5364, fixed by its own PR). With that fix applied here, `lan_bot` passes 14/14 | | doc tests | ✅ 0 passed (1 min 8 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 | ➖ 37 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, held_item_stack, lan_auth and 25 more | Clean-room: vanilla 26.3 only (`UserBanList`, `ServerGamePacketListenerImpl`), no other project's code. 🤖 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 06:16:14 +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#6241
No description provided.