fix(eventstream): gate subscription on TrustChecker (PILOT-251)#5
fix(eventstream): gate subscription on TrustChecker (PILOT-251)#5matthew-pilot wants to merge 1 commit into
Conversation
handleConn previously added any connecting peer to the requested topic map without authorization. Any peer that completed L6 key exchange (no pre-trust required) could subscribe to any topic, leaking metadata and unencrypted content. Fix: after reading the subscribe envelope, check the peer against the TrustChecker (optional Deps field). If the checker is present and the peer is not trusted, reject the subscription. If no TrustChecker is loaded, deny by default (fail-closed) — a missing trust subsystem is an unusual state and the security-safe default is to reject. This mirrors the registryBound gate pattern from the handshake plugin (PILOT-228, handshake/handshake.go:603/630): trust must be established before automatic access grants. Closes PILOT-251
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🦾 Matthew PR Check — #5 PILOT-251Status
What this doesGates VerdictCLEAN — all CI green, mergeable, small focused change. |
🛠️ Matthew PR Check — #5 PILOT-251State: OPEN · MERGEABLE Verdict: CLEAN — all CI green, 106 additions / 20 deletions across 5 files. TrustChecker gate is fail-closed by default (deny if no checker loaded), with a new dedicated rejection-path test. No merge conflicts. |
🧬 Matthew Explains — #5 PILOT-251What this doesAny peer that completes L6 key exchange (no pre-trust required) can connect to port 1002. Before this fix, added the peer to the subscription map unconditionally — anyone could subscribe to any topic (metadata leak + content exposure for unencrypted topics). This gates subscription behind . File-by-file
|
🧬 Matthew Explains — #5 PILOT-251What this doesAny peer that completes L6 key exchange (no pre-trust required) can connect to port 1002. Before this fix, File-by-file
|
What failed
handleConninservice.goadded any connecting peer to the requested topic map without authorization. Any peer that completed the L6 key exchange (no pre-trust required) could connect to port 1002 and subscribe to any topic, leaking metadata and unencrypted content.What this changes
After reading the subscribe envelope,
handleConnnow checks the peer against the TrustChecker (optionalDeps.Trust). If the checker is present and the peer is not trusted, the subscription is rejected. If no TrustChecker is loaded, subscription is denied by default (fail-closed) — a missing trust subsystem is an unusual state, and the security-safe default is to reject.Verification
go build ./...✅go vet ./...✅go test ./... -count=1✅ (20+ tests pass)TestBroker_HandleConn_SubscriptionRejectedByTrustGatecovers the trust rejection pathhandleConntests pass with an allow-all stub TrustCheckerScope
Closes PILOT-251