OAuth Vulnerabilities Explained: How Broken Login Flows Leak Accounts
“Login with Google” and “Continue with GitHub” feel like the safest buttons on the internet. The protocol behind them, OAuth 2.0, is solid — but the way apps implement it often is not. Broken OAuth flows are a classic bug bounty category because one misconfiguration can mean full account takeover. Here is how the flow works, where it breaks, and how to test it legally.
How OAuth Is Supposed to Work
In the standard authorization-code flow:
- You click “Login with Google” on an app.
- The app sends you to Google with its client ID, a redirect URI, and a random state value.
- You log in at Google and approve the app.
- Google sends you back to the app’s redirect URI with a one-time authorization code.
- The app exchanges that code for an access token, server to server, and logs you in.
The security of the whole dance rests on a few details: the redirect URI must be locked down, the state value must be unpredictable and checked, and the code must only be usable once, by the right app.
Where It Breaks
- Open redirect URI. If the app accepts any redirect URI, an attacker registers their own domain, tricks a victim into logging in through it, and captures the victim’s authorization code — then logs in as the victim.
- Missing or ignored state parameter. Without a checked state value, an attacker can start a login with their own account and trick a victim’s browser into completing it — binding the victim’s session to the attacker’s account (a login CSRF). Worse variants leak tokens entirely.
- Code reuse and leakage. Authorization codes that are not single-use, or that appear in URLs logged by analytics and referrer headers, can be replayed by anyone who grabs one.
- No PKCE on public clients. Mobile and single-page apps cannot keep a secret, so they must use PKCE (a per-login secret challenge). Without it, a stolen code is directly usable.
- Confused identity binding. Some apps match accounts by email address alone from the OAuth provider. If the provider does not verify that email, an attacker can create an account with a victim’s email at the provider and take over the victim’s account on the app.
How to Test It (Legally)
Only on apps you own, a lab, or a program whose scope explicitly includes OAuth testing:
- Map the flow first. Log in with your own test accounts and record every redirect, parameter and token with a proxy like Burp Suite.
- Try redirect URI tricks. Test variations of the registered redirect URI — subdomains, paths, trailing slashes, URL-encoded characters — and see if any are accepted that should not be.
- Drop the state parameter. Remove or change state and see if the login still completes. If it does, you have a finding.
- Replay the code. Capture your own authorization code and try to exchange it twice, or from a different session. A second success is a finding.
- Test account binding. Create two provider accounts and see whether changing the email or provider ID confuses which app account you land in.
What a Good Report Looks Like
Bug bounty programs pay for impact, not theory. A strong OAuth report shows: the exact request sequence, the victim’s session you took over (your own test account — never a real user’s), and the business impact in one sentence (“an attacker can take over any account by tricking the victim into clicking one link”). Include reproduction steps a triager can follow with two test accounts.
The Defensive Takeaway
If you build login flows: lock the redirect URI to an exact match, always generate and verify state, use PKCE for public clients, treat codes as single-use secrets, and bind accounts to a verified provider user ID — never to an unverified email. OAuth is safe when implemented carefully; most account-takeover OAuth bugs are one missing check away from being prevented. As always on this blog: only test systems you own or have written permission to test. OAuth testing on a live app without permission is not research — it is unauthorized access.



Comments
Post a Comment