Validate WebSocket subscribe payloads and cap rooms per client
Maintainers usually reply within 1 day
@0xMegie is already working on this.
Since Sep 26, 2026.
Assessment
This issue has not been assessed yet.
Description
Description
Builds on #32 and #165. MilestoneNotificationsGateway (backend/src/milestone-notifications/milestone-notifications.gateway.ts) is a Socket.IO gateway; clients join and leave gig:<id> rooms. The premise that connections leak on disconnect is not supported by the code: the gateway keeps no per-client state of its own (no maps, listeners or timers), and Socket.IO removes a disconnected socket from all of its rooms automatically, so handleDisconnect only needs to log.
What is genuinely unbounded is what a single connection may do before it disconnects:
subscribe:gigcallsclient.join(gig:${data.gigId})with no validation ofdata(a missing payload throws aTypeError), no format check ongigId, and no limit on how many rooms one socket can join. A client can create arbitrarily many, arbitrarily named rooms, growing server memory for as long as the connection is open.- The handshake is unauthenticated (no JWT check) and there is no cap on concurrent connections, so the above is available to anyone.
- There is no visibility into open connections or room counts, so any real growth could not be spotted.
(Separately, nothing in the app currently calls emitMilestoneUpdate / emitDeliverableUploaded, and nothing subscribes to the outbox trustflow:events:gateway Redis channel; that wiring is out of scope here.)
Component
Backend
Difficulty
🟡 Medium
Tasks
- Validate the
subscribe:gig/unsubscribe:gigpayload (gigIdpresent, matches the gig id format, length-limited) and return an error ack instead of throwing - Cap the number of rooms a socket may join (configurable) and reject beyond it
- Decide whether subscriptions need JWT authentication at handshake; if so, implement it with the existing
JwtAuthGuard/AuthService.validateToken - Track connection count and rooms per gateway (log line or metric) and log disconnect reason
- Unit tests for invalid payloads, room cap and disconnect behaviour
Acceptance Criteria
- A single client cannot join unbounded or malformed rooms
- Malformed subscribe payloads return an error response and never throw
- Connection and room counts are observable
- Covered by a gateway spec (there is none today)
Estimated Time
1-2 days
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 58
- Avg merge
- 3h 5m
- Merged PRs (30d)
- 44
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from trustflow-protocol/trustflow-backend
-
backend bug difficulty: medium priority: medium reliability
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
trustflow-protocol/trustflow-backend#730 ·
Maintainers usually reply within 1 day
-
backend bug difficulty: medium priority: high security
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
trustflow-protocol/trustflow-backend#728 ·
Maintainers usually reply within 1 day
-
backend bug difficulty: medium priority: medium testing
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
trustflow-protocol/trustflow-backend#727 ·
Maintainers usually reply within 1 day
-
backend bug difficulty: easy good first issue priority: medium
Difficulty 1/5 Under an hour Newbie friendliness 92/100
trustflow-protocol/trustflow-backend#726 ·
Maintainers usually reply within 1 day
-
backend bug difficulty: easy good first issue priority: medium
Difficulty 1/5 Under an hour Newbie friendliness 90/100
trustflow-protocol/trustflow-backend#725 ·
Maintainers usually reply within 1 day
All issues in trustflow-protocol/trustflow-backend
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
umami-software/umami#4637 ·
Maintainers usually reply within 3 days
-
Hotkeys fire when pressed with the Ctrl key, so browser shortcuts also trigger player actionsPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
muxinc/media-chrome#1332 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
polarsource/polar#15580 ·
Maintainers usually reply within 1 day
-
accepted bug via-triage
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
pingdotgg/t3code#20931 · 1 comment ·
Maintainers usually reply within 1 day
-
bug/1-unconfirmed kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day