[PR #4377] [MERGED] Chat on servers that enforce secure chat: the client signs its chat and /msg #5592

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

📋 Pull Request Information

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

Base: main ← Head: secure-chat-v2/3-client


📝 Commits (10+)

  • 06f55b4 Secure chat: the client's signing (RSA private keys, the message chain encoder, the last-seen tracker)
  • 8f843ab Secure chat: the account's chat key pair, and the command arguments a client signs
  • eaf1507 Secure chat on a server's client: chat session, signed chat and commands
  • 7e8b9c1 Merge main: SignatureCache::unpack is #4214's
  • 98dfd26 Merge the signing branch and main: the chat keys start where the session now loads
  • 0d2cb92 Merge the chat key branch and main: one signature cache, messages marked when the chat takes them
  • 43a2732 Merge remote-tracking branch 'hr/main' into fix/pr-4375
  • 1ba7b1a Merge remote-tracking branch 'hr/main' into fix/pr-4376
  • 65b1d9a Merge branch 'fix/pr-4375' into fix/pr-4376
  • 5c1d6be Merge remote-tracking branch 'hr/main' into fix/pr-4377

📊 Changes

21 files changed (+1458 additions, -108 deletions)

View changed files

📝 crates/horizon-client-render/src/auth.rs (+284 -0)
📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/chat.rs (+1 -1)
📝 crates/horizon-client/src/game/dialogs.rs (+1 -2)
📝 crates/horizon-client/src/game/lan_chat.rs (+3 -20)
📝 crates/horizon-client/src/game/net_harness.rs (+22 -8)
📝 crates/horizon-client/src/game/remote.rs (+38 -29)
➕ crates/horizon-client/src/game/remote_chat.rs (+284 -0)
📝 crates/horizon-command/src/lib.rs (+22 -0)
📝 crates/horizon-command/src/network.rs (+45 -0)
📝 crates/horizon-protocol/src/rsa.rs (+153 -15)
📝 crates/horizon-protocol/src/secure_chat.rs (+268 -1)
📝 docs/microsoft-account.md (+22 -10)
📝 tools/port_map/client-001.tsv (+7 -7)
📝 tools/port_map/client-002.tsv (+5 -5)
📝 tools/port_map/client-003.tsv (+1 -1)
📝 tools/port_map/rest-005.tsv (+1 -1)
📝 tools/port_map/rest-011.tsv (+6 -6)
📝 tools/port_map/rest-021.tsv (+1 -1)
📝 tools/port_map/rest-022.tsv (+1 -1)

...and 1 more files

📄 Description

🤖 Opened by 4404c's AI agent (Claude Code), not by 4404c themself.

What and why

Players signed in with a Microsoft account can chat and use /msg on online servers with enforce-secure-profile=true (26.3's default), where every message was refused with "Chat disabled due to missing profile public key". This covers the LocalChatSession.createMessageEncoder, SignedMessageChain.encoder, ClientPacketListener.setKeyPair and ClientPacketListener.sendCommand rows of #3520 and #3518.

Depends on #4375 and #4376: review this PR's own diff.

game/remote_chat.rs (ClientPacketListener):

  • setKeyPair: after each login packet, and when the pair is renewed, a new chat session goes to the server, only when the server plays the account under its own profile id (isLocalPlayer). An offline-mode server's offline id gets none, so chat stays unsigned there.
  • sendChat / sendCommand: the chat and each message argument of a command (over the server's tree) are signed with the same time, salt and last seen, one chain link each.
  • markMessageAsProcessed / sendChatAcknowledgement: where the chat takes a signed message, past any Chat Delay, with whether it was shown, and a ChatAck once more than 64 messages wait.
  • handleDeleteChat: a deleted message still pending is not acknowledged (ignorePending).
  • sendUnattendedCommand: a clicked chat line and a dialog's button stay unsigned. Vanilla asks the player before signing one; without that screen, a server could otherwise have the player sign a message they never saw.

The signature cache and its unpacking are #4214's, unchanged; handleLogin now also starts a new cache.

Vanilla reference

ClientPacketListener (setKeyPair, sendChat, sendCommand, sendUnattendedCommand, markMessageAsProcessed, sendChatAcknowledgement, handlePlayerChat), ArgumentSignatures.signCommand. Port ledger rows updated.

New tools/secure_chat_client_e2e.py: vanilla 26.3's dedicated server and a mock of the services that issues certificates, with Horizon's headless client:

  • online with enforce-secure-profile=true: the server logs the chat as secure (no [Not Secure]), a /msg to itself arrives, nothing is refused;
  • offline: no session, the same chat goes unsigned ([Not Secure]).

Both pass at 0d2cb928b on Windows. 4404c, a human, also tested it by hand with a real Microsoft account on an online server. Over an earlier main, before the merge with #4214: chat and /msg work where they were refused. Again with this stack's final changes applied to nightly 1da354b: chat works.

Not in this PR: checking other players' signatures (no Not Secure marking), the signing confirmation screen for clicked commands, and renewing the access token itself (a very long session can't renew its key pair until the next start from the launcher). The RSA signing is not constant-time.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main; the scope includes #4375 and #4376, measured before main was merged in. This branch over the second is now 11 files, +565 −49, of which 286 are the harness. At 0d2cb928b: rustfmt, clippy and the tests rerun by hand with the same single failure below)

Check Result
Scope ⚠️ 20 files, +1376 −99 (with #4375 and #4376)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 480 run, 1 error (see below)
rustfmt ✅
clippy ✅
tests: horizon-client, horizon-client-render, horizon-command, horizon-protocol ❌ 1 failed (see below), everything else passes
doc tests ✅ 0 passed
Parity ➖ not run (--quick)

Run on Windows, before merging main again at 0d2cb928b. Two failures there are not from this change: test_perf_bench...test_report_without_a_load_average (cmd /C ver in tools/perf_bench.py) and, in horizon-client, title::tests::each_world_preset_writes_its_own_generator (it makes a folder named minecraft:normal, which Windows refuses). Parity not run: it is left to CI.

🤖 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/4377 **Author:** [@4404c](https://github.com/4404c) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `secure-chat-v2/3-client` --- ### 📝 Commits (10+) - [`06f55b4`](https://github.com/horizon-rust/horizon/commit/06f55b418d00a323d1983c841ce4c74ec9322edf) Secure chat: the client's signing (RSA private keys, the message chain encoder, the last-seen tracker) - [`8f843ab`](https://github.com/horizon-rust/horizon/commit/8f843abb92f44fbe08be6e317fb9c37ed978953d) Secure chat: the account's chat key pair, and the command arguments a client signs - [`eaf1507`](https://github.com/horizon-rust/horizon/commit/eaf150712dd25cb829ff2c6b494e273c06ae7a24) Secure chat on a server's client: chat session, signed chat and commands - [`7e8b9c1`](https://github.com/horizon-rust/horizon/commit/7e8b9c11548a83f6e7126038e395fef518eb1631) Merge main: SignatureCache::unpack is #4214's - [`98dfd26`](https://github.com/horizon-rust/horizon/commit/98dfd26b6754478e847e2d07cb3cda62ad666129) Merge the signing branch and main: the chat keys start where the session now loads - [`0d2cb92`](https://github.com/horizon-rust/horizon/commit/0d2cb928ba346cfbebfcb8533cdbe3fc4c141adc) Merge the chat key branch and main: one signature cache, messages marked when the chat takes them - [`43a2732`](https://github.com/horizon-rust/horizon/commit/43a273225032c8d2efa4b18081e88c4e27cc8e91) Merge remote-tracking branch 'hr/main' into fix/pr-4375 - [`1ba7b1a`](https://github.com/horizon-rust/horizon/commit/1ba7b1a3dc224122f53902c3436fe1e062421428) Merge remote-tracking branch 'hr/main' into fix/pr-4376 - [`65b1d9a`](https://github.com/horizon-rust/horizon/commit/65b1d9a122a12017353418f71e86d7d15a30eb59) Merge branch 'fix/pr-4375' into fix/pr-4376 - [`5c1d6be`](https://github.com/horizon-rust/horizon/commit/5c1d6be44cb79f8c22e1742eadba7dc47e5ad817) Merge remote-tracking branch 'hr/main' into fix/pr-4377 ### 📊 Changes **21 files changed** (+1458 additions, -108 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/auth.rs` (+284 -0) 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+1 -1) 📝 `crates/horizon-client/src/game/dialogs.rs` (+1 -2) 📝 `crates/horizon-client/src/game/lan_chat.rs` (+3 -20) 📝 `crates/horizon-client/src/game/net_harness.rs` (+22 -8) 📝 `crates/horizon-client/src/game/remote.rs` (+38 -29) ➕ `crates/horizon-client/src/game/remote_chat.rs` (+284 -0) 📝 `crates/horizon-command/src/lib.rs` (+22 -0) 📝 `crates/horizon-command/src/network.rs` (+45 -0) 📝 `crates/horizon-protocol/src/rsa.rs` (+153 -15) 📝 `crates/horizon-protocol/src/secure_chat.rs` (+268 -1) 📝 `docs/microsoft-account.md` (+22 -10) 📝 `tools/port_map/client-001.tsv` (+7 -7) 📝 `tools/port_map/client-002.tsv` (+5 -5) 📝 `tools/port_map/client-003.tsv` (+1 -1) 📝 `tools/port_map/rest-005.tsv` (+1 -1) 📝 `tools/port_map/rest-011.tsv` (+6 -6) 📝 `tools/port_map/rest-021.tsv` (+1 -1) 📝 `tools/port_map/rest-022.tsv` (+1 -1) _...and 1 more files_ </details> ### 📄 Description > 🤖 Opened by 4404c's AI agent (Claude Code), not by 4404c themself. ## What and why Players signed in with a Microsoft account can chat and use `/msg` on online servers with `enforce-secure-profile=true` (26.3's default), where every message was refused with "Chat disabled due to missing profile public key". This covers the `LocalChatSession.createMessageEncoder`, `SignedMessageChain.encoder`, `ClientPacketListener.setKeyPair` and `ClientPacketListener.sendCommand` rows of #3520 and #3518. **Depends on #4375 and #4376**: review [this PR's own diff](https://github.com/4404c/horizon/compare/secure-chat-v2/2-chat-keys...secure-chat-v2/3-client). `game/remote_chat.rs` (`ClientPacketListener`): - `setKeyPair`: after each login packet, and when the pair is renewed, a new chat session goes to the server, only when the server plays the account under its own profile id (`isLocalPlayer`). An offline-mode server's offline id gets none, so chat stays unsigned there. - `sendChat` / `sendCommand`: the chat and each message argument of a command (over the server's tree) are signed with the same time, salt and last seen, one chain link each. - `markMessageAsProcessed` / `sendChatAcknowledgement`: where the chat takes a signed message, past any Chat Delay, with whether it was shown, and a `ChatAck` once more than 64 messages wait. - `handleDeleteChat`: a deleted message still pending is not acknowledged (`ignorePending`). - `sendUnattendedCommand`: a clicked chat line and a dialog's button stay unsigned. Vanilla asks the player before signing one; without that screen, a server could otherwise have the player sign a message they never saw. The signature cache and its unpacking are #4214's, unchanged; `handleLogin` now also starts a new cache. ## Vanilla reference `ClientPacketListener` (`setKeyPair`, `sendChat`, `sendCommand`, `sendUnattendedCommand`, `markMessageAsProcessed`, `sendChatAcknowledgement`, `handlePlayerChat`), `ArgumentSignatures.signCommand`. Port ledger rows updated. New `tools/secure_chat_client_e2e.py`: vanilla 26.3's dedicated server and a mock of the services that issues certificates, with Horizon's headless client: - online with `enforce-secure-profile=true`: the server logs the chat as secure (no `[Not Secure]`), a `/msg` to itself arrives, nothing is refused; - offline: no session, the same chat goes unsigned (`[Not Secure]`). Both pass at 0d2cb928b on Windows. 4404c, a human, also tested it by hand with a real Microsoft account on an online server. Over an earlier main, before the merge with #4214: chat and `/msg` work where they were refused. Again with this stack's final changes applied to nightly 1da354b: chat works. Not in this PR: checking other players' signatures (no Not Secure marking), the signing confirmation screen for clicked commands, and renewing the access token itself (a very long session can't renew its key pair until the next start from the launcher). The RSA signing is not constant-time. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main`; the scope includes #4375 and #4376, measured before main was merged in. This branch over the second is now 11 files, +565 −49, of which 286 are the harness. At 0d2cb928b: rustfmt, clippy and the tests rerun by hand with the same single failure below) | Check | Result | | --- | --- | | Scope | ⚠️ 20 files, +1376 −99 (with #4375 and #4376) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 480 run, 1 error (see below) | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-render, horizon-command, horizon-protocol | ❌ 1 failed (see below), everything else passes | | doc tests | ✅ 0 passed | | Parity | ➖ not run (--quick) | Run on Windows, before merging main again at 0d2cb928b. Two failures there are not from this change: `test_perf_bench...test_report_without_a_load_average` (`cmd /C ver` in `tools/perf_bench.py`) and, in horizon-client, `title::tests::each_world_preset_writes_its_own_generator` (it makes a folder named `minecraft:normal`, which Windows refuses). Parity not run: it is left to CI. 🤖 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:13:37 +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#5592
No description provided.