OAuth Token Validation Bug in Facebook
A missing validation on the OAuth token in Facebook's Twitter linking endpoint allowed an attacker to reuse a previously generated token to link a victim's page to the attacker's Twitter account, even after the attacker's admin role was removed. The attacker could then send a crafted URL to the victim, who upon opening it would link their page to the attacker's Twitter account.
Meta
Published on whitehatstories.blogspot.in
May 06, 2017
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
Root cause
Likely the OAuth token was not invalidated or re-validated against the user's current permissions when the callback URL was used, allowing reuse after the attacker lost admin access.
Impact
An attacker could link a victim's page to the attacker's Twitter account even after losing admin access, potentially allowing the attacker to post as the page or access page data via Twitter.
What the attacker needed
Attacker is admin of victim's page; victim removes attacker's admin role; victim clicks attacker-supplied link
The fix
The OAuth token should be validated against the user's current permissions and invalidated after use or when the user's role changes.
How it was found
- Attacker and victim are both admins of a page.
- Attacker starts linking the page to Twitter and obtains the authorization URL containing the oauth token, but does not complete the link.
- Victim removes the attacker's admin role from the page.
- Attacker opens the saved URL and captures the return URL containing oauth_token and oauth_verifier.
- Attacker sends the return URL to the victim.
- Victim opens the URL, and the page gets linked to the attacker's Twitter account.
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.
OAuth is a way for one website to ask another website to confirm who you are, without sharing your password. Here, Facebook let a user link their page to a Twitter account, but the special code (token) used for that link did not expire and was not checked properly. So an attacker could save the code, get removed as admin, and still trick the victim into using that old code to link the page to the attacker's Twitter account.
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.