Repository navigation
Close a stored XSS and four cross-team realtime leaks - #114
Conversation
From an adversarial review of main. Every finding below was reproduced before it was fixed. Stored XSS in the doc renderer. renderMarkdownWithHeadingIds sanitized first and then re-opened the result with a regex to splice in an anchor id. The attribute chunk was captured with [^>]*, which stops at the first bracket, and the sanitizer legitimately keeps attribute values containing one, because that is spec legal HTML. So a heading written as <h1 title="a><img src=x onerror=...>"> had the id spliced into the middle of its own title value, closing the quote early and handing the browser a live img element. There is no CSP, so that ran as the viewer. The pattern now understands quoted values, and the result is sanitized again afterwards rather than trusted, with id allowed only on headings. Four publishers attached an org scope to rows that are not org wide. The hub authorizes an org scope on membership alone, and every browser subscribes to it, so anyone in the workspace received them: - completeCycle sent every rolled over issue, title and description included, to the whole org rather than the owning team. Sprint completion is routine and cycle:manage is a member permission, so a full sprint of another team's work leaked on each close. - removeMember did the same for every reassigned issue. - markAttachmentReady and the presign route announced every upload with its file name, size and storage key, including uploads onto private docs and onto other teams' issues. All four now use the same scopes the rest of the code already uses. The catch up path had these right, which is what showed they were bugs: only the live publish skipped the gate. A live socket also never re-read membership or role. A person removed from a team kept receiving that team's deltas until they disconnected, and an admin demoted to guest kept role admin on the connection, which short circuits scope authorization, so they could subscribe to anything in the org afterwards. The hub now refreshes the principal on a team_member or member change and drops every scope that no longer authorizes, failing closed if the refresh throws.
There was a problem hiding this comment.
imshashank has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 28 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Findings from an adversarial security review of
main. Each was reproduced against the real stack before being fixed.Stored XSS in the doc renderer
renderMarkdownWithHeadingIdssanitized the markdown and then re-opened the sanitized HTML with a regex to splice in an anchor id:[^>]*stops at the first bracket, and the sanitizer legitimately keeps attribute values that contain one, because that is spec-legal HTML and neither serializer escapes it. So stored content of the formsurvives sanitization as one inert
h1, and then the splice putsid="..."in the middle of thetitlevalue, closing the quote early. The browser then sees a real<img>with a liveonerror. There is no Content-Security-Policy on the app, so it executes as whoever opened the doc, in the app origin. Any member withdoc:writecould plant it.Three changes, each sufficient on its own, kept together as layers: the pattern now understands quoted attribute values, the spliced result is sanitized again rather than trusted, and
idis allowed only on heading elements so the second pass cannot be used to smuggle one onto anything else.Four publishers attached an org scope to rows that are not org-wide
The hub authorizes an
org:scope on organization membership alone, with no role or team test, and every signed-in browser subscribes to it. So an org scope means "everyone in the workspace".completeCycleremoveMembermarkAttachmentReady/api/attachments/presignThe sprint case is the worst of them: completing a sprint is routine,
cycle:manageis a member permission rather than an admin one, and every unfinished issue rolls over, so a full sprint of another team's work went out on each close.All four now use the scopes the rest of the codebase already uses (
issueScopes, and a newattachmentScopesthat derives from the parent rather than the organization). The catch-up path had every one of these right, filtering throughvisibleToPrincipalandreadableDocIds, which is what shows these were bugs rather than intent: only the live publish path skipped the gate.A live socket never re-read membership or role
ConnectionPrincipal.teamIdsand.rolewere captured once at authentication and never refreshed.revalidateAffectedreturned early for everything except amemberdelete.Two consequences. Someone removed from a team kept receiving that team's issue, comment and reaction deltas for as long as they left the tab open. And an admin demoted to guest kept
role: 'admin'on the connection, which short-circuits scope authorization for team, project, issue and doc scopes, so they could subscribe to anything in the workspace after the demotion, not merely keep what they already had.The hub now refreshes the principal on any
team_memberormemberchange and re-authorizes every scope the connection holds, dropping the ones that no longer pass. If the refresh throws, the connection closes rather than continuing on stale permissions.Not in this PR
Six lower-severity findings from the same review are still open and tracked: team-restricted projects and their milestones carry an org scope, unshared saved views do too, signing out does not close the socket, the
orbit.readMCP scope is not enforced, presigned uploads carry no server-side size cap, and the analytics CSV export does not escape formula-leading characters. The project and milestone ones need the owning teams computed rather than simply dropping the org scope, or list updates stop arriving, so they want their own change.