fix(dig-node): gate chat.send + chat.poll behind the control token - #168
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
F1 (#1946): chat.send seals + BLS-signs a directed message as the node's own 0x0010 identity, and chat.poll drains the inbound inbox. Both previously classified as WalletMethodClass::Other and routed through the ungated local plane, so any local process could seal/send as the node or steal/delete another app's queued ciphertext. Gate both behind the master/paired control token on BOTH transports (HTTP POST and the /ws request plane), mirroring cache.fetchAndCache and control.* mutations. An unauthorized caller gets -32030 UNAUTHORIZED before any seal/send or inbox drain runs. Fail-closed on an empty master token. Updates SPEC §5.5.2 with the authz contract. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes dig_ecosystem#1946. Security follow-up F1 from the Lane B pre-merge audit (dig-node#133).
Why
chat.sendandchat.pollclassified as ungatedWalletMethodClass::Other, routing through the ungated local plane — so ANY local process (not just the paired chat app) could invoke them:chat.sendmakes the node seal + BLS-sign a message as its own0x0010identity to an arbitrary recipient — it wields the node's cryptographic identity (comparable to the token-gatedcontrol.*mutations).chat.pollDRAINS (deletes) the inbound inbox — once the live receive path (#1947) lands, an unauthorized local process could steal/delete another app's queued ciphertext.Bounded today (opaque app-supplied payload, attacker lacks the inner DIGCHAT1 key, loopback-bound, pre-release) — so it wasn't a #133 blocker, but it's the ranked-#1 non-gating follow-up and must land before the chat app is in real use.
What changed
control.*/cache.fetchAndCache— a newis_gated_chat_method+chat_call_authorized(server.rs:~1108) requiring the master control token OR a valid paired controller token (control::ct_eq+pairing::is_paired_token), fail-closed on an empty master (the CSPRNG-failure sentinel, mirroring #2032). An unauthorized caller gets-32030 UNAUTHORIZEDbefore any dispatch — no seal/send, no inbox drain.POST /(rpchandler, before the passthrough-relay dispatch) — the live path: chat is dispatched only viahandle_rpcfrom the HTTP path today./ws(ws_dispatch, before the wallet fallthrough) — chat is HTTP-only today (ws_dispatchdoesn't reachhandle_rpc), so this is bypass-proof defense-in-depth: if #793 later wires chat onto/ws, the gate is already in place.control.*/cache.fetchAndCacherisk class — chat now mirrors that master-or-paired policy.How verified (TDD)
chat_methods_over_http_require_the_control_token(integration) — for bothchat.send+chat.poll: untokened →-32030 UNAUTHORIZEDwith noresult(proves no side effect ran before the gate); wrong token → rejected; master token → clears the gate.chat_gate_classifies_and_authorizes_like_a_control_mutation(unit) — only chat.send/poll gated; no/wrong token denied; master/paired allowed; empty-master fail-closed.cargo fmt0,clippy -p dig-node-service -D warningsclean,buildok, targeted tests pass. (The ~9 socket-bind sandbox failures are the known caveat; the new tests aren't among them.)SPEC
Root
SPEC.md§5.5.2 updated (the service's normative contract is the root SPEC — there is nocrates/dig-node-service/SPEC.md): chat.send/chat.poll are control-token-gated on both transports,-32030before any side effect.Version
root
[workspace.package].version0.92.0 → 0.93.0 (dig-node-serviceinherits viaversion.workspace = true);Cargo.lockregenerated (dig-node-service=0.93.0). Minor (security behaviour change).Notes for the gate
result(matching the repo'scache.fetchAndCachegate-test pattern); the inboxdrain()count isn't asserted directly (needs deeper node access).Refs #133 (F1), #1947 (the live-receive path this lands ahead of), #2032 (the CSPRNG/empty-token control-plane work this mirrors).
Generated by Claude Code