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:
| Invariant | What breaks it |
|---|---|
| The code or token goes only to the registered client | Weak 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 flow | Missing, 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 scope | Client confusion: an implicit-flow token minted for another client_id is accepted. Scope upgrade at the token endpoint. |
| The identity data is authentic | Implicit flow where the client trusts browser-posted profile data. Unverified email at the provider. |
| Only trusted clients exist | Open 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).
stateand PKCE:stateshould 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 staticstate, 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
scopeparameter 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_urisandlogo_uri. The research also coversredirect_urisession 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_idmust equal the URL it came from (stops borrowing another client’s metadata), and every request’sredirect_urimust be in itsredirect_uris, checked on every authorization, not just the first. - No shared secrets:
client_secretandclient_secret_basic/_post/_jwtare forbidden because the document is public; clients are public (none+ mandatory PKCE) or useprivate_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 andjwks_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-configurationand/.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? Canscopebe 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_uriandlogo_urifetched server-side (SSRF)? - Auth proxies in front of apps: how are bypass/skip rules matched (path vs full URI)?
Notable cases
- @fastify/oauth2:
stateand PKCE-verifier cookies were set on the login path but cleared withPath=/, so they survived the callback. The single-use guarantee failed, enabling login CSRF (advisory). - Seamless Auth API <0.19.2:
statewas 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 fromstate, so whoever heldstateheld everything PKCE checks. That is login CSRF (RFC 9700 §4.7). Fix (#463):/startreturns a randombindingkept insessionStorage; 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 temporaryOAUTH_ALLOW_UNBOUND_STATEescape 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-tokensubmismatches, 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.comcallback 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
emailparameter 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_routesregexes 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/tokenskipped client-secret verification forclient_secret_basicclients, 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_uriallowlists. 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_postwhen tokens must come back through the browser (Doyensec). - Make
stateunguessable, 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-usestateis still unbound; bind it to a browser-held secret, and never derive the PKCE verifier fromstateitself (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-requestredirect_urichecks 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).
Related
- Authentication Security · OpenID Connect Security · Account Takeover · Device Code Phishing · OAuth Consent Phishing
- Login CSRF · Cross-Site Request Forgery · Open Redirect to SSRF · JSON Web Tokens · MCP Security · API Security · Bug Bounty Hunting · AI and LLM Security
See also: Open Redirect
Sources
- PortSwigger: OAuth 2.0 authentication vulnerabilities · original
- Doyensec: Common OAuth Vulnerabilities · original
- OAuth 2.0 Redirect URI Validation Falls Short (ACM) · original
- PortSwigger: Hidden OAuth attack vectors · original
- Login CSRF via a replayable OAuth code (static state, no PKCE) · original
- @fastify/oauth2 login CSRF via uncleared OAuth state cookie · original
- Akeeba (Joomla) account takeover via missing OAuth state validation · original
- The Referer Header That Redirected OAuth Tokens · original
- How I Chained a Stale CNAME Record with OAuth 2.0 Wildcards for a $6,000 Account Takeover (ATO) · original
- Hunting Account Takeovers in the Wild West of MCP OAuth Servers · original
- This OAuth Bug Earned Me $$$$: Account Takeover via Identity Injection · original
- NocoDB OAuth authentication bypass · original
- OAuth2-Proxy Authentication Bypass (CVE-2025-54576) · original
- The Current Landscape of OAuth Attacks · original
- We wrote an RFC 9700 matrix and it found a bug (OAuth state binding) · original
- Better Auth OAuth signature issue (high) · original
- Pomerium authentication bypass (critical) · original
- Registering MCP Clients with CIMD in Auth0 · original
- OAuth Is Not the Finish Line: Testing Token Lifecycle and Mobile API Trust Boundaries · original
- Softaculous Virtualizor SQL injection (critical) · original