OAuth 2.0 Testing Checklist
OAuth 2.0 is the protocol of choice for “Sign in with Google/Apple/GitHub” integrations. Because developers must manually map authorization codes, callback URLs, and state parameters, implementation errors are extremely common.
OAuth bugs often lead to complete Account Takeover (ATO), which carries critical severity and commands the highest payouts.
The Core Flow (Authorization Code)
Section titled “The Core Flow (Authorization Code)”+----------+ auth request (with redirect_uri & state) +--------------+| | ------------------------------------------------> | || | <------------------------------------------------ | || Client | auth code | IdP (e.g. || Browser | | Google) || | POST /callback (with code) | || | ------------------------------------------------> | |+----------+ +--------------+sequenceDiagram
autonumber
actor Browser as Client Browser
participant App as Target App (Client)
participant IdP as Identity Provider (e.g. Google)
Browser->>IdP: 1. Auth Request (redirect_uri & state)
IdP-->>Browser: 2. Delivers Auth Code (via redirect callback)
Browser->>App: 3. POST /callback?code=AUTH_CODE&state=STATE
Note over App: Validates state & extracts Auth Code
App->>IdP: 4. Server-to-Server token request (code + client_secret)
IdP-->>App: 5. Returns Access Token & user profile info
App-->>Browser: 6. Logs user in (sets session cookie)
OAuth 2.0 Checklist
Section titled “OAuth 2.0 Checklist”1. State Parameter Manipulation (OAuth CSRF / Account Hijacking)
Section titled “1. State Parameter Manipulation (OAuth CSRF / Account Hijacking)”The state parameter acts as a CSRF token for the login flow, linking the OAuth response back to the user’s browser session.
- Remove the
stateparameter entirely: Initiate the login flow, capture the request in Repeater, drop thestateparameter, and send the request. Does it succeed? - Send an empty or static
state: Check if the application acceptsstate=or a generic value likestate=12345. - Cross-session state swap (The CSRF Attack):
- Authenticate as Alice (the attacker) and start a “Link Google Account” process.
- Intercept the final callback request from Google:
GET /oauth/callback?code=ALICES_CODE&state=ALICES_STATE
- Drop this request in Alice’s browser (do not let it complete). Copy the entire URL.
- Send this URL to Bob (the victim). If Bob visits the link in his logged-in browser session, does Alice’s Google account get linked to Bob’s profile?
- If yes, Alice can now log in to Bob’s account using her Google credentials. (Severity: High/Critical)
2. Redirect URI Manipulation
Section titled “2. Redirect URI Manipulation”The redirect_uri tells the Identity Provider (IdP) where to send the authorization code. If you can hijack this parameter, you can steal authorization codes.
- Direct URL Swap:
Change
redirect_uri=https://target.com/callbacktoredirect_uri=https://attacker.com/callback. Check if the IdP issues the code to the attacker’s server. - Path Traversal / Path Escape:
Check if the target server validates callback paths loosely:
redirect_uri=https://target.com/callback/../../attacker.comredirect_uri=https://target.com/callback%2f%2e%2e%2f%2e%2e%2fattacker.com
- Parameter Manipulation / Regex Bypasses:
- Subdomain spoofing:
redirect_uri=https://target.com.attacker.com - Parameter injection:
redirect_uri=https://target.com/callback?url=https://attacker.com - Fragment injection:
redirect_uri=https://target.com/callback#https://attacker.com
- Subdomain spoofing:
- Wildcard Subdomain Abuse:
If the configuration permits
*.target.comas a redirect target, find a dangling subdomain or a subdomain vulnerable to takeover (e.g.dangling.target.com) and redirect the codes there:redirect_uri=https://dangling.target.com/callback
3. Code/Token Leakage (Referer Header)
Section titled “3. Code/Token Leakage (Referer Header)”Even if the callback domain is strictly validated, the authorization code might leak after it lands on the callback page.
- Check for External Assets on Callback Page:
Inspect the HTML source of the callback page (
https://target.com/callback?code=CODE). Does it load third-party scripts, images, or advertisements? - Verify the
RefererHeader: Monitor your proxy logs. When the callback page requests these external assets, does the browser send theRefererheader containing the code/token parameter (Referer: https://target.com/callback?code=CODE) to the third-party domain? - Open Redirect on Callback Page:
Check if the callback page redirects you to an arbitrary path using a parameter:
https://target.com/callback?code=CODE&next=/profileChange the redirect path tohttps://attacker.com. The browser will follow the redirect and transmit the authorization code to your server via theRefererheader.
4. Pre-Account Takeover (OAuth Email Binding Flaw)
Section titled “4. Pre-Account Takeover (OAuth Email Binding Flaw)”This occurs when the application merges accounts created via traditional passwords with accounts created via SSO without verifying ownership.
- Test Account Binding Sequence:
- Register a traditional account using the victim’s email address:
victim@example.comand a password of your choice. - Leave the email unverified if the app allows you to log in.
- Now, pretend you are the victim. Log in using OAuth (Google/Apple) using the verified
victim@example.comaccount. - Does the application log you into the pre-existing account created by the attacker?
- If yes, the attacker can log in at any time using the password they set originally, while the victim logs in via OAuth, sharing the same account context. (Severity: High/Critical)
- Register a traditional account using the victim’s email address:
OAuth 2.0 Vulnerability Taxonomy
Section titled “OAuth 2.0 Vulnerability Taxonomy”Below is a structured taxonomy of the primary integration vulnerabilities affecting OAuth 2.0 implementation, ordered from client-side state manipulation to token flow leakages.
1. OAuth Cross-Site Request Forgery (CSRF)
Section titled “1. OAuth Cross-Site Request Forgery (CSRF)”- Name: State Parameter Omission / Bypass
- The Shape: The application initiates authorization flows without generating a unique, cryptographically secure
stateparameter, or fails to validate it on callback. This allows attackers to bind their credentials to a victim’s session. - How to Detect: Intercept the
/oauth/callbackrequest, modify or omit thestateparameter, and observe if the login flow completes successfully. - How to Mitigate/Solve: Generate a random token, store it in the user’s session cookie, pass it in the
stateparameter during authorization, and assert equivalence on the callback request before exchanging the code. - Difficulty Tag: Easy (High-Value: Enables complete mapping of attacker identity onto victim accounts).
- Real Example: A vulnerability in standard social login library configurations allowing user-linked social logins to hijack target profiles.
2. Permissive Redirect URI Validation
Section titled “2. Permissive Redirect URI Validation”- Name: Redirect URI Pattern Bypass
- The Shape: The authorization server validates requested callback destinations using partial string matching, regex wildcards, or weak domain checks. This allows attackers to redirect authorization codes to external malicious servers.
- How to Detect: Request authorization codes while modifying the
redirect_urito reference related hosts, external subdomains, or directories containing directory traversal payloads (e.g.https://target.com/callback/../../attacker.com). - How to Mitigate/Solve: Enforce strict, exact string match comparison for registered redirect URIs. Avoid dynamic URL parsing or regex validation patterns.
- Difficulty Tag: Medium
- Real Example: Facebook OAuth wildcard redirection bypasses leading to token access leakage across client subdomains.
3. Callback Token/Code Leakage
Section titled “3. Callback Token/Code Leakage”- Name: Callback Referrer/History Token Leakage
- The Shape: An application returns access tokens or authorization codes in the URL parameters or fragment, which then leak through the browser’s
Refererheader when loading external third-party assets (images, frames, or tracker scripts) or during open redirection. - How to Detect: Monitor outbound callback HTTP traffic using a proxy, checking if third-party assets loaded on the callback page receive the
codeortokenin theirRefererheaders. - How to Mitigate/Solve: Transition to the Authorization Code Flow with PKCE (Proof Key for Code Exchange) to prevent code reuse, and use
Referrer-Policy: no-referreron callback pages. - Difficulty Tag: Hard
- Real Example: Authorization tokens leaked to third-party ad script networks embedded on e-commerce OAuth landing portals.
Next step: continue with GraphQL testing in Section 7b. For the full account takeover manuals, see the Broken Access Control guide.
Open local graph around this page
Linked from here
Bug Hunting for BeginnersFor authorized testing only. Read the ethics note before you put a domain in scope.