feat(server): secure chat, as vanilla 26.3's server

Chat session updates with their profile key checked against the services'
keys, signed chat and the message chain, last-seen acknowledgements, the
signature cache, signed say/me/msg, enforce-secure-profile, and vanilla's
log lines. Offline servers and players without a chat session chat
unsigned, as on vanilla. tools/test_secure_chat_parity.py compares both
servers with test keys and a mock services server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-18 07:28:35 +02:00
parent 5b62d771bb
commit 454b3842bb
23 changed files with 2505 additions and 86 deletions
+3 -2
View File
@@ -20,8 +20,9 @@ plan are in [docs/server.md](https://github.com/ludovic111/horizon/blob/main/doc
Until then Horizon players can join offline servers only (`online_mode = false`). An offline server never
checks accounts: anyone who reaches it can join under any name. Keep it on your LAN or a tailnet
(Tailscale, ZeroTier), or share it only with friends you trust.
- **No secure chat.** Chat isn't signed, and `enforce-secure-profile` has no effect. Vanilla clients show
chat from the server as not secure.
- **Secure chat** works as on vanilla's server: in online mode, vanilla clients sign their chat, and with
`enforce-secure-profile=true` (the default) unsigned chat is refused. On an offline server, or for a player
without a chat session (Horizon's own client today), chat stays unsigned and shows as not secure.
- **Nether and End:** each player travels on their own through portals, and operators with `execute in
<dimension> run tp`. The players in the level they leave stop seeing them, and the ones in the level they
arrive in start to, as on vanilla (checked against vanilla with two players, by command and through an End
+2 -2
View File
@@ -82,7 +82,8 @@ not tick cost, so it is in scope here (see section 9).
| Area | Status |
|---|---|
| `online-mode=true` | **Works** (ServerLoginPacketListenerImpl): a 1024-bit RSA key pair at start ("Generating keypair"), the encryption request, the shared secret and challenge, AES/CFB8, and the session service's `hasJoined` check (with the address when `prevent-proxy-connections` is on), with vanilla's log lines and messages. `test_online_mode_parity.py` runs the same logins against vanilla's server and Horizon's with a mock session service. Not yet: secure chat (chat is unsigned, as on a server that doesn't enforce it). |
| `online-mode=true` | **Works** (ServerLoginPacketListenerImpl): a 1024-bit RSA key pair at start ("Generating keypair"), the encryption request, the shared secret and challenge, AES/CFB8, and the session service's `hasJoined` check (with the address when `prevent-proxy-connections` is on), with vanilla's log lines and messages. `test_online_mode_parity.py` runs the same logins against vanilla's server and Horizon's with a mock session service. |
| Secure chat | **Works** (`SignedMessageChain`, `LastSeenMessagesValidator`, `MessageSignatureCache`): the chat session update and its profile key, checked against the services' `playerCertificateKeys`; signed chat, `say`, `me` and `msg`, relayed with their signatures and last-seen lists; `enforce-secure-profile` (with `online-mode`) refuses unsigned chat; and vanilla's log lines (`[Not Secure]`, the decoder's warnings, the kicks). Offline servers and players without a chat session chat unsigned, as on vanilla. `test_secure_chat_parity.py` runs the same signed and unsigned players against vanilla's server and Horizon's, with test keys and a mock services server. |
| Nether and End | **Players can't change dimension.** The engine keeps one dimension loaded (`Game::enter_dimension` moves only the local single-player player), and the hub serves one `dimension` to everyone. |
| Refused logins | Logged as vanilla does: `Disconnecting <name> (/address): <reason>`, then `<name> (/address) lost connection: <reason>`, and the session errors (`Username '<name>' tried to join with an invalid session`, `Couldn't verify username because servers are unavailable`). |
| Gameplay for remote players | The LAN guest leftovers apply: an item used on a block is used twice, the recipe book doesn't work, status effects don't apply to guests, arrows don't record their owner, team friendly fire is ignored (#484). Block desync and short freezes are reported on a same-machine server (#500). |
@@ -507,7 +508,6 @@ machine, then published in `benchmarks/`; and item 5.
**Out (next):**
- secure chat on the server (online mode itself works);
- the Nether and End for remote players;
- the headless engine and its RAM win;
- a server-only prepare without a JDK;