fix(sso): re-check domain conflict before write and reject IP-address domains#4825
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Conflict handling is refactored into shared
Reviewed by Cursor Bugbot for commit 6193c4a. Configure here. |
Greptile SummaryThis PR narrows the TOCTOU window in the SSO domain-conflict check by extracting the DB lookup into a reusable
Confidence Score: 5/5Safe to merge — the changes are a focused, additive hardening of the SSO registration path with no regressions introduced. The numeric-TLD guard in domain.ts is a single-line addition that is provably correct given the earlier regex already guarantees at least one dot. The findDomainConflict refactor in route.ts is a pure extraction with identical semantics to the original inline query, and the second pre-write invocation correctly closes the gap that previously spanned the full OIDC discovery round-trip. New tests directly exercise the added rejection paths. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Route as SSO Register Route
participant DB as Database
participant Auth as auth.api
Client->>Route: POST /api/auth/sso/register
Route->>Route: normalizeSSODomain()
Route->>DB: findDomainConflict() check 1
DB-->>Route: conflict 409 or continue
Route->>Route: Build OIDC/SAML config
Route->>DB: findDomainConflict() check 2
DB-->>Route: conflict 409 or continue
Route->>Auth: registerSSOProvider()
Auth-->>Route: providerId
Route-->>Client: 200 success
Reviews (1): Last reviewed commit: "fix(sso): re-check domain conflict befor..." | Re-trigger Greptile |
Summary
auth.api.registerSSOProvider, in addition to the early fail-fast check, so the gap between check and write no longer spans the OIDC discovery fetches (narrows the TOCTOU window from seconds to ms).normalizeSSODomainnow rejects bare IPv4 addresses and numeric TLDs (e.g.10.0.0.1), which are never registrable email domains.lower(domain)) is blocked on deduping existing duplicate provider rows — tracked in SSO: make domain uniqueness atomic — dedup ssoProvider rows + add lower(domain) unique index #4824.Type of Change
Testing
Tested manually; added unit cases for IP/numeric-TLD rejection. (Existing SSO register route tests cover the conflict/ownership paths.)
Checklist