Repository navigation
fix(auth): bind CoinPay sign-in to the CoinPay sub, not the unverified email - #655
Merged
Merged
Conversation
…ied email CoinPay never verifies emails, so a CoinPay account registered with a victim's address used to log into the victim's ugig account (createUser email_exists -> listUsers lookup by email -> magic link for that email). - Login resolves the account only via oauth_identities (provider, sub). - An unbound CoinPay login whose email is already on ugig is refused (coinpay_email_in_use): sign in normally, then connect CoinPay from Settings -> Connections. - The session magic link is generated for the bound account's own email, not the CoinPay-supplied one (a changed CoinPay email could point at another account). - Connect mode: the state cookie is unsigned JSON, so its userId must equal the currently signed-in user or the link is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ThreatCrush Security Scan60 finding(s) HIGH/CRITICAL: 1 | MEDIUM: 12 | LOW: 47
…and 10 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CoinPay userinfo always returns email_verified=false (CoinPay never verifies addresses), but the CoinPay callback adopted any existing ugig account with the same email (createUser -> email_exists -> listUsers by email -> magic link). Anyone could register a CoinPay account with a victim's address and sign into their ugig account.
Changes
src/lib/coinpay-login.ts: the account is chosen only throughoauth_identities (coinpay, sub). Unbound sub + email already on ugig -> refused withcoinpay_email_in_use(login page explains: sign in normally, connect CoinPay from Settings -> Connections). Unbound sub + unused email -> new account bound to the sub.coinpay_oauth_statecookie is unsigned JSON, so a rewrittenuserIdcould attach the caller's CoinPay to someone else's profile (then log in as them). The callback now requires the signed-in user to match.src/lib/coinpay-login.test.ts,src/app/api/callback/oauth/route.connect.test.ts.No migration needed: existing CoinPay users are already bound by sub in
oauth_identities.🤖 Generated with Claude Code