A Security Vulnerability That Could Have Led to Full Twitter Account Takeover
Twitter's backend accepted Google ID tokens that were not issued for its own OAuth client, because it failed to validate the audience (aud) claim. An attacker could use a token generated through Google's OAuth Playground to log in as the victim, but only if the victim was phished into generating and sharing that token.
Published on medium.com
While working on various OAuth-related tests and experiments, I discovered an interesting security issue in Twitter. Before diving into the vulnerability itself, it’s helpful to briefly explain what Google OAuth is.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could take over a victim's Twitter account, but only if the victim was phished into generating and sharing an ID token; Twitter classified the report as informational.
What the attacker needed
Victim has a Google account; victim is phished into using OAuth Playground; attacker obtains the victim's ID token
The fix
The backend should validate the ID token's audience claim against its own client_id, and should never accept tokens generated through OAuth Playground.
How it was found
- The victim visits Google's OAuth Playground and signs in with their Google account.
- The victim selects scopes and authorises the APIs, generating an ID token.
- The victim copies the ID token from the Playground.
- The attacker obtains this ID token, for example through a phishing site that pretends to test OAuth configuration.
- The attacker uses the token to authenticate to Twitter as the victim.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you sign in with Google, Google gives the website a digital ID card (a token) that says who you are. That card is meant only for that specific website, and the website should check the card is addressed to it. Twitter did not check this, so a card made for a different app could still be used to log in as someone else. However, the attacker still needed the victim to create and hand over such a card, which requires tricking them.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.