fix(eventstream): add TopicPolicy interface for subscription authorization (PILOT-251)#29
Merged
Merged
Conversation
…ation (PILOT-251) Introduce a TopicPolicy interface that gates topic subscription in the eventstream broker's handleConn path. Before this change, any peer that completed L6 key exchange could subscribe to any topic — no access control existed (SECURITY_PLAN AI-016). Changes: - Add TopicPolicy interface with AllowSubscribe(remoteAddr, topic) - Default policy (defaultAllowPolicy) permits all subscriptions, preserving backward compatibility for existing deployments - Broker holds the policy and checks it before addSub; denied subscriptions log a warning and publish pubsub.subscribe_denied bus event - Service exports SetTopicPolicy(p) so daemon-level callers can install restricted policies when topic-level access control is required - Tests for both allowed and denied subscription paths Closes PILOT-251
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
All checks green, no branch protection requiring review on this repo. Waiting for human approval (comment |
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.
What changed
Added a
TopicPolicyinterface that gates topic subscription in the eventstream broker'shandleConnpath. Before this change, any peer that completed L6 key exchange could subscribe toanytopic — no access control existed (SECURITY_PLAN AI-016).Why
The bug.
broker.handleConn(service.go:217-244) reads the first frame as a subscribe envelope and adds the connection to whatever topic it names with no authorization check. Any Pilot peer can subscribe to any topic, including private/encrypted topics whose metadata reveals who publishes.The fix
TopicPolicyinterface withAllowSubscribe(remoteAddr Addr, topic string) booldefaultAllowPolicypermits all subscriptions (backward compatible, no behavioral change for existing deployments)topicPolicy.AllowSubscribebeforeaddSub; denied subscriptions log a warning at WARN level and publishpubsub.subscribe_deniedbus event for observabilityService.SetTopicPolicy(p)so daemon-level callers can install a restricted policy when topic-level access control is requiredVerification
go build ./...✓go vet ./...✓go test ./...✓ (all existing tests pass, new tests pass)PR checklists
service.gohas functional changes; tests are mechanical `newBroker> signature updates + 2 new test functions.github/workflows/,go.mod,package.json,Dockerfilechangespaths_deniedpaths touchedCloses PILOT-251