Skip to content

LearnWeb and API

OAuth and OIDC client configuration review

Brief

Most OAuth findings are configuration: a flow the provider should no longer offer, a missing state or PKCE check, a redirect URI matched by prefix, or an API that accepts any token the provider ever issued. Each one is checked with our own test accounts and stops at the first response that answers the question.

Stage
Access
Reviewed
On this page
  1. Check first
  2. Which flows does the provider offer?
  3. Does the app send and check state, nonce and PKCE?
  4. Does the provider accept redirect URIs the client never registered?
  5. Does the API check which client a token was issued to?
  6. The defender sees
  7. Done when
  8. Not covered
  9. Tools
  10. Related research
  11. Reviewed

All commands

Situation
A web app that signs users in through an OAuth 2.0 or OpenID Connect provider, two test accounts, and where the client can, a second test client registered on the same provider for us. We test only the app, API and provider tenant the scope letter names, every login is one of our test accounts, and no request sends a real user anywhere; redirect checks stop at the provider's first answer and never complete a sign-in.
Goal
A table of the app's sign-in configuration: flows offered, state, nonce and PKCE use, redirect URI matching, and audience checking, each marked as holding or failing with the request that showed it.
Outputs
Captured on 4 Nov 2026 against the Atarus Bench Web and API lab fixture, edition web-api-0.2, running on loopback, with one origin playing every host, renamed to the example domains and printed as https (the lab ran plain http). The provider is the fixture's lab identity provider, and the test login, its code and the three tokens are lab values.

Check first

  • The provider, the app's client id, and whether the client is public (a browser or mobile app) or confidential (a server holding a secret).
  • Every redirect URI the client has registered, from the client's provider console.
  • Which APIs accept the provider's tokens, and how each one validates them.
  • Two test accounts, and a second test client on the same provider if the client can register one.
  • Where the provider's sign-in log goes, so each refused request can be matched.

Steps

Which flows does the provider offer?

curl -s https://idp.example.com/.well-known/openid-configuration | jq '{response_types_supported,
  grant_types_supported, code_challenge_methods_supported, token_endpoint_auth_methods_supported}'

Expected output

{
  "response_types_supported": [
    "code",
    "id_token",
    "token id_token"   # <- the implicit flow is still offered
  ],
  "grant_types_supported": [
    "authorization_code",
    "implicit",
    "refresh_token",
    "password"   # <- the password grant hands passwords to clients
  ],
  "code_challenge_methods_supported": [
    "plain",
    "S256"
  ],
  "token_endpoint_auth_methods_supported": [
    "client_secret_basic",
    "private_key_jwt"
  ]
}

The discovery document describes the whole provider, not this client, so it tells us what to ask about rather than what is wrong. The implicit flow puts tokens in the URL fragment, and the password grant teaches users to type their password into something other than the provider. The current best practice says not to use either.

Negative result. Only code among the response types, no implicit or password grant, and S256 offered for PKCE.

Fix. Turn off the implicit and password grants for every client that does not need them, then on the provider; move single page apps to the authorization code flow with PKCE.

Does the app send and check state, nonce and PKCE?

# AUTHZ_URL: the authorization request from the browser's network panel, during our own test login
for p in response_type state nonce code_challenge_method; do
  printf '%s=%s\n' "$p" "$(printf '%s' "$AUTHZ_URL" | grep -oE "[?&]$p=[^&]*" | cut -d= -f2)"
done
# our own code, held back in the proxy, replayed with a changed state
curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' -b "pre_login=$PRE_LOGIN_COOKIE" \
  "https://app.example.com/callback?code=$TEST_CODE&state=atarus-changed"

Expected output

response_type=code
state=ce15149f07
nonce=
code_challenge_method=   # <- no PKCE: an intercepted code can be redeemed without a verifier
302 https://app.example.com/dashboard   # <- the callback accepted a state it never issued

state ties the callback to the browser that started the login; if the app does not compare it, someone can finish a login in a victim's browser with their own account. PKCE ties the code to the client instance that asked for it. nonce does the same for the ID token. We hold our test account's code in the proxy, so the replay uses a code that has never been redeemed.

Negative result. All three parameters present with S256, and a callback with a changed state returns an error without signing anyone in.

Fix. Generate state and the PKCE verifier per login, store them in the pre-login session, reject a callback whose state does not match, and require PKCE on the provider for this client.

Does the provider accept redirect URIs the client never registered?

for r in https://app.example.com/callback https://app.example.com/callback/extra \
         https://app.example.com.tester.example/callback https://tester.example/callback; do
  printf '%-48s ' "$r"
  curl -s -o /dev/null -w '%{http_code}\n' --get https://idp.example.com/authorize --data-urlencode response_type=code \
    --data-urlencode client_id=app-web --data-urlencode scope=openid --data-urlencode "redirect_uri=$r"
done

Expected output

https://app.example.com/callback                 302
https://app.example.com/callback/extra           302   # <- a path the client never registered goes on to the login page
https://app.example.com.tester.example/callback  400
https://tester.example/callback                  400

The registered URI sets the baseline: here a 302 onwards to the login page means the provider accepted the redirect, and a 400 is the error page it must show instead of redirecting. A provider that matches by prefix sends codes to any path under the callback, and one open redirect on the app then carries the code to a host the attacker owns. We stop at this first response and never sign in through a variant.

Negative result. Every variant other than the exact registered string gets the error page.

Fix. Register exact redirect URIs and have the provider compare them as whole strings. Remove wildcard and development entries from production clients.

Does the API check which client a token was issued to?

curl -s -o me.json -w 'app access token    %{http_code}\n' -H "Authorization: Bearer $AT_APP" https://api.example.com/v1/me
curl -s -o me.json -w 'other client token  %{http_code}\n' -H "Authorization: Bearer $AT_OTHER" https://api.example.com/v1/me
curl -s -o me.json -w 'id token            %{http_code}\n' -H "Authorization: Bearer $ID_APP" https://api.example.com/v1/me

Expected output

app access token    200
other client token  200   # <- a token issued to a different client is accepted
id token            401

All three tokens belong to our test user; the second came from the test client registered for us. An API that checks the signature and issuer but not the audience accepts a token from any client on the provider, so a token taken through a minor app works on the main API. We read me.json each time to confirm the body names our test user, not an error page with a 200.

Negative result. Only the app's own access token gets a 200; the other client's token and the ID token get a 401.

Fix. Validate aud, iss, exp and the token type on every API, as RFC 9068 sets out for JWT access tokens, and log the client id each accepted token was issued to.

The defender sees

The provider logs every authorization request: the refused redirects show as errors naming the client id and the unregistered URI (on Entra ID, AADSTS50011), and our test logins show as ordinary sign-ins. The app should log the callback with a state mismatch as a failed login; if it logged a success, that is the finding seen from the inside. The API calls with another client's token look normal unless the API logs which client each token came from, and without that line nobody can see a token used outside the app it was issued to.

Done when

The discovery document is recorded, the authorization request's parameters and the callback's state check are tested, each redirect variant has the provider's response, and each API has been called with a token from another client.

Not covered

Session handling after sign-in (see authentication and session testing), refresh token lifetime (see the persistence audit), SAML, and attacks on the provider itself.