
OAuth security testing finds real bugs in the trust bindings between parties: redirect matching, response binding, token validation and account linking. Production deployments almost never break at the cryptography, which is why scanner-grade parameter fuzzing misses the findings that end in account takeover.
The short answer
- OAuth and OIDC break at trust bindings, not crypto: redirect_uri matching, state, nonce, PKCE, iss, token audience and (iss, sub) account keys.
- Every grant type needs a specific set of bindings. A control counts only when the server rejects the request with that binding removed or altered.
- Highest-yield results: open redirects on registered callback hosts, unenforced PKCE, ID tokens checked only for signature, and accounts linked by email.
- RFC 9700 removes implicit and ROPC and requires exact redirect matching and S256 PKCE. Anything still accepting the old paths goes in the report.
Key takeaways
- OAuth security testing targets trust bindings between parties, not cryptography: redirect matching, state, nonce, PKCE, iss, audience and account keys.
- A control is confirmed only by a server-side rejection of the request with the binding removed or altered.
- PKCE, state, nonce and the RFC 9207 iss parameter each stop a different attack; a multi-issuer OIDC client needs all four.
- Link federated accounts by (iss, sub), never by email, and pin tenants on multi-tenant issuers such as Entra ID.
- For AI agents and MCP, audience-restricted tokens and a ban on token passthrough decide whether prompt injection becomes data theft.
What is OAuth security testing actually testing?
OAuth security testing audits, grant by grant, the trust decisions each party makes about the others. It almost never targets the cryptography. Signatures and TLS hold up in production. What fails is a server or client accepting an assertion without binding it to the request that started the flow.
Map four boundaries first:
- Authorization server to client: redirect_uri matching, client authentication, dynamic registration, scope issuance.
- Client to browser: state, nonce, PKCE, and where tokens land after the redirect.
- Client to issuer: which authorization server produced this response, and whether the token’s iss and aud match.
- Resource server to token: audience, scope, token type and sender constraint.
Keep the protocols straight. OAuth 2.0 (RFC 6749, October 2012) is a delegation framework. OpenID Connect Core 1.0 (final November 2014) adds the ID token and is the authentication layer. The client consumes the ID token; the resource server consumes the access token.
A “Sign in with X” button where the client treats an access token as proof of identity is a design bug before you send a single request.
One rule separates a useful report from a noisy one: a control counts as confirmed only when the server rejects the malformed request. “The SPA never sends that parameter” is not a control, and neither is a check that lives only in the UI.
How do you test OAuth redirect_uri validation for bypasses?
Capture the authorization request, mutate redirect_uri one variant at a time, and record whether the authorization server issues a code to the mutated location or returns an error. Then repeat at the token endpoint. That second comparison is independent, and many servers skip it.
The variant families that still beat hand-rolled or loosely configured matchers:
- Prefix and suffix matching, where the registered host appears as a label or path segment inside a host the tester controls.
- Userinfo tricks, where everything before an @ sign is parsed as credentials rather than the host.
- Path traversal and double slashes that escape the registered callback path.
- Parser differentials: percent-encoding, case, backslashes that browsers treat as slashes, default ports, trailing slashes.
- IDN and punycode homoglyphs of the client domain.
The most damaging finding usually sits on the client. If the registered callback domain hosts an open redirect, an XSS on the callback path or a host-header injection, the code leaks even under exact string matching. Wildcard subdomain registrations add another route: one dangling CNAME and a subdomain takeover hand you a valid callback.
Native apps need their own testing pass. Any app on the device can claim a custom URI scheme, so RFC 8252 recommends claimed HTTPS redirects or loopback with an ephemeral port, plus PKCE. Run the same exact-match tests on post_logout_redirect_uri, which teams often register loosely because “it’s only logout.”

Is PKCE enough, or do you still need state, nonce and iss?
PKCE alone is not enough. PKCE, state and nonce bind different things, and a typical OIDC code flow needs all three, plus the iss response parameter whenever the client trusts more than one issuer.
| Binding | What it ties together | What it stops | Negative test |
|---|---|---|---|
| state (RFC 6749 §10.12) | Authorization response to the browser session that started it | Login CSRF, response injection | Drop or swap state; callback must fail |
| nonce (OIDC Core) | ID token to the original authentication request | ID token replay and injection | Replay an old ID token in a fresh session |
| PKCE S256 (RFC 7636) | Authorization code to the client instance holding code_verifier | Code interception and injection | Redeem with no verifier, a wrong one, or method plain |
| iss parameter (RFC 9207) | Authorization response to the issuer that produced it | Mix-up across issuers | Return a code with a mismatched iss |
PKCE uses a code_verifier of 43 to 128 characters from the unreserved set, sent as BASE64URL(SHA256(code_verifier)). The math is rarely the bug. We find servers that redeem a code with no verifier even though the request carried a challenge, servers that still accept plain, and clients that reuse one verifier across sessions.
PKCE is not client authentication, and state is not user authentication. While you are at the token endpoint, redeem a code twice. RFC 6749 requires single-use codes, recommends a lifetime of at most 10 minutes, and says reuse should revoke tokens already issued from that code. If the first token still works, report it.
Mix-up: the missing issuer binding
A mix-up attack, formalized by Fett, Küsters and Schmitz, targets clients that trust several authorization servers. The victim authorizes at the honest AS, but the client believes the flow belongs to an attacker-controlled AS and redeems the returned code at the attacker’s token endpoint. The attacker now holds a valid code for the victim’s account.
RFC 9207 (2022) adds an iss parameter to the authorization response, advertised via authorization_response_iss_parameter_supported. It closes the attack only if the AS sends it and the client compares it with the issuer stored in session before redemption. Checking iss inside the ID token is too late: the code has already left.
To test, stand up a second issuer in staging, start a flow against one and return a response labeled as the other. Distinct redirect URIs per issuer are an acceptable older mitigation. A shared callback with no iss check is a finding.
What must a relying party check before it trusts a token?
Signature verification is the easy part. A relying party that stops there accepts tokens minted for other clients, other issuers and earlier sessions. Minimum checks for an OIDC ID token:
- Signature against the issuer’s JWKS, with an algorithm allowlist set by the RP, never by the token header.
- Exact
iss;audcontaining the client_id, plusazpwhen there are multiple audiences. exp,iatandnbfwith tight clock skew.nonceequal to the stored value;at_hashorc_hashwhere the flow returns them.acrandamrwhen the RP requested step-up. Asking for MFA throughacr_valuesand never checking the result silently accepts password-only sessions.
Header attacks still land against custom validation code: alg: none, HS256 versus RS256 key confusion, jku, x5u or jwk headers pointing at an attacker key set, and kid path traversal. Also submit an access token where the RP expects an ID token. If it verifies, the RP accepts it.
Where tokens live after the redirect
For most web apps, access tokens should not live in the browser. The Backend-for-Frontend (BFF) pattern keeps them server-side and gives the browser only an HttpOnly, SameSite session cookie. Leaks we still find: tokens in URL fragments that reach history and Referer, postMessage handlers without origin checks, localStorage, and APM traces or proxy logs.
Browser privacy changes push teams toward bad workarounds. Chrome 80’s SameSite=Lax default (February 2020) breaks form_post postbacks unless the cookie is SameSite=None, and third-party cookie blocking breaks prompt=none iframe renewal. The fix that ships under pressure is a long-lived refresh token in localStorage. Look for it.
Public-client refresh tokens need rotation with reuse detection: replay an old one and the whole token family should die. DPoP (RFC 9449) or mTLS (RFC 8705) make theft harder still, but only if the resource server rejects plain Bearer for the same scopes. Strip the DPoP proof and resend as Bearer. That downgrade is the test.
How does Sign in with Google or Microsoft become account takeover?
“Sign in with X” becomes account takeover when the application links federated identities to local accounts by email instead of by the pair (iss, sub). OIDC Core requires sub to be unique and never reassigned within one issuer. It guarantees nothing about email, which is mutable and often unverified.
The nOAuth issue, disclosed by Descope in 2023, is the reference case. Microsoft Entra ID let the email claim carry an unverified, user-editable value in multi-tenant apps, so SaaS products that merged accounts by email handed a victim’s account to anyone who set that address in a tenant they controlled.
- Email linking: log in from an IdP or tenant where you control the email value. Does the app merge into an existing account? Is
email_verifiedchecked? - sub collisions: with two IdPs configured, is
substored without its issuer? - Link-flow CSRF: can an attacker attach their IdP identity to a victim’s session because the linking callback lacks state?
- Pre-hijacking: Sudhodanan and Paverd (2022) showed that variants such as the classic-federated merge and trojan identifier let an attacker register first and keep access after the victim’s federated login.
Multi-tenant issuers need a dedicated test. An app registered against Entra ID’s common or organizations endpoint accepts identities from any tenant someone can create unless it pins the expected tid or validates the per-tenant issuer. Auth0, Okta, Keycloak and Amazon Cognito federations with “trust email” settings fail the same way.
Device code phishing and illicit consent
Both abuse flows that work exactly as designed. The attacker starts a Device Authorization Grant (RFC 8628) and sends the user_code under a pretext. The victim enters it on the real Microsoft page, completes MFA, and the attacker’s polling client receives tokens. In February 2025, Microsoft Threat Intelligence described such a campaign against Microsoft 365, tracked as Storm-2372.
Illicit consent grants use a multi-tenant app with a convincing name; once consented, its Graph or Google Workspace scopes survive password resets. In a configuration review, verifying exposure reduces to checking restricted user consent, verified-publisher policy, Conditional Access blocks on device code flow, and service principal reviews. Our Entra ID security assessment tests tenant pinning and consent policy together, because they usually fail together.

What do RFC 9700 and OAuth 2.1 force you to turn off?
RFC 9700, the OAuth 2.0 Security Best Current Practice published in January 2025, and the OAuth 2.1 draft remove the legacy paths attackers downgrade to. Treat each as a finding if any registered client can still use it:
- The implicit grant (
response_type=token). - The resource owner password credentials grant (
grant_type=password). - Access tokens in query parameters.
- Any redirect_uri matching other than exact string comparison.
- Code flow without PKCE, or PKCE with
plain, including for confidential clients.
“Only legacy clients use it” is not a mitigation. An attacker needs one accepted legacy path, and they choose which client_id to present.
Also test the token endpoint for gaps the BCP leaves open. Send client_id in both the Basic header and the form body and see which one the server authenticates and which it authorizes. Check whether dynamic client registration (RFC 7591) works without an initial access token. Request privileged scopes and watch for issuance without a fresh consent prompt.
For token exchange (RFC 8693), try trading a low-privilege subject token for a broader audience. For client credentials, look for secrets in repos and CI, and replay a private_key_jwt assertion to confirm jti is enforced.
How do you secure OAuth for AI agents and MCP servers?
Treat an AI agent as an OAuth client whose instructions an attacker can partially write. The Model Context Protocol authorization specification builds on OAuth 2.1 with PKCE and RFC 8707 resource indicators, and it forbids token passthrough: an MCP server must not accept a token issued for another audience and forward it upstream.
- Token passthrough: the upstream API sees a token minted for a different audience, and the MCP server’s own logging and rate limits are bypassed.
- Confused deputy: an MCP proxy using a static client_id with a third-party AS lets a malicious dynamically registered client ride an existing consent and obtain a code without a fresh prompt.
- Missing resource indicators: one broad-audience token replays across every service the agent touches.
- Long-lived, wide-scope refresh tokens: a single indirect prompt injection becomes delegated data exfiltration, the pattern OWASP files under LLM06 Excessive Agency.
Test by issuing a token for one MCP server and presenting it to another, by reading aud on every token the agent holds, and by planting an indirect injection that asks for a scope the task never needed. Our MCP server and tool-chain security testing runs these chains; scoring is covered in how to test excessive agency in AI agents.
The thread through every section is the same. Each grant has a short list of bindings, and each binding has a negative test. A report that proves enforcement with a rejected request, or proves absence with a captured token, is worth paying for.

FAQ
What is the difference between state and nonce?
state binds the authorization response to the browser session that started the flow and stops login CSRF. nonce binds the ID token to the original authentication request and stops token replay. They are not interchangeable, and an OIDC code flow typically needs both.
Is PKCE only for public clients?
No. PKCE was designed for public clients, but RFC 9700 and OAuth 2.1 require it for confidential clients too, because it also blocks code injection. Only the S256 method should be accepted.
Which OAuth flows should be disabled under RFC 9700?
The implicit grant and the resource owner password credentials grant, along with access tokens in query strings and any redirect_uri matching other than exact string comparison. If any registered client still accepts them, it is a finding.
What is the BFF pattern?
Backend-for-Frontend keeps access and refresh tokens on the server and gives the browser only an HttpOnly, SameSite session cookie, so an XSS cannot read tokens directly.
What is MCP token passthrough?
An MCP server accepting a token issued for another audience and forwarding it to an upstream API. The MCP authorization specification forbids it because it bypasses audience checks, logging and rate limits.
If you want these chains run against your own identity provider, clients and agents, with every finding backed by a server-side rejection test, our team does that in OAuth, OIDC and SAML SSO security testing.