Skip to content

Honor Apple's email_verified claim before linking accounts - #21

Merged
phulin merged 1 commit into
phulin:mainfrom
jackowayed:claude/oy-11-apple-email-verified
Aug 16, 2026
Merged

phulin merged 1 commit into
phulin:mainfrom
jackowayed:claude/oy-11-apple-email-verified

Conversation

@jackowayed

Copy link
Copy Markdown
Contributor

verifyAppleIdToken returned { sub, email } unconditionally, ignoring the email_verified claim. That email flows into tryLinkOAuthUserByEmail, which adopts any existing account holding it — so an unverified Apple email could claim another user's account.

Mirror the Google path: read email_verified, treat it as verified only when it is boolean true or the string "true", and return the email only when verified (undefined otherwise). This affects both the redirect callback and the native Apple endpoint, which is correct.

  • worker/routes/oauth.ts: add email_verified to the decoded payload type and gate the returned email on it in verifyAppleIdToken.
  • tests/worker/oauth.test.ts: createAppleIdToken gains an emailVerified option; regression tests assert an unverified email takes the new-user path without adopting a pre-seeded account (no session), and a verified email links to and adopts it.

This finding was OY-11 in the ID scheme my audit session came up with :P

Claude-Session: https://claude.ai/code/session_015EkRWLSbdRZqE9uCeuuQce

verifyAppleIdToken returned { sub, email } unconditionally, ignoring the
email_verified claim. That email flows into tryLinkOAuthUserByEmail, which
adopts any existing account holding it — so an unverified Apple email could
claim another user's account.

Mirror the Google path: read email_verified, treat it as verified only when
it is boolean true or the string "true", and return the email only when
verified (undefined otherwise). This affects both the redirect callback and
the native Apple endpoint, which is correct.

- worker/routes/oauth.ts: add email_verified to the decoded payload type and
  gate the returned email on it in verifyAppleIdToken.
- tests/worker/oauth.test.ts: createAppleIdToken gains an emailVerified
  option; regression tests assert an unverified email takes the new-user
  path without adopting a pre-seeded account (no session), and a verified
  email links to and adopts it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EkRWLSbdRZqE9uCeuuQce
Co-authored-by: jackowayed <18899+jackowayed@users.noreply.github.com>
@jackowayed
jackowayed force-pushed the claude/oy-11-apple-email-verified branch from 0c3cb7b to d2b5987 Compare August 11, 2026 16:04
@phulin
phulin merged commit d728549 into phulin:main Aug 16, 2026
1 check passed
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.

3 participants