SKILL: OAuth Security Testing
Metadata
Description
OAuth 2.0 attack checklist: authorization code interception, redirect_uri bypass, CSRF on OAuth flow, state parameter abuse, open redirector chaining, token leakage via Referer, PKCE bypass, and scope escalation. Use when testing OAuth implementations in web apps or bug bounty.
Trigger Phrases
Use this skill when the conversation involves any of:
OAuth, OAuth 2.0, authorization code, redirect_uri bypass, OAuth CSRF, state parameter, PKCE bypass, scope escalation, token leakage, open redirector, OAuth attack
Instructions for Claude
When this skill is active:
- Load and apply the full methodology below as your operational checklist
- Follow steps in order unless the user specifies otherwise
- For each technique, consider applicability to the current target/context
- Track which checklist items have been completed
- Suggest next steps based on findings
Full Methodology
OAuth Security Testing
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
Mechanisms
- OAuth 2.0 authorizes limited access to resources via tokens; pair with OIDC for identity.
- Core Flows:
- Authorization Code (with PKCE for public clients)
- Client Credentials (service-to-service)
- Avoid Implicit and ROPC where possible
- Key Components:
- Resource Owner (user)
- Client (third-party app)
- Authorization Server (issues tokens)
- Resource Server (hosts protected resources)
- Tokens (access and refresh)
- Hardening Extensions:
- PAR (Pushed Authorization Requests), JAR (Request Objects), JARM (JWT-secured responses)
- Sender‑constrained tokens (DPoP, mTLS)
private_key_jwt or mTLS client authentication for confidential clients
OAuth/OIDC Considerations
- PKCE everywhere: Even with confidential clients/native apps;
code_verifier must be required and validated.
- Nonce/state binding: For OIDC, ensure
nonce is present and matched; state should be unguessable and tied to session.
redirect_uri exact match: Enforce exact string match against pre-registered allowlist; no wildcards/path traversal.
aud/azp/iss enforcement: Validate tokens strictly, including clock skew and JWKS kid rotation behavior.
- Front-channel logout/login CSRF: Validate logout CSRF; defend forced login to attacker accounts.
- ID Token vs Access Token: APIs must not accept ID tokens; check
token_type and audience.
- Device Code & CIBA: Validate polling rate limits, code expiry, and binding of device/user codes.
- Refresh Token Rotation: Enforce reuse detection and global invalidation chains.
- PAR/JAR/JARM: Use to pin exact redirect_uri and inputs and to protect front-channel parameters.
OAuth 2.1 Updates
- Implicit Flow Deprecated: Authorization servers should not support
response_type=token
- Password Grant Deprecated: ROPC (Resource Owner Password Credentials) considered insecure
- PKCE Mandatory: Required for all OAuth clients including confidential clients
- Exact Redirect URI Matching: No more substring or prefix matching allowed
- Refresh Token Sender Constraint: Refresh tokens should be sender-constrained via DPoP or mTLS
Financial-grade API (FAPI) Security
FAPI 1.0 Advanced Profile
- Signed Request Objects (JAR): Authorization requests as signed JWTs
- Hybrid Flow: Uses
response_type=code id_token for additional security
- MTLS Client Authentication: Certificate-bound tokens
- JARM: JWT-secured authorization response mode
- Request Object Encryption: Sensitive parameters encrypted
FAPI 2.0 Security Profile
- Pushed Authorization Requests (PAR): POST request parameters to dedicated endpoint
- DPoP (Demonstrating Proof-of-Possession): Token bound to client's key pair
- Client Authentication:
private_key_jwt or MTLS required
- Grant Management: Rich authorization requests and grant management API
graph TD
User[Resource Owner] -->|Initiates flow| Client
Client -->|Authorization Request| AuthServer[Authorization Server]
AuthServer -->|Authentication| User
User -->|Approves access| AuthServer
AuthServer -->|Authorization Code| Client
Client -->|Code + Client Secret| AuthServer
AuthServer -->|Access Token| Client
Client -->|Access Token| ResourceServer[Resource Server]
ResourceServer -->|Protected Resource| Client
style User fill:#b7b,stroke:#333,color:#333
style Client fill:#aae,stroke:#333,color:#333
style AuthServer fill:#9f9,stroke:#333,color:#333
style ResourceServer fill:#e9a,stroke:#333,color:#333
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
Native/Mobile
- Verify App Links/Universal Links to prevent hijacking callbacks.
- Ensure OAuth proxy components in mobile apps validate issuer and JWKS; do not ship client secrets in binaries.
SPA/Browser
- Use Authorization Code + PKCE; avoid Implicit/Hybrid unless justified.
- Store tokens in memory; if cookies are used, set
__Host- prefix with HttpOnly; Secure; SameSite.
Authorization Code Flow
- Initial authorization request has
response_type=code
- Request format:
/authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=code&scope=openid%20profile&state=ae13d489bd00e3c24
- Callback contains authorization code:
/callback?code=a1b2c3d4e5f6g7h8&state=ae13d489bd00e3c24
- More secure, backend exchanges code for tokens
sequenceDiagram
participant User
participant Client
participant AuthServer as Authorization Server
participant API as Resource Server
User->>Client: 1. Click "Login with Service"
Client->>AuthServer: 2. Authorization Request (response_type=code)
AuthServer->>User: 3. Login & Consent
User->>AuthServer: 4. Approves Access
AuthServer->>Client: 5. Redirect with Authorization Code
Client->>AuthServer: 6. Token Request (code + client_secret)
AuthServer->>Client: 7. Access & Refresh Tokens
Client->>API: 8. API Request + Access Token
API->>Client: 9. Protected Resource
Implicit Flow
- Initial authorization request has
response_type=token
- Request format:
/authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=token&scope=openid%20profile&state=ae13d489bd00e3c24
- Access token returned directly in URL fragment:
/callback#access_token=z0y9x8w7v6u5&token_type=Bearer&expires_in=5000&scope=openid%20profile&state=ae13d489bd00e3c24
- Higher vulnerability potential due to frontend token handling
sequenceDiagram
participant User
participant Client as Client (Browser)
participant AuthServer as Authorization Server
participant API as Resource Server
User->>Client: 1. Click "Login with Service"
Client->>AuthServer: 2. Authorization Request (response_type=token)
AuthServer->>User: 3. Login & Consent
User->>AuthServer: 4. Approves Access
AuthServer->>Client: 5. Redirect with Access Token in Fragment
Note over Client: Token stored in browser
Client->>API: 6. API Request + Access Token
API->>Client: 7. Protected Resource
Vulnerabilities
- Improper redirect_uri validation
- Open redirects
- Subdomain/path validation bypass
- CSRF attacks (missing/improper state parameter)
- Token leakage (URL fragments in referrer headers)
- Scope elevation (improper authorization)
- Account takeover via improper linking/unlinking
- JWT vulnerabilities (weak signatures, lack of validation)
- Client secret exposure in source/git repositories
- Authorization bypass in misconfigured implementations
- Session fixation attacks
- Access token theft via XSS/Man-in-the-Middle
Authorization Code Injection / Code Substitution
- Attacker injects victim authorization code into attacker session to bind victim account. Mitigate with state-nonce binding and PKCE.
Method 1: Auth Bypass in OAuth Implicit Flow
- Locate POST request containing user info (email, username) and access token
- In implicit flow, servers often don't properly validate access tokens
- Try changing user parameters (email, username) while keeping the token
- Potentially impersonate other users if server trusts client-provided identifiers
Method 2: Forced Profile Linking
- Target OAuth profile linking functionality
- Check for missing
state parameter in auth requests
- Create CSRF attack by copying auth URL before code/token use
- Deliver as direct link or embedded iframe to victim
- Can link attacker's social media to victim's account
Method 3: Account Hijacking via redirect_uri
- Identify authorization request with redirect_uri parameter
- Test redirect_uri manipulation (external domains or open redirects)
- Modify redirect_uri to attacker-controlled endpoint (webhook)
- Deliver modified auth URL to victim to capture their authorization code
- Use stolen code to complete OAuth flow and access victim's account
Methodologies
- Tools:
- Burp Suite (OAuth Scanner extension)
- OWASP ZAP
- OAuth 2.0 Threat Model Toolkit
- Postman for API testing
- JWT_Tool for token analysis
- OAuthSecurity Cheatsheet Scanner
- Techniques:
- Flow manipulation
- Parameter tampering
- Token analysis
- Replay attacks
- Social engineering (phishing for tokens)
- DPoP proof validation testing
- MTLS certificate validation testing
- PAR endpoint exploitation
- Token exchange flow testing
Chaining and Escalation
OAuth → Full Account Takeover
Open Redirect → Authorization Code Theft:
- Discover open redirect on trusted domain
- Craft OAuth flow with redirect_uri pointing to open redirect
- Victim clicks malicious link, completes OAuth flow
- Authorization code redirected through open redirect to attacker
- Attacker exchanges code for access token
CSRF → Account Linking Attack:
- Initiate OAuth flow to link social account
- Capture authorization callback URL before code is used
- Deliver URL to victim via CSRF
- Victim's account linked to attacker's social account
- Attacker logs in with social account to access victim's account
XSS → Token Theft:
- Find XSS vulnerability on application
- Inject script to steal access tokens from localStorage
- Use stolen tokens to access victim's API resources
- If refresh tokens stolen, maintain persistent access
OAuth → Lateral Movement
Token Exchange → Service Impersonation:
- Obtain low-privilege access token
- Use RFC 8693 token exchange to request token for different service
- Weak validation allows unauthorized service access
- Move laterally across microservices
Scope Elevation → Privilege Escalation:
- Obtain token with limited scope
- Manipulate refresh token exchange to request broader scopes
- Weak scope validation grants elevated permissions
- Access privileged API endpoints
IdP Confusion → Cross-Tenant Access:
- Multi-tenant application with multiple IdPs
- Obtain authorization code from Tenant A's IdP
- Exchange code at Tenant B's token endpoint
- Weak issuer validation grants cross-tenant access
OAuth → Backend Exploitation
JWT Algorithm Confusion → Signature Bypass:
- Obtain valid JWT access token
- Change algorithm from RS256 to HS256
- Sign token with public key (treating it as HMAC secret)
- Backend fails to validate algorithm properly
- Forge arbitrary tokens for privilege escalation
SSRF via redirect_uri → Internal Service Access:
- OAuth provider allows internal redirect_uri
- Set redirect_uri to internal service (http://169.254.169.254)
- Authorization response sent to internal service
- Use to access cloud metadata or internal APIs
Token Replay → Session Hijacking:
- Capture access token via network sniffing or logs
- Token not properly bound to client (no DPoP/MTLS)
- Replay token from attacker's system
- Hijack victim's session and access resources
Remediation Recommendations
OAuth 2.1 / Modern Implementation
Implement OAuth 2.1: Adopt latest security recommendations
- Deprecate Implicit and Password grants
- Require PKCE for all clients (public and confidential)
- Enforce exact redirect_uri matching
- Implement refresh token rotation with reuse detection
Enforce state parameter: Always required, cryptographically random, single-use
Validate token claims strictly:
aud (audience): Must match resource server
iss (issuer): Verify against known issuers
exp (expiration): Enforce with clock skew tolerance (max 60s)
nbf (not before): Validate if present
Secure token storage:
- Never use localStorage (XSS vulnerable)
- Use httpOnly cookies with
__Host- prefix or memory-only storage
- Set proper cookie flags:
HttpOnly; Secure; SameSite=Strict
Advanced Security Features
- Implement PAR (Pushed Authorization Requests): POST parameters to
/par endpoint
- Use DPoP (Demonstrating Proof-of-Possession): Bind access tokens to client's public key
- Implement MTLS for confidential clients: Certificate-bound access tokens
- Use JAR (JWT-secured Authorization Request): Sign authorization request parameters
- Consider JARM (JWT-secured Authorization Response): Signed authorization responses
Token Management
- Short-lived access tokens: 5-15 minutes maximum
- Refresh token rotation: Issue new refresh token on each use
- Refresh token reuse detection: Revoke entire token family on reuse
- Token binding: Use DPoP or MTLS to bind tokens to clients
Standards and Compliance
- Follow OAuth 2.1 (draft) guidance
- Implement FAPI if dealing with financial data
- Follow RFC 6819 OAuth threat model
- Adopt RFC 8252 for native apps
- Consider RFC 8693 for secure token exchange
- Implement RFC 9449 for DPoP
Regular Security Practices
- Rotate signing keys regularly (every 6-12 months)
- Implement JWKS with short TTL (< 1 hour)
- Pin trusted issuers in client configuration
- Conduct regular OAuth security audits
- Keep libraries and dependencies updated
1---2name: offensive-oauth3description: OAuth 2.0 attack checklist: authorization code interception, redirect_uri bypass, CSRF on OAuth flow, state parameter abuse, open redirector chaining, token leakage via Referer, PKCE bypass, and scope escalation. Use when testing OAuth implementations in web apps or bug bounty. Use only for authorized security research, training, or assessment.4license: MIT5---6# SKILL: OAuth Security Testing78## Metadata9- **Skill Name**: oauth-attacks10- **Folder**: offensive-oauth11- **Source**: https://github.com/SnailSploit/offensive-checklist/blob/main/oauth.md1213## Description14OAuth 2.0 attack checklist: authorization code interception, redirect_uri bypass, CSRF on OAuth flow, state parameter abuse, open redirector chaining, token leakage via Referer, PKCE bypass, and scope escalation. Use when testing OAuth implementations in web apps or bug bounty.1516## Trigger Phrases17Use this skill when the conversation involves any of:18`OAuth, OAuth 2.0, authorization code, redirect_uri bypass, OAuth CSRF, state parameter, PKCE bypass, scope escalation, token leakage, open redirector, OAuth attack`1920## Instructions for Claude2122When this skill is active:231. Load and apply the full methodology below as your operational checklist242. Follow steps in order unless the user specifies otherwise253. For each technique, consider applicability to the current target/context264. Track which checklist items have been completed275. Suggest next steps based on findings2829---3031## Full Methodology3233# OAuth Security Testing3435## Shortcut3637- Check for improper redirect validation (open redirects)38- Test state parameter manipulation/absence39- Manipulate OAuth flows to bypass authentication40- Try URL path traversal in redirect_uri41- Hunt for client secret leakage in source code/repos42- Look for improper scope validation4344## Mechanisms4546- **OAuth 2.0** authorizes limited access to resources via tokens; pair with **OIDC** for identity.47- **Core Flows**:48 - Authorization Code (with PKCE for public clients)49 - Client Credentials (service-to-service)50 - Avoid Implicit and ROPC where possible51- **Key Components**:52 - Resource Owner (user)53 - Client (third-party app)54 - Authorization Server (issues tokens)55 - Resource Server (hosts protected resources)56 - Tokens (access and refresh)57- **Hardening Extensions**:58 - PAR (Pushed Authorization Requests), JAR (Request Objects), JARM (JWT-secured responses)59 - Sender‑constrained tokens (DPoP, mTLS)60 - `private_key_jwt` or mTLS client authentication for confidential clients6162### OAuth/OIDC Considerations6364- **PKCE everywhere**: Even with confidential clients/native apps; `code_verifier` must be required and validated.65- **Nonce/state binding**: For OIDC, ensure `nonce` is present and matched; `state` should be unguessable and tied to session.66- **`redirect_uri` exact match**: Enforce exact string match against pre-registered allowlist; no wildcards/path traversal.67- **`aud`/`azp`/`iss` enforcement**: Validate tokens strictly, including clock skew and JWKS `kid` rotation behavior.68- **Front-channel logout/login CSRF**: Validate logout CSRF; defend forced login to attacker accounts.69- **ID Token vs Access Token**: APIs must not accept ID tokens; check `token_type` and audience.70- **Device Code & CIBA**: Validate polling rate limits, code expiry, and binding of device/user codes.71- **Refresh Token Rotation**: Enforce reuse detection and global invalidation chains.72- **PAR/JAR/JARM**: Use to pin exact redirect_uri and inputs and to protect front-channel parameters.7374### OAuth 2.1 Updates7576- **Implicit Flow Deprecated**: Authorization servers should not support `response_type=token`77- **Password Grant Deprecated**: ROPC (Resource Owner Password Credentials) considered insecure78- **PKCE Mandatory**: Required for all OAuth clients including confidential clients79- **Exact Redirect URI Matching**: No more substring or prefix matching allowed80- **Refresh Token Sender Constraint**: Refresh tokens should be sender-constrained via DPoP or mTLS8182### Financial-grade API (FAPI) Security8384#### FAPI 1.0 Advanced Profile8586- **Signed Request Objects (JAR)**: Authorization requests as signed JWTs87- **Hybrid Flow**: Uses `response_type=code id_token` for additional security88- **MTLS Client Authentication**: Certificate-bound tokens89- **JARM**: JWT-secured authorization response mode90- **Request Object Encryption**: Sensitive parameters encrypted9192#### FAPI 2.0 Security Profile9394- **Pushed Authorization Requests (PAR)**: POST request parameters to dedicated endpoint95- **DPoP (Demonstrating Proof-of-Possession)**: Token bound to client's key pair96- **Client Authentication**: `private_key_jwt` or MTLS required97- **Grant Management**: Rich authorization requests and grant management API9899```mermaid100graph TD101 User[Resource Owner] -->|Initiates flow| Client102 Client -->|Authorization Request| AuthServer[Authorization Server]103 AuthServer -->|Authentication| User104 User -->|Approves access| AuthServer105 AuthServer -->|Authorization Code| Client106 Client -->|Code + Client Secret| AuthServer107 AuthServer -->|Access Token| Client108 Client -->|Access Token| ResourceServer[Resource Server]109 ResourceServer -->|Protected Resource| Client110111 style User fill:#b7b,stroke:#333,color:#333112 style Client fill:#aae,stroke:#333,color:#333113 style AuthServer fill:#9f9,stroke:#333,color:#333114 style ResourceServer fill:#e9a,stroke:#333,color:#333115```116117## Hunt118119- Intercept OAuth flows with proxy (Burp/ZAP)120- Manipulate redirect_uri parameters121- Remove/tamper state parameter122- Test PKCE implementations123- Inspect token handling in browsers124- Check for client secret leakage125- Analyze scope handling logic126- Test account linking/unlinking127- Review token validation procedures128- Examine refresh token security129130#### Native/Mobile131132- Verify App Links/Universal Links to prevent hijacking callbacks.133- Ensure OAuth proxy components in mobile apps validate issuer and JWKS; do not ship client secrets in binaries.134135#### SPA/Browser136137- Use Authorization Code + PKCE; avoid Implicit/Hybrid unless justified.138- Store tokens in memory; if cookies are used, set `__Host-` prefix with `HttpOnly; Secure; SameSite`.139140### Authorization Code Flow141142- Initial authorization request has `response_type=code`143- Request format: `/authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=code&scope=openid%20profile&state=ae13d489bd00e3c24`144- Callback contains authorization code: `/callback?code=a1b2c3d4e5f6g7h8&state=ae13d489bd00e3c24`145- More secure, backend exchanges code for tokens146147```mermaid148sequenceDiagram149 participant User150 participant Client151 participant AuthServer as Authorization Server152 participant API as Resource Server153154 User->>Client: 1. Click "Login with Service"155 Client->>AuthServer: 2. Authorization Request (response_type=code)156 AuthServer->>User: 3. Login & Consent157 User->>AuthServer: 4. Approves Access158 AuthServer->>Client: 5. Redirect with Authorization Code159 Client->>AuthServer: 6. Token Request (code + client_secret)160 AuthServer->>Client: 7. Access & Refresh Tokens161 Client->>API: 8. API Request + Access Token162 API->>Client: 9. Protected Resource163```164165### Implicit Flow166167- Initial authorization request has `response_type=token`168- Request format: `/authorization?client_id=12345&redirect_uri=https://client-app.com/callback&response_type=token&scope=openid%20profile&state=ae13d489bd00e3c24`169- Access token returned directly in URL fragment: `/callback#access_token=z0y9x8w7v6u5&token_type=Bearer&expires_in=5000&scope=openid%20profile&state=ae13d489bd00e3c24`170- Higher vulnerability potential due to frontend token handling171172```mermaid173sequenceDiagram174 participant User175 participant Client as Client (Browser)176 participant AuthServer as Authorization Server177 participant API as Resource Server178179 User->>Client: 1. Click "Login with Service"180 Client->>AuthServer: 2. Authorization Request (response_type=token)181 AuthServer->>User: 3. Login & Consent182 User->>AuthServer: 4. Approves Access183 AuthServer->>Client: 5. Redirect with Access Token in Fragment184 Note over Client: Token stored in browser185 Client->>API: 6. API Request + Access Token186 API->>Client: 7. Protected Resource187```188189## Vulnerabilities190191- **Improper redirect_uri validation**192 - Open redirects193 - Subdomain/path validation bypass194- **CSRF attacks** (missing/improper state parameter)195- **Token leakage** (URL fragments in referrer headers)196- **Scope elevation** (improper authorization)197- **Account takeover** via improper linking/unlinking198- **JWT vulnerabilities** (weak signatures, lack of validation)199- **Client secret exposure** in source/git repositories200- **Authorization bypass** in misconfigured implementations201- **Session fixation** attacks202- **Access token theft** via XSS/Man-in-the-Middle203204#### Authorization Code Injection / Code Substitution205206- Attacker injects victim authorization code into attacker session to bind victim account. Mitigate with state-nonce binding and PKCE.207208#### Method 1: Auth Bypass in OAuth Implicit Flow209210- Locate POST request containing user info (email, username) and access token211- In implicit flow, servers often don't properly validate access tokens212- Try changing user parameters (email, username) while keeping the token213- Potentially impersonate other users if server trusts client-provided identifiers214215#### Method 2: Forced Profile Linking216217- Target OAuth profile linking functionality218- Check for missing `state` parameter in auth requests219- Create CSRF attack by copying auth URL before code/token use220- Deliver as direct link or embedded iframe to victim221- Can link attacker's social media to victim's account222223#### Method 3: Account Hijacking via redirect_uri224225- Identify authorization request with redirect_uri parameter226- Test redirect_uri manipulation (external domains or open redirects)227- Modify redirect_uri to attacker-controlled endpoint (webhook)228- Deliver modified auth URL to victim to capture their authorization code229- Use stolen code to complete OAuth flow and access victim's account230231## Methodologies232233- **Tools**:234 - Burp Suite (OAuth Scanner extension)235 - OWASP ZAP236 - OAuth 2.0 Threat Model Toolkit237 - Postman for API testing238 - JWT_Tool for token analysis239 - OAuthSecurity Cheatsheet Scanner240- **Techniques**:241 - Flow manipulation242 - Parameter tampering243 - Token analysis244 - Replay attacks245 - Social engineering (phishing for tokens)246 - DPoP proof validation testing247 - MTLS certificate validation testing248 - PAR endpoint exploitation249 - Token exchange flow testing250251## Chaining and Escalation252253### OAuth → Full Account Takeover2542551. **Open Redirect → Authorization Code Theft**:256 - Discover open redirect on trusted domain257 - Craft OAuth flow with redirect_uri pointing to open redirect258 - Victim clicks malicious link, completes OAuth flow259 - Authorization code redirected through open redirect to attacker260 - Attacker exchanges code for access token2612622. **CSRF → Account Linking Attack**:263 - Initiate OAuth flow to link social account264 - Capture authorization callback URL before code is used265 - Deliver URL to victim via CSRF266 - Victim's account linked to attacker's social account267 - Attacker logs in with social account to access victim's account2682693. **XSS → Token Theft**:270 - Find XSS vulnerability on application271 - Inject script to steal access tokens from localStorage272 - Use stolen tokens to access victim's API resources273 - If refresh tokens stolen, maintain persistent access274275### OAuth → Lateral Movement2762771. **Token Exchange → Service Impersonation**:278 - Obtain low-privilege access token279 - Use RFC 8693 token exchange to request token for different service280 - Weak validation allows unauthorized service access281 - Move laterally across microservices2822832. **Scope Elevation → Privilege Escalation**:284 - Obtain token with limited scope285 - Manipulate refresh token exchange to request broader scopes286 - Weak scope validation grants elevated permissions287 - Access privileged API endpoints2882893. **IdP Confusion → Cross-Tenant Access**:290 - Multi-tenant application with multiple IdPs291 - Obtain authorization code from Tenant A's IdP292 - Exchange code at Tenant B's token endpoint293 - Weak issuer validation grants cross-tenant access294295### OAuth → Backend Exploitation2962971. **JWT Algorithm Confusion → Signature Bypass**:298 - Obtain valid JWT access token299 - Change algorithm from RS256 to HS256300 - Sign token with public key (treating it as HMAC secret)301 - Backend fails to validate algorithm properly302 - Forge arbitrary tokens for privilege escalation3033042. **SSRF via redirect_uri → Internal Service Access**:305 - OAuth provider allows internal redirect_uri306 - Set redirect_uri to internal service (http://169.254.169.254)307 - Authorization response sent to internal service308 - Use to access cloud metadata or internal APIs3093103. **Token Replay → Session Hijacking**:311 - Capture access token via network sniffing or logs312 - Token not properly bound to client (no DPoP/MTLS)313 - Replay token from attacker's system314 - Hijack victim's session and access resources315316## Remediation Recommendations317318### OAuth 2.1 / Modern Implementation319320- **Implement OAuth 2.1**: Adopt latest security recommendations321 - Deprecate Implicit and Password grants322 - Require PKCE for all clients (public and confidential)323 - Enforce exact redirect_uri matching324 - Implement refresh token rotation with reuse detection325326- **Enforce state parameter**: Always required, cryptographically random, single-use327- **Validate token claims strictly**:328 - `aud` (audience): Must match resource server329 - `iss` (issuer): Verify against known issuers330 - `exp` (expiration): Enforce with clock skew tolerance (max 60s)331 - `nbf` (not before): Validate if present332333- **Secure token storage**:334 - Never use localStorage (XSS vulnerable)335 - Use httpOnly cookies with `__Host-` prefix or memory-only storage336 - Set proper cookie flags: `HttpOnly; Secure; SameSite=Strict`337338### Advanced Security Features339340- **Implement PAR (Pushed Authorization Requests)**: POST parameters to `/par` endpoint341- **Use DPoP (Demonstrating Proof-of-Possession)**: Bind access tokens to client's public key342- **Implement MTLS for confidential clients**: Certificate-bound access tokens343- **Use JAR (JWT-secured Authorization Request)**: Sign authorization request parameters344- **Consider JARM (JWT-secured Authorization Response)**: Signed authorization responses345346### Token Management347348- **Short-lived access tokens**: 5-15 minutes maximum349- **Refresh token rotation**: Issue new refresh token on each use350- **Refresh token reuse detection**: Revoke entire token family on reuse351- **Token binding**: Use DPoP or MTLS to bind tokens to clients352353### Standards and Compliance354355- Follow **OAuth 2.1** (draft) guidance356- Implement **FAPI** if dealing with financial data357- Follow **RFC 6819** OAuth threat model358- Adopt **RFC 8252** for native apps359- Consider **RFC 8693** for secure token exchange360- Implement **RFC 9449** for DPoP361362### Regular Security Practices363364- Rotate signing keys regularly (every 6-12 months)365- Implement JWKS with short TTL (< 1 hour)366- Pin trusted issuers in client configuration367- Conduct regular OAuth security audits368- Keep libraries and dependencies updated369