Sign in with Apple JWT Bug: Account Takeover Case
Apple's Sign in with Apple token minting process allowed an attacker to supply an arbitrary email address in the JWT, which Apple signed without verifying ownership. This let attackers obtain valid identity tokens for any email, enabling account takeover on third-party apps that trusted the email claim.
medium.com
Published on medium.com
Bug Bounty
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Sign in with Apple is Apple's federated identity service, and it behaves much like OpenID Connect. A user authenticates with Apple, chooses whether to share their real email address or a private relay address, and Apple returns a signed JWT. The relying party (the third-party app) verifies the signature against Apple's public keys and then logs in whoever the email claim names.
In April 2020, Bhavuk Jain found a flaw in the step where Apple minted that token. According to the researcher, the email that ended up in the JWT could be supplied by the requester, and Apple did not confirm that the address belonged to the person who had just signed in. The result was a validly signed identity token for an email address nobody had proven they owned. Apple paid $100,000 for the report.
The write-up is an analytical case study of that public disclosure. Reproduction details, endpoints and request bodies are deliberately left out, so the analysis below stays at the level of the token flow and the relying-party checks.

AI-generated illustration.
Setup
The report does not describe a lab setup, test accounts, tooling or versions. The precondition that matters is on the relying-party side: an app that accepts Sign in with Apple and trusts the email claim in the returned JWT, without additional safeguards, is exposed. The researcher named large integrators such as Dropbox, Spotify and Airbnb as examples of adopters, while noting that they were not tested.
Finding it
The researcher's observation was about where the email in the token came from. In a correct flow, the identity provider should only assert an address that the authenticated user has demonstrated control of. Here the email that ended up in the JWT could be supplied by the requester, and Apple did not confirm it belonged to the person who had just signed in.
The token itself was genuine: correct issuer, correct signature, and a claim saying the email was verified. Only the identity inside it was wrong. That is what makes the case uncomfortable: every app that validated the JWT properly still accepted it, because the lie came from the trusted signer itself.
Exploitation
The report does not publish a step-by-step reproduction, endpoints or request bodies. What it describes is the shape of the attack:
- The attacker starts a Sign in with Apple flow and supplies the email address they want the token to name, rather than an address they control.
- Apple mints a JWT for that address. The token carries the correct issuer, a valid signature and a claim stating the email is verified.
- The attacker presents the token to a third-party app that uses Sign in with Apple. The app verifies the signature against Apple's public keys, reads the
emailclaim and logs the attacker in as the account associated with that address.
The condition is that the target app trusts the email claim and has no additional safeguards. Jain wrote that the bug could lead to full takeover of accounts on third-party apps using Sign in with Apple, even if the victim had no Apple ID, as long as the app had no additional safeguards.
Apple reviewed its logs and found no misuse or account compromise.
Root cause
The mistake was in token minting at the identity provider: the email placed in the JWT was caller-chosen and was not bound to the identity that had just authenticated. The signature, issuer and verified-email claim were all correct, so relying-party validation could not detect the problem. A valid signature proves who issued a token, not that its claims are true.
Impact
An attacker could obtain a validly signed identity token for any email address and use it against third-party apps that trust the email claim without additional safeguards, leading to full account takeover. The victim did not need an Apple ID. The exposure depended on the integrator: apps with additional safeguards were not necessarily affected, and the named integrators were not tested. Apple found no evidence of misuse.
Fix
According to press coverage cited in the write-up, Apple fixed the bug in 2020. The report does not describe the code change. For relying parties, the write-up sets out defensive measures as its own analysis:
- Key accounts on the stable subject, not the email. Link a social login to
iss+suband treat email as a mutable contact attribute. - Never auto-merge on email alone. If a federated email matches an existing password account, require the user to prove control of that account before linking.
- Validate every claim you depend on: check
aud,exp,nonceand issuer, and bind the nonce to the browser session that started the login. - Plan for a compromised provider: alert on new federated links and offer step-up checks for sensitive actions.
The write-up includes this reference implementation of those checks:
def federated_login(id_token, session): claims = verify_jwt(id_token, keys=apple_jwks(), issuer=APPLE_ISS, audience=MY_CLIENT_ID) if claims.nonce != session.pop("login_nonce"): raise AuthFailed("nonce mismatch") link = links.find(issuer=claims.iss, subject=claims.sub) if link: return create_session(link.user) existing = users.find_by_email(claims.email) if existing: return require_proof_of_existing_account(existing, claims) return create_session(users.create_federated(claims.iss, claims.sub, contact_email=claims.email))
The function verifies the token against Apple's keys with the expected issuer and audience, checks the nonce against the session, looks the user up by issuer and subject, and refuses to merge into an existing email account without proof of control.
Variants to test
- Caller-chosen email in a federated token. Try to influence the email claim during the identity provider flow. A positive result is a token whose
emailnames an address you do not control while the signature and issuer are valid. - Email-based account merging. Register a password account, then sign in with a federated identity whose email matches it. A positive result is being logged into the existing account without proving control of the address.
- Missing nonce binding. Replay a federated login response in a different browser session. A positive result is a session created without a nonce mismatch.
- Unchecked audience or issuer. Present a token minted for a different client or issuer. A positive result is acceptance where
audorissshould have been rejected. - Subject instability. Sign in twice with the same federated identity and compare the subject. A positive result is a changing
subthat forces the app to fall back on email for matching.
What happened, in plain words
In April 2020, a security researcher named Bhavuk Jain found a serious flaw in Sign in with Apple, Apple's system that lets you log in to other websites using your Apple account. The flaw meant that Apple's servers would create a valid, officially signed login token for any email address an attacker asked for, even an address the attacker did not own. Any third-party app that trusted those tokens without extra checks could be tricked into logging the attacker in as someone else. Apple paid $100,000 for the report.
This article is an analytical case study of that public disclosure. It is not the researcher's own discovery, and the reproduction details, endpoints and request bodies are deliberately left out. What follows explains the token flow and the checks that apps on the receiving end should make.

AI-generated illustration.
The pieces you need to know first
Before the story makes sense, here are a few everyday ideas.
Sign in with Apple is a federated identity service. "Federated" means one company vouches for who you are, and other companies trust that voucher. Think of it like a passport: your own country issues it, and a hotel in another country accepts it because it trusts the issuing government. Here, Apple is the issuer and the third-party app is the hotel.
When you use Sign in with Apple, you authenticate with Apple (your Apple ID and password, or Face ID), and then you choose whether to share your real email address or a private relay address that Apple makes up for you. Apple then hands the app a JWT, which stands for JSON Web Token.
A JWT is a small block of text that carries claims (statements) about you, such as your email address, plus a cryptographic signature. The signature is like a wax seal on a letter: it proves the letter came from the person whose seal it is, and that nobody altered it on the way. The app can check the seal using Apple's public keys, which are published openly so anyone can verify Apple's signatures.
OpenID Connect is the standard way this kind of login usually works. Sign in with Apple behaves much like it.
The relying party is the third-party app that relies on Apple's token. It checks the signature against Apple's public keys and then logs in whoever the email claim names. A claim is simply a field inside the token, like a line on a form.
The setup
The report does not describe a lab setup, test accounts, tooling or versions. The precondition that matters is on the relying-party side: an app that accepts Sign in with Apple and trusts the email claim in the returned JWT, without additional safeguards, is exposed. The researcher named large integrators such as Dropbox, Spotify and Airbnb as examples of adopters, while noting that they were not tested.
In plain terms: the danger is not in the app's own code being broken. The danger is in the app believing what Apple's token says, which is normally a very reasonable thing to do.
Finding it
The researcher's observation was about where the email in the token came from. In a correct flow, the identity provider should only assert an address that the authenticated user has demonstrated control of. Here the email that ended up in the JWT could be supplied by the requester, and Apple did not confirm it belonged to the person who had just signed in.
Think of a bank teller who is supposed to check your ID before writing your name on a certificate. If the teller instead writes down whatever name you say, the certificate looks official, has the bank's stamp, and is completely worthless as proof of identity. That is what happened inside Apple's token minting.
The token itself was genuine: correct issuer, correct signature, and a claim saying the email was verified. Only the identity inside it was wrong. That is what makes the case uncomfortable: every app that validated the JWT properly still accepted it, because the lie came from the trusted signer itself.
Exploitation
The report does not publish a step-by-step reproduction, endpoints or request bodies. What it describes is the shape of the attack:
- The attacker starts a Sign in with Apple flow and supplies the email address they want the token to name, rather than an address they control.
- Apple mints a JWT for that address. The token carries the correct issuer, a valid signature and a claim stating the email is verified.
- The attacker presents the token to a third-party app that uses Sign in with Apple. The app verifies the signature against Apple's public keys, reads the
emailclaim and logs the attacker in as the account associated with that address.
The condition is that the target app trusts the email claim and has no additional safeguards. Jain wrote that the bug could lead to full takeover of accounts on third-party apps using Sign in with Apple, even if the victim had no Apple ID, as long as the app had no additional safeguards.
Apple reviewed its logs and found no misuse or account compromise.
Root cause
The mistake was in token minting at the identity provider: the email placed in the JWT was caller-chosen and was not bound to the identity that had just authenticated. The signature, issuer and verified-email claim were all correct, so relying-party validation could not detect the problem. A valid signature proves who issued a token, not that its claims are true.
Impact
An attacker could obtain a validly signed identity token for any email address and use it against third-party apps that trust the email claim without additional safeguards, leading to full account takeover. The victim did not need an Apple ID. The exposure depended on the integrator: apps with additional safeguards were not necessarily affected, and the named integrators were not tested. Apple found no evidence of misuse.
Fix
According to press coverage cited in the write-up, Apple fixed the bug in 2020. The report does not describe the code change. For relying parties, the write-up sets out defensive measures as its own analysis:
- Key accounts on the stable subject, not the email. Link a social login to
iss+suband treat email as a mutable contact attribute. - Never auto-merge on email alone. If a federated email matches an existing password account, require the user to prove control of that account before linking.
- Validate every claim you depend on: check
aud,exp,nonceand issuer, and bind the nonce to the browser session that started the login. - Plan for a compromised provider: alert on new federated links and offer step-up checks for sensitive actions.
The write-up includes this reference implementation of those checks:
def federated_login(id_token, session): claims = verify_jwt(id_token, keys=apple_jwks(), issuer=APPLE_ISS, audience=MY_CLIENT_ID) if claims.nonce != session.pop("login_nonce"): raise AuthFailed("nonce mismatch") link = links.find(issuer=claims.iss, subject=claims.sub) if link: return create_session(link.user) existing = users.find_by_email(claims.email) if existing: return require_proof_of_existing_account(existing, claims) return create_session(users.create_federated(claims.iss, claims.sub, contact_email=claims.email))
Line by line, in plain words:
def federated_login(id_token, session):defines a function that handles a login coming from a federated provider. It takes the token the provider sent and the current browser session.claims = verify_jwt(id_token, keys=apple_jwks(),starts checking the token's signature using Apple's published keys, fetched byapple_jwks().issuer=APPLE_ISS, audience=MY_CLIENT_ID)finishes the check by requiring that the token was issued by Apple and was meant for this specific app. The audience is the app the token was made for; a token made for another app should not be accepted here.if claims.nonce != session.pop("login_nonce"):compares the nonce in the token with the one stored in the session. A nonce is a one-time random value created when the login starts, so a token from a different login attempt cannot be reused.raise AuthFailed("nonce mismatch")stops the login if the nonces do not match.link = links.find(issuer=claims.iss, subject=claims.sub)looks up an existing link using the issuer and the subject (sub), which is the provider's stable identifier for the user.if link:checks whether such a link exists.return create_session(link.user)logs the user in if the link is found.existing = users.find_by_email(claims.email)looks for an existing account with the same email address.if existing:checks whether one was found.return require_proof_of_existing_account(existing, claims)refuses to merge automatically and asks the user to prove they control that existing account.return create_session(users.create_federated(claims.iss, claims.sub,creates a new federated account keyed on issuer and subject.contact_email=claims.email))stores the email only as a contact detail, not as the identity.
The function verifies the token against Apple's keys with the expected issuer and audience, checks the nonce against the session, looks the user up by issuer and subject, and refuses to merge into an existing email account without proof of control.
Variants to test
- Caller-chosen email in a federated token. Try to influence the email claim during the identity provider flow. A positive result is a token whose
emailnames an address you do not control while the signature and issuer are valid. - Email-based account merging. Register a password account, then sign in with a federated identity whose email matches it. A positive result is being logged into the existing account without proving control of the address.
- Missing nonce binding. Replay a federated login response in a different browser session. A positive result is a session created without a nonce mismatch.
- Unchecked audience or issuer. Present a token minted for a different client or issuer. A positive result is acceptance where
audorissshould have been rejected. - Subject instability. Sign in twice with the same federated identity and compare the subject. A positive result is a changing
subthat forces the app to fall back on email for matching.
Glossary
- Account takeover: when an attacker gains control of someone else's account.
- Audience (
aud): the claim naming which app a token was intended for. - Authentication: proving who you are, for example with a password or Face ID.
- Claim: a statement inside a token, such as an email address or an expiry time.
- CWE: a catalogue of common weakness types used to classify security bugs.
- Expiry (
exp): the claim stating when a token stops being valid. - Federated identity: a login where one provider vouches for your identity and other apps trust that voucher.
- Identity provider: the service that authenticates you and issues the token, here Apple.
- Issuer (
iss): the claim naming which provider created the token. - JWT (JSON Web Token): a small signed block of text carrying claims about a user.
- Nonce: a one-time random value used to tie a login response to the browser session that started it.
- OpenID Connect: a common standard for federated login built on top of OAuth.
- Public keys: openly published cryptographic keys used to verify a provider's signatures.
- Relying party: the third-party app that accepts and trusts the provider's token.
- Signature: cryptographic proof that a token came from the named issuer and was not altered.
- Subject (
sub): the provider's stable identifier for a user, which does not change when their email does. - Token: a piece of data, often signed, that represents a login or permission.