OAuth 2.0
Identifying OAuth authentication
If you see an option to log in using your account from a different website, this is a strong indication that OAuth is being used.
Regardless of which OAuth grant type is being used, the first request of the flow will always be a request to the
/authorization
endpoint containing a number of query parameters that are used specifically for OAuth. In particular, keep an eye out for theclient_id
,redirect_uri
, andresponse_type
parameters
Recon
If using an external OAuth service, identify the provider by the hostname in the authorization request. Public API documentation typically provides detailed information, including endpoint names and configuration options. Try sending a request to the following standard endpoints:
/.well-known/oauth-authorization-server
/.well-known/openid-configuration
Vulnerabilities
Improper implementation of the implicit grant type
At the conclusion of the login process, the client application often sends the username and access token to the server via a POST
request. The server then issues a session cookie, effectively completing the login and establishing the user session
Exploitation: repeat this request with an arbitrary account (changing email and username) and leaving the access token
Account hijacking via redirect_uri
Replace redirect_uri
with a attacker controlled domain
Note: using state
or nonce
protection does not necessarily prevent these attacks because an attacker can generate new values from their own browser.
Flawed redirect_uri validation
Chain vulns
If you are unable to successfully submit an external domain as the redirect_uri
you can chain vulnerabilities like open redirect, xss etc.
Find open redirect
Use this url as
redirect_uri
Tip: the default URI will often be on an OAuth-specific path, such as /oauth/callback
, so you can use directory traversal tricks https://client-app.com/oauth/callback/../../example/path
Flawed CSRF protection
if you notice that the authorization request does not send a state
parameter, It potentially means that you can initiate an OAuth flow yourself before tricking a user's browser into completing it, similar to a traditional CSRF attack.
OpenID Connect
Identifying OpenID Connect
Look for the mandatory openid
scope
Unprotected dynamic client registration
Identify configuration file
/.well-known/openid-configuration
to get registration_endpointRegister your own client app. In the logo_uri add a external url for SSRF
Make
GET /client/CLIENT-ID/logo
request and replace theclient_id
Last updated