AI pentesting guides / Vulnerability classes

OAuth and OIDC

OAuth misconfiguration testing

OAuth misconfiguration testing checks whether an application's OAuth 2.0 or OpenID Connect flows can be abused to steal authorisation codes or tokens, log in as another user, or link an attacker's identity to a victim's account. The flaws are usually in how the client and authorisation server are configured, not in the protocol itself, and they fall under OWASP Top 10 2021 A07 and OWASP API Security Top 10 2023 API2.

There is no single CWE for OAuth misconfiguration. Individual findings map to the underlying weakness, most often CWE-601 (open redirect via redirect_uri), CWE-352 (missing state, a form of CSRF) or CWE-287 (improper authentication).

Classification

  • CWE-601 URL Redirection to Untrusted Site, for loose redirect_uri validation.
  • CWE-352 Cross-Site Request Forgery, for missing or unchecked state.
  • CWE-287 Improper Authentication, for account-linking and token-validation flaws.
  • OWASP Top 10 2021: A07; OWASP API Security Top 10 2023: API2.

What to test

  • redirect_uri validation: prefix or substring matching, extra paths, subdomains, or parameters that let a code be sent to an attacker-controlled page.
  • state parameter: missing, static or not checked, enabling login CSRF and account linking attacks.
  • PKCE: absent for public clients such as SPAs and mobile apps, or not enforced by the server.
  • Implicit flow still enabled, putting tokens in URL fragments.
  • ID token validation: signature, audience, issuer and nonce checks.
  • Account linking by unverified email, letting an attacker's identity provider account claim a victim's account.

Proof

Proof depends on the flaw. For redirect_uri, it is an authorisation code for a test victim arriving at a URL the tester controls. For missing state, it is a test victim's account linked to the tester's identity after visiting a crafted link. For account linking, it is a login to a test victim account via an identity the tester created. Each needs a recorded flow with every redirect, not just a single request.

Remediation

Register exact redirect URIs and compare them exactly. Require and verify a per-request state value, and PKCE with S256 for every client, as the OAuth 2.0 Security Best Current Practice (RFC 9700) recommends. Disable the implicit flow. Validate ID tokens fully. Only link accounts on verified email from trusted providers, with user confirmation.

With Pentest-Swarm

What Pentest-Swarm covers for OAuth

Pentest-Swarm does not currently test OAuth or OpenID Connect flows automatically. Some related checks help around the edges.

  • Open-redirect proof on redirect-style parameters, read from the Location header against a safe sentinel host, which can reveal redirect chains useful in OAuth attacks.
  • JWT checks with jwt_tool on tokens the application accepts.
  • BOLA and authentication-bypass proofs on the APIs that sit behind the OAuth login.

Where it falls short

OAuth testing requires driving multi-step browser flows across two parties, with test accounts at the identity provider, which Pentest-Swarm does not do today. Use a manual tester with an intercepting proxy such as Burp Suite and the OAuth 2.0 Security Best Current Practice as a checklist, and review client configuration at your identity provider.

Questions

Is OAuth an authentication protocol?

OAuth 2.0 is for authorisation. OpenID Connect adds authentication on top. Many flaws come from using plain OAuth as if it proved identity.

Do SPAs and mobile apps need PKCE?

Yes. They are public clients that cannot keep a secret, and current guidance recommends PKCE for all clients.

Why does the state parameter matter?

It binds the OAuth response to the user's browser session. Without it an attacker can complete a flow in the victim's browser with the attacker's code.

Sources

  1. RFC 9700: OAuth 2.0 Security Best Current Practice
  2. OWASP OAuth 2.0 Cheat Sheet
  3. CWE-601