Skip to content
OAuth / SSO Write-up Intermediate

How an OAuth Misconfiguration Led to Token Leakage

The backend that builds OAuth authorisation URLs trusted the Host header, so an attacker could change it to their own domain and have the OAuth redirect URI point to their server. After a victim logged in with Google or Microsoft, the resulting token would be sent to the attacker, allowing account takeover.

medium.com

Published on medium.com

Free Article Link: Click for free!

Ehtesham Ul Haq, 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

The backend used the untrusted Host header to construct the OAuth redirect URI without validating it against a whitelist.

Impact

An attacker could capture access tokens, leading to account takeover and exposure of sensitive data such as email, profile data, or cloud files.

What the attacker needed

Victim initiates login via Google or Microsoft; attacker can intercept and modify requests

The fix

The application should strictly validate the Host header and only allow whitelisted redirect URIs.

How it was found

  1. Intercept the login process with a proxy.
  2. Find the endpoint that builds OAuth links.
  3. Change the Host header to an attacker-controlled domain.
  4. Observe that the server generates OAuth URLs with the injected domain as the redirect destination.

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 lets you sign in to a site using another provider like Google. The site tells Google where to send you back using a redirect address. If the site builds that address from an untrusted header, an attacker can make it point to their own server and steal the login token.

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.

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.