OAuth 2.0 Vulnerabilities

OAuth 2.0 flaws are mostly implementation and configuration mistakes. They let an attacker steal or inject an authorization code or token, or tie a victim’s browser to the wrong account, which turns “Log in with X” into account takeover.

How it works

OAuth is a delegation framework that got repurposed for login. The client takes a token (or the /userinfo data it unlocks) as proof of identity. The spec is loose, most security controls are optional, and in some grant types secrets travel through the browser (PortSwigger). Every bug class breaks one of these invariants:

InvariantWhat breaks it
The code or token goes only to the registered clientWeak redirect_uri matching (prefix, wildcard subdomain, path confusion, parameter pollution). An open redirect or proxy page on an allowed origin. Referer leakage. Custom-scheme hijacking on mobile.
The callback belongs to the browser that started the flowMissing, static or non-single-use state. No PKCE. No session binding. The result is login CSRF or attacker-identity linking.
The token is for this client and this scopeClient confusion: an implicit-flow token minted for another client_id is accepted. Scope upgrade at the token endpoint.
The identity data is authenticImplicit flow where the client trusts browser-posted profile data. Unverified email at the provider.
Only trusted clients existOpen Dynamic Client Registration with no redirect validation. SSRF through jwks_uri, logo_uri and similar.

Details per class:

  • redirect_uri validation: the ACSAC ‘23 study found the RFC’s guidance under-specified. 6 of 16 IdPs were vulnerable to path confusion and 10 to parameter pollution, and chained with client bugs this gave full ATO (ACM). The allowlist must be per-client and exact (Doyensec).
  • Implicit flow: if the client POSTs the user data it received to its own backend and the backend trusts it, changing the parameters impersonates any user (PortSwigger). OAuth 2.1 drops the implicit flow (Doyensec).
  • state and PKCE: state should be unguessable and tied to the session. If it is missing or static, an attacker can complete their own flow in the victim’s browser. That gives login CSRF, or links the attacker’s IdP identity to the victim’s account (PortSwigger). With a static state, no PKCE and no session binding, the code becomes a portable “log in as this account” token (dkrypt).
  • Scope upgrade: an authorization server that trusts a scope parameter sent on the code-for-token request lets a malicious client widen access. The resource server must enforce the scope the user actually granted (Doyensec).
  • Hidden OIDC/OAuth surface: Dynamic Client Registration is “SSRF by design” through jwks_uri, request_uris and logo_uri. The research also covers redirect_uri session poisoning and WebFinger user enumeration. Always fetch /.well-known/openid-configuration (PortSwigger Research).
  • Token-holder confusion: OAuth access tokens that the app’s session layer also accepts give delegated, narrowly scoped tokens full-session power (NocoDB).
  • Enterprise view: attackers now target OAuth tokens rather than passwords. Stolen access and refresh tokens bypass MFA and survive password resets. Unit 42 names Cross-User OAuth Session Fixation (COSF), cross-tenant client ID confusion and cross-connector OAuth ATO as current classes (Unit 42).
  • Token lifecycle beyond the handshake: a correct login flow says nothing about refresh-token handling, token misuse across API and mobile trust boundaries, or resource-server authorization, which is where mobile/API tests still find gaps; RFC 9700 and RFC 10017 (browser-based apps, Aug 2026) are the current baselines (Rebline, partial article). See JWT Token Lifecycle and Revocation.

Client ID Metadata Documents (CIMD)

The MCP authorization spec now prefers CIMD over Dynamic Client Registration (DCR, RFC 7591), which it keeps only as a fallback. The client_id is an HTTPS URL that serves the client’s JSON metadata; the AS fetches it during the authorization request, so the request is the registration and there is no open /register endpoint or client database to spam. Trust moves from a stored record to DNS + TLS at request time (Auth0). Security-relevant rules, as Auth0 implements them:

  • The fetched document’s client_id must equal the URL it came from (stops borrowing another client’s metadata), and every request’s redirect_uri must be in its redirect_uris, checked on every authorization, not just the first.
  • No shared secrets: client_secret and client_secret_basic/_post/_jwt are forbidden because the document is public; clients are public (none + mandatory PKCE) or use private_key_jwt.
  • The fetch is an SSRF sink by design: HTTPS only, no redirects, no internal or special-use IPs, no localhost/loopback, path required, no query/fragment/credentials/dot segments, URL ≤ 120 bytes, document ≤ 5 KB and jwks_uri ≤ 12 KB.
  • Dynamic registrations persist only after a user completes consent and always register as third-party apps; a manual mode puts an admin review in front. The consent screen names the app from the document’s own client_name.

What to check

  • Recon: identify the provider, fetch /.well-known/openid-configuration and /.well-known/oauth-authorization-server, note grant types, response_mode, and whether registration is open.
  • redirect_uri: test subdomains, paths, extra query params, duplicated params, and other origins the client controls (open redirects, proxy pages, dangling CNAMEs). Check whether the token endpoint re-validates it.
  • state: present? Unpredictable? Bound to the session or browser (not just signed)? Single-use? Cleared after the callback? Is PKCE enforced (not just supported)?
  • Account linking via OAuth: can a callback started by the attacker attach to a logged-in victim?
  • Implicit flow: can you tamper with the identity data the client sends to its own backend?
  • Token audience: does the client accept tokens issued to other client_ids? Can scope be raised at the token endpoint?
  • Where tokens or codes appear in URLs: Referer, logs, postMessage, post-login redirects.
  • Mobile: custom-scheme redirect URIs (can another app register the scheme?).
  • Dynamic registration: is it open, and are redirect_uris, jwks_uri and logo_uri fetched server-side (SSRF)?
  • Auth proxies in front of apps: how are bypass/skip rules matched (path vs full URI)?

Notable cases

  • @fastify/oauth2: state and PKCE-verifier cookies were set on the login path but cleared with Path=/, so they survived the callback. The single-use guarantee failed, enabling login CSRF (advisory).
  • Seamless Auth API <0.19.2: state was HMAC-signed, 10-minute, single-use and PKCE was on, yet nothing bound it to the starting browser, and the PKCE verifier was derived server-side from state, so whoever held state held everything PKCE checks. That is login CSRF (RFC 9700 §4.7). Fix (#463): /start returns a random binding kept in sessionStorage; only its SHA-256 goes into the signed state; the callback compares it in constant time before marking the state used, so a wrong binding cannot burn a legitimate flow. A temporary OAUTH_ALLOW_UNBOUND_STATE escape hatch logs a warning at boot (Seamless Auth).
  • Better Auth <1.7.16 (CVE-2026-134312): OAuth sign-in trusted unverified provider emails (including email_verified: "false" as a string) and ignored profile vs ID-token sub mismatches, allowing linking into a victim’s local account (advisory).
  • Akeeba SocialLogin (Joomla): no session-bound state. A crafted callback link linked the attacker’s social identity to a logged-in victim’s account, followed by login as the victim (advisory).
  • Airbnb, 2016 ($5,000): redirect URIs were exact-matched, but a post-login redirect driven by Referer, chained with login CSRF on the OAuth start endpoint, delivered Facebook and Google tokens to an attacker page (case study).
  • Wildcard redirect + stale CNAME ($6,000): a *.target.com callback rule plus a subdomain takeover gave zero-interaction code theft (writeup).
  • MCP OAuth servers: open DCR, missing redirect URI validation and optional PKCE gave one-click ATO across AI-integration servers (sicks3c).
  • Identity injection (Bugcrowd): adding an email parameter to the profile POST during Facebook login logged the attacker in as any user (writeup).
  • CVE-2025-54576 (OAuth2-Proxy ≤7.10.0): skip_auth_routes regexes were matched against the full URI including the query string, so a crafted query bypassed authentication (ZeroPath).
  • NocoDB (<2026.10.1): OAuth access tokens were signed with the instance JWT secret and accepted as full sessions (advisory).
  • Pomerium 0.30.0–0.33.x (CVE-2026-135300, critical): the MCP token endpoint /.pomerium/mcp/token skipped client-secret verification for client_secret_basic clients, so an intercepted authorization code or refresh token redeemed with any secret; fixed 0.34.0 (advisory). Client authentication at the token endpoint is what makes a leaked code useless; test it with a wrong secret.
  • Virtualizor CVE-2026-135174: SQLi via the email claim returned by the OAuth provider, leading to admin login; claims from the IdP are attacker-influenced input. (source)

Defenses

  • Exact-match, per-client redirect_uri allowlists. No wildcards. Re-check at the token endpoint (Doyensec).
  • Use authorization code + PKCE for all clients. Don’t use the implicit flow, and use response_mode=form_post when tokens must come back through the browser (Doyensec).
  • Make state unguessable, session-bound and single-use, and make the callback refuse a code that has no link to the current browser context (dkrypt). A signed, expiring, single-use state is still unbound; bind it to a browser-held secret, and never derive the PKCE verifier from state itself (Seamless Auth).
  • The server derives identity from the provider (token or userinfo), never from client-supplied parameters. Verify token audience and granted scope.
  • Lock down or authenticate Dynamic Client Registration. Treat any URL the AS fetches as an SSRF sink (PortSwigger Research). For MCP clients prefer CIMD with self-matching client_id, per-request redirect_uri checks and a hardened fetcher (Auth0).
  • Verify client authentication on every token-endpoint grant, including refresh (Pomerium).
  • Keep delegated OAuth tokens separate from first-party session credentials (different keys and audiences).
  • Enterprise: disable end-user consent for unverified apps, use admin approval workflows, and continuously audit registered redirect URIs (Unit 42).

See also: Open Redirect

Sources