Skip to content

fix(oauth): reject cross-site workspace OAuth launches - #9772

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/oauth-authorize-csrf
Nov 7, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/oauth-authorize-csrf

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • GET /api/auth/oauth2/authorize?providerId=…&workspaceId=…[&credentialId=…] picked the workspace (and, on reconnect, the credential) from the query alone and created a connect draft on the viewer's session. Session cookies are SameSite=Lax, so a cross-site page could navigate a signed-in user there and link their provider account as a credential in a workspace the attacker shares with them, or rebind an existing credential to the victim's account (CSRF on a state-changing GET)
  • Reject that branch when Sec-Fetch-Site is cross-site, before any draft is created, using the existing isCrossSiteSessionRequest helper (same gate as workflow execute)
  • draftId launches are unchanged: drafts are bound to the user who created them, and v2 API callers hand those authorization URLs to users from their own origin
  • In-app (same-origin), www ↔ apex (same-site), and desktop/CLI/address-bar (none) launches still work. A server-side redirect such as /desktop/connect keeps the attacker's page as the initiator, so the browser still sends cross-site
  • The proxy showed the login form to signed-in users for any /api/auth/oauth2/authorize callback, so /login?callbackUrl=<workspace launch> turned the launch into a same-origin request after sign-in. That exception now applies only to OAuth client requests (client_id present); a workspace launch callback sends a signed-in user to the app entry
  • Shrinks the check-test-types baseline for the authorize route test (its GET calls now pass createRouteContext({}))

Type of Change

  • Bug fix

Testing

  • proxy.test.ts: signed-in /login with a workspace-launch callback redirects to the app entry (red before the change); an OAuth client callback still shows the form
  • route.test.ts: cross-site workspace launch is refused with no draft or link call (red on the pre-fix code, confirmed by reverting the guard); a cross-site launch of the user's own draft still reaches the provider (the same-site/none header matrix is owned by same-origin.test.ts)
  • bun run --cwd apps/sim test on authorize/route.test.ts + same-origin.test.ts + proxy.test.ts + app/(auth) suites (107 passed), bun run lint, Phase A generators (no drift); type-check, check:audits and the full suite run in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Nov 7, 2026 8:07pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect the bounded workspace OAuth account-linking and login callback flows.

The behavior changes appear safe, but the new test wrapper must use the required shared helper before merging.

Findings

  1. P2 Test bypasses shared helper ▶

Summary

The PR blocks cross-site workspace OAuth launches before creating a connection draft.

  • Workspace OAuth launches reject cross-site starts before creating a draft.

Reviews (3) · Last reviewed commit: "fix(oauth): keep workspace launches out ..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit e39ae88 into staging Nov 7, 2026
64 of 65 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/oauth-authorize-csrf branch November 7, 2026 20:05
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

This branch was successfully deployed

1 active deployment
Preview — 0fa99ea2 Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant