Skip to content

GitHub sign-in only claims a verified email (account takeover) - #432

Merged
aamoghS merged 1 commit into
devfrom
fix/github-verified-email
Sep 25, 2026
Merged

aamoghS merged 1 commit into
devfrom
fix/github-verified-email

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Bug (security)

GitHub is registered with allowDangerousEmailAccountLinking: true, which trusts the email to be the user's own. Auth.js's GitHub provider, when the profile has no public email, takes the primary (or first) address from /user/emails without checking verified.

So someone could add a member's address to their own GitHub account, never verify it, keep it private, and sign in with GitHub straight into that member's account, admin roles included. apphosting.yaml wires both GitHub secrets, so this is live in production.

Fix

The provider overrides userinfo.request: always read /user/emails and use the verified primary, else any verified address, else none (sign-in then has no email and fails).

Tests

verifiedGitHubEmail unit tests (verified primary wins; unverified primary never taken; none verified → null). packages/auth added to the root pnpm test. Typecheck 9/9, lint 8/8, 831 tests pass.

Worth doing after merge

Check account rows with provider = 'github' whose linked user's email isn't a verified address on that GitHub account; a takeover would look like that.

GitHub is registered with allowDangerousEmailAccountLinking, which
trusts the email to be the user's own. Auth.js's GitHub provider, when
the profile has no public email, takes the primary (or first) address
from /user/emails without checking verified. Someone could add a
member's address to their own GitHub account, never verify it, keep it
private, and sign in with GitHub straight into that member's account,
admin roles included. Production wires both GitHub secrets, so this was
live.

The provider now overrides userinfo.request: it always reads
/user/emails and uses the verified primary, else any verified address,
else none (the sign-in then has no email and fails).
verifiedGitHubEmail is tested, and packages/auth joins the root test
run.
@github-actions
github-actions Bot requested a review from aamoghS as a code owner September 25, 2026 03:42
@aamoghS aamoghS changed the title Feature: fix/github-verified-email to dev GitHub sign-in only claims a verified email (account takeover) Sep 25, 2026
@aamoghS
aamoghS merged commit 038c93e into dev Sep 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant