OAuth 2.0 Attack Techniques
OAuth 2.0 is a delegation protocol — and when implemented incorrectly, it becomes a mechanism for account takeover. This post covers every major OAuth attack pattern from redirect URI manipulation to implicit flow token theft.
OAuth Flows Quick Reference
Authorization Code (most secure) — code exchanged server-side for tokens.
Implicit (deprecated) — token in URL fragment directly (dangerous).
Client Credentials — M2M, no user involvement.
Device Flow — TV/IoT devices, no browser.
Redirect URI Manipulation
The redirect_uri parameter tells the authorization server where to send the code/token after authorization.
Exact match bypass
|
Subdomain bypass (if wildcards allowed)
|
Chaining with open redirect
If target.com has an open redirect:
|
After authorization, the code goes to target.com/redirect, which redirects to attacker.com/steal?code=AUTH_CODE.
State Parameter Attacks (CSRF)
If state is missing, predictable, or not validated:
|
Account linking CSRF:
- Attacker initiates OAuth flow for “Connect GitHub account.”
- Drops the flow before the redirect (stops at step 5 out of 6).
- Gets the victim to click a link that completes the flow (step 6 — visiting the callback with the authorization code).
- Victim’s account is now linked to attacker’s GitHub account.
- Attacker uses “Login with GitHub” to access victim’s account.
Authorization Code Interception
Via Referer header
After authorization, the redirect contains the code in the URL. If the callback page loads third-party resources:
|
The Referer header on external resource requests contains the code.
Via Browser History / Analytics
If the code appears in the browser history or is sent to analytics (GA, Mixpanel, etc.).
Via Log Poisoning
Server-side request logs often record the full URL including query parameters.
Implicit Flow Token Theft
The implicit flow puts the access token directly in the URL fragment:
|
Fragment is accessible to JavaScript on the page. If the callback page has XSS:
|
Token Leakage in OAuth Apps
token_endpoint_auth_method=none (Public client secrets)
|
Reusable authorization codes
|
Scope escalation
|
JWT Attack Chaining in OAuth
OAuth tokens are often JWTs. Apply JWT attacks:
|
OpenID Connect Attacks
id_token claim manipulation
OIDC uses JWTs. If the sub claim isn’t validated server-side after signature verification:
|
Forge this token (with algorithm confusion or none) to log in as victim.
Nonce replay
OIDC uses nonce to prevent replay attacks. If the server doesn’t validate the nonce, a stolen id_token can be reused.
Discovery and Enumeration
|
Tools
|
Remediation
- Validate
redirect_uriagainst an exact-match allowlist. - Require and validate the
stateparameter on every authorization request. - Make authorization codes single-use and short-lived (≤10 minutes).
- Use PKCE (Proof Key for Code Exchange) for public clients.
- Don’t use the implicit flow — use authorization code with PKCE.
- Validate JWT signatures and claims (especially
iss,aud,exp,sub) on the server.
Discussion
Leave a comment · All fields required · No spam
No comments yet. Be the first.