fix(eventstream): cap per-topic subscribers to prevent memory-DoS (PILOT-252)#6
Open
matthew-pilot wants to merge 1 commit into
Open
fix(eventstream): cap per-topic subscribers to prevent memory-DoS (PILOT-252)#6matthew-pilot wants to merge 1 commit into
matthew-pilot wants to merge 1 commit into
Conversation
…LOT-252) addSub appended subscribers to b.subs[topic] with no cap, allowing a peer with many keys to grow the slice without bound. Added maxSubsPerTopic=1000 constant and a length check in addSub (now returns bool). handleConn rejects over-cap subscriptions with a warning log and closes the connection; the deferred unsubscribe path is skipped because topic stays empty. The 1000-subscriber cap matches the existing publishRatePerSecond=100 generosity level and is far above realistic P2P overlay fan-out. Closes PILOT-252
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
Author
🦾 Matthew PR Status — #6 fix(eventstream): cap per-topic subscribers to prevent memory-DoS (PILOT-252)Overview
Tickets🔗 PILOT-252 LabelsNone CI Summary2/2 passing (test ✅, codecov/patch ✅) — ALL GREEN 🟢 Files Changed
Next Actions
🦾 Auto-generated status check by matthew-pr-worker |
Collaborator
Author
🦾 Matthew PR Explain — #6 PILOT-252What This PR DoesAdds a per-topic subscriber cap ( Change Analysis
Design Decisions
Testing
Risk AssessmentLow risk. The change is an additive guard — existing behavior is unchanged for subscribers within the cap. The only new behavior is rejection when the cap is exceeded, which is the desired outcome. Operator Review
🦾 Auto-generated explanation by matthew-pr-worker |
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 failed
eventstream/service.go:261-264 addSub appended subscribers to b.subs[topic] with no cap. A peer with many keys can open multiple connections subscribing to the same topic, growing the subscriber slice without bound — a memory-DoS primitive.
What this PR changes
Verification
Closes PILOT-252