---
name: oauth-security-testing
description: Use when testing OAuth 2.0/OIDC login flows on a web app or bug bounty: checklist for redirect_uri bypass, state/CSRF abuse, PKCE bypass, token leakage.
---
# OAuth Security Testing
## What this does
Walks an audit of an OAuth 2.0 / OIDC implementation: authorization code interception, redirect_uri bypass, CSRF on the OAuth flow, state parameter abuse, open redirector chaining, token leakage via Referer, PKCE bypass, and scope escalation.
## When to use
When the work involves: OAuth, OAuth 2.0, authorization code, redirect_uri bypass, OAuth CSRF, state parameter, PKCE bypass, scope escalation, token leakage, open redirector, OAuth attack.
## How to run it
1. Treat the checklist below as the operational checklist; follow steps in order unless the user says otherwise.
2. For each technique, assess applicability to {target} / {context}.
3. Track which checklist items are completed.
4. Suggest next steps based on findings.
### Shortcut
- Check for improper redirect validation (open redirects)
- Test state parameter manipulation/absence
- Manipulate OAuth flows to bypass authentication
- Try URL path traversal in redirect_uri
- Hunt for client secret leakage in source code/repos
- Look for improper scope validation
### Hunt
- Intercept OAuth flows with proxy (Burp/ZAP)
- Manipulate redirect_uri parameters
- Remove/tamper state parameter
- Test PKCE implementations
- Inspect token handling in browsers
- Check for client secret leakage
- Analyze scope handling logic
- Test account linking/unlinking
- Review token validation procedures
- Examine refresh token security
### Request formats (verbatim)
Authorization code: `/authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=code&scope=openid%20profile&state=ae13d489bd00e3c24` then callback `/callback?code=a1b2c3d4e5f6g7h8&state=ae13d489bd00e3c24`.
Implicit: `/authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=token&scope=openid%20profile&state=ae13d489bd00e3c24` returning `/callback#access_token=z0y9x8w7v6u5&token_type=Bearer&expires_in=5000&scope=openid%20profile&state=ae13d489bd00e3c24`.
### Core checks
- `redirect_uri` exact match against pre-registered allowlist; no wildcards/path traversal
- `state` unguessable, single-use, tied to session; OIDC `nonce` present and matched
- PKCE everywhere; `code_verifier` required and validated
- Validate `aud`/`azp`/`iss`, `exp` (max 60s skew), `nbf`, JWKS `kid` rotation
- APIs must not accept ID tokens; check `token_type` and audience
- Refresh token rotation with reuse detection and global invalidation
- Front-channel logout/login CSRF; forced login to attacker accounts
### Attack methods to test
1. Auth bypass in implicit flow: find the POST carrying user info plus access token; try changing user parameters (email, username) while keeping the token to impersonate other users.
2. Forced profile linking: look for missing `state` in auth requests, copy the auth URL before code/token use, deliver as a direct link or iframe so the attacker's social account links to the victim's account.
3. Account hijacking via redirect_uri: modify `redirect_uri` to an attacker-controlled endpoint (webhook) or open redirect, send the URL to the victim, capture their authorization code, then complete the OAuth flow.
### Chains
- Open redirect → authorization code theft → token exchange
- CSRF → account linking attack
- XSS → token theft from localStorage
- Token exchange (RFC 8693) → service impersonation; scope elevation; IdP confusion → cross-tenant access
- JWT alg confusion (RS256→HS256) → signature bypass; SSRF via redirect_uri (e.g. http://169.254.169.254); token replay with no DPoP/mTLS
### Tools
Burp Suite (OAuth Scanner extension), OWASP ZAP, OAuth 2.0 Threat Model Toolkit, Postman, JWT_Tool.
### Remediation
Adopt OAuth 2.1: deprecate Implicit and Password grants, require PKCE for all clients, exact redirect_uri matching, refresh token rotation with reuse detection. Always require a cryptographically random, single-use `state`. Access tokens 5-15 minutes. Never store tokens in localStorage; use `HttpOnly; Secure; SameSite=Strict` cookies with `__Host-` prefix or memory-only. Add PAR, DPoP, mTLS, JAR/JARM where applicable. Follow RFC 6819, 8252, 8693, 9449 and FAPI for financial data; rotate signing keys every 6-12 months, JWKS TTL < 1 hour.
## Output
A prioritized findings list: each tested item, vulnerable or not, evidence (request/response), exploit chain if any, severity, remediation; plus checklist status and suggested next tests.
Credit: Based on public content by lukegarvai, packaged by Orbit.