fix(collab): authorize against the team session, not the build session (Closes #187) - #191
Conversation
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
94c6412
into
harsharajkumar-273:main
Closes #187
Restores real-time collaboration, which has been closing every connection since #147 merged.
Cause
buildCollaborationRoomIdcomposesteam:<code>:<path>and is the only producer of room IDs in the client. The authorization check looked that string up inbuildExecutor's map, which is keyed by 16-hex IDs fromcrypto.randomBytes(8). Ateam:string can never match, sogetSessionalways returnedundefinedand every connection closed with1008 'invalid session'— the room creator's included.isValidRoomIdonly checks type and length, so the malformed lookup wasn't caught earlier.Change
Room IDs beginning
team:resolve their code throughteamSessionStore, which is where the room's identity actually lives. Anything else falls back to the previous build-session creator check, so no other caller shape is affected.The code is taken from between the first two colons and passed through
normalizeTeamSessionCode, matching how/team-sessions/jointreats it. Verified against the cases that matter:What "authorized" means here, and why
You assigned this before answering the membership question I raised, so I looked into it:
TeamSessionhas no joiner list. It recordscode,repo,hostName,hostLogin,createdAt,updatedAt— nothing that identifies who has joined. So there is no per-user membership available to test.That leaves possession of a valid, unexpired invite code as the boundary. Restricting to
hostLogininstead would deny every invited collaborator, which defeats the purpose of a team session entirely.To be explicit about where that sits: it is weaker than per-user membership, and stronger than what existed before #147. An authenticated caller must still hold a code that resolves to a live session, so the guessed-16-hex-room-ID attack from #140 stays closed — guessing an invite code is the remaining exposure, and codes are short.
If you want a tighter check, the prerequisite is recording joiners on the team session at
/team-sessions/join. That's a schema and lifecycle change rather than a fix to this function, so I've left it out — happy to open it separately. It would also close CodeRabbit's outstanding "does not recognize authorized members" note on #147.Verification
npx tsc --noEmitclean; room-ID parsing exercised against the cases above.I could not run a live two-client collaboration session from my environment. Given this restores a broken feature rather than hardening a working one, it's worth one manual check before merging: open a team session in two browsers and confirm edits propagate. I'd rather flag that than imply I've verified it end to end.
Ordering
Touches
collaborationServer.ts, as does my open #146 branch — that one changesensureRedisSubscription, this changesattachCollaborationServer. They should merge, but worth landing one and re-checking.