Skip to content
OAuth / SSO Write-up Intermediate

FB OAuth Misconfigurations to Account Takeover

The application's Facebook OAuth login accepted only a 16-digit Facebook user ID (oauthId) to issue session cookies, without verifying the Facebook token. An attacker who obtained a victim's Facebook token via XSS could use the Facebook API to retrieve the user ID and then log in as the victim.

hbenja47 Follow

Published on medium.com

Today I’m going to share my experience through a bug, my first account takeover in bug bounty through authentication via Facebook. It was in a private program that had login via Facebook or Google.

Benja (bronxi), on medium.com

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 application trusted a client-supplied Facebook user ID as proof of identity instead of verifying the Facebook access token with Facebook's servers.

Impact

An attacker could take over any user's account that has Facebook login enabled, by obtaining the user's Facebook token via XSS and then using the Facebook API to get the user ID, which grants session cookies without expiration.

What the attacker needed

Victim clicks a malicious link; attacker has an XSS vulnerability; victim has Facebook login enabled

The fix

The application should verify the Facebook access token with Facebook's servers and use the verified user ID, rather than trusting a client-supplied user ID.

How it was found

  1. The attacker sends a malicious link to the victim to obtain their Facebook token stored in localStorage.
  2. The victim receives that malicious link and opens it.
  3. The attacker receives the Facebook token on their server.
  4. The attacker uses the Facebook API to obtain the User ID.
  5. The attacker uses the userID to obtain the victim’s session cookies and logs into the victim’s 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.

When you log in with Facebook, the app should check a secret token from Facebook to confirm who you are. Here, the app only asked for a public-looking number (the Facebook user ID) and gave out a login session if that number was correct. So if an attacker could learn that number, they could log in as you.

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.

More by hbenja47

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

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.