Skip to content
OAuth / SSO Write-up Intermediate

Exploiting Oauth Authentication Vulnerabilities Part Iii

The OAuth service did not validate the redirect_uri parameter, so an attacker could craft a CSRF exploit that caused a victim's authorization code to be sent to the attacker's server. The attacker could then use that code to obtain an authenticated session and access the victim's account.

Hashar Mujahid Follow

Published on infosecwriteups.com

Hi my name is Hashar Mujahid. I’m a cybersecurity student and today I will show some techniques that can be used to exploit OAuth 2.0 and possibly allow an attacker to take over the victim’s account completely.

Hashar Mujahid, on infosecwriteups.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

The OAuth service failed to validate the redirect_uri parameter, allowing arbitrary redirect destinations.

Impact

An attacker could steal an authorization code and use it to take over the victim's account, including admin accounts.

What the attacker needed

Victim clicks a link; victim has active OAuth session

The fix

The OAuth service should validate the redirect_uri against a whitelist of allowed URLs.

How it was found

  1. Log in to the website using the provided social media credentials.
  2. Analyse the OAuth authorization request and note the redirect_uri parameter.
  3. Change the redirect_uri to an arbitrary URL and observe that the service redirects there.
  4. Craft a CSRF payload that loads the authorization URL in an iframe with the redirect_uri pointing to the exploit server.
  5. Store and test the exploit, then deliver it to the victim.
  6. Capture the leaked authorization code from the access logs and use it to obtain a session.

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 websites to let you log in using another service, like Google. When you log in, the service sends a special code back to the website. If the website doesn't check where it's sending that code, an attacker can trick the service into sending the code to the attacker's own server. The attacker can then use that code to 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 Hashar Mujahid

View all

1 more disclosed report, 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.