RFC 9207 in Practice: Checking iss on the Callback When Your App Trusts Several IdPs

If your app signs users in through more than one identity provider, your OAuth callback has to answer a question the original protocol never let it ask: which server actually issued this code? RFC 9207 adds an iss parameter to the authorization response so it can. The fix is three lines of logic in the callback. Before redirecting, record the issuer you sent the user to. On return, compare iss to it with exact string equality. Reject on mismatch, before the code goes anywhere near a token endpoint.
This guide is written against RFC 9207 (OAuth 2.0 Authorization Server Issuer Identification, March 2022, Standards Track), RFC 9700 (OAuth 2.0 Security Best Current Practice, January 2025, BCP 240) Section 4.4, the OAuth 2.1 Internet-Draft draft-ietf-oauth-v2-1-16 (3 September 2026), OpenID Connect Core 1.0 and Discovery 1.0 incorporating errata set 2, and the MCP authorization specification revision 2026-07-28, all retrieved 2026-10-21. It adds working callback code to our earlier, architecture-level guide to OIDC with multiple identity providers. Where a conclusion is our reading rather than a source’s statement, it is marked ANALYSIS.
Key Takeaways
- Mix-up only threatens clients with two or more authorization servers, and any one of them can be the attacker. RFC 9207 states that “OAuth clients that interact with only one authorization server are not vulnerable to mix-up attacks,” but the moment you add a second, you “become vulnerable and need to apply countermeasures” (RFC 9207 §1, retrieved 2026-10-21).
- The defense is mandatory once you have two. “In scenarios where an OAuth client interacts with two or more authorization servers, however, clients MUST prevent mix-up attacks” (RFC 9700 §4.4.2, retrieved 2026-10-21). OAuth 2.1 repeats the same MUST (draft-ietf-oauth-v2-1-16 §2.3.4, retrieved 2026-10-21).
- The comparison is exact. It “MUST use simple string comparison as defined in Section 6.2.1 of [RFC3986],” and on mismatch clients “MUST reject the authorization response and MUST NOT proceed with the authorization grant” (RFC 9207 §2.4, retrieved 2026-10-21). No trailing-slash or case cleanup.
- PKCE and
statedo not stop it. The client hands its owncode_verifierto the attacker’s token endpoint, as the MCP security guidance notes (MCP Security Best Practices, retrieved 2026-10-21). ANALYSIS:stateround-trips correctly too, because the session it binds is the user’s own.- The ID token’s
issarrives too late in the plain code flow. RFC 9207 accepts an ID token as an alternative only when it comes “from the authorization endpoint (e.g.,response_type=code id_token)” (RFC 9207 §4, retrieved 2026-10-21). Withresponse_type=codeit comes back from the token endpoint, after the code has already left.- MCP clients now have to do this. They “MUST apply the validation in RFC9207 Section 2.4 before transmitting the authorization code to any token endpoint” (MCP Authorization, 2026-07-28, retrieved 2026-10-21).
On this page: the attack · why PKCE and state miss it · the iss parameter · the code · when iss is missing · distinct redirect URIs · tests · how this was sourced · FAQ · wrap-up
How a Mix-Up Attack Steals a Code From a Multi-IdP App
The attacker does not need to break any provider. It needs to be one of your providers, or to have compromised one.
RFC 9207 lists the routes in: “an authorization server could become compromised, or the attacker could register their own authorization server, for example, using dynamic client registration” (RFC 9207 §1, retrieved 2026-10-21). For a consumer app, the second route is not exotic. Any app that lets a tenant, a partner, or a user configure “bring your own OIDC provider” accepts an issuer it does not control.
RFC 9700 describes the canonical attack against the authorization code grant. Its preconditions are that the client works with an honest server (H-AS) and an attacker-run one (A-AS), and that it “stores the authorization server chosen by the user in a session bound to the user’s browser and uses the same redirection URI for each authorization server” (RFC 9700 §4.4.1, retrieved 2026-10-21). That is the default design of most multi-IdP logins: one /callback, and a session value saying which button was clicked.
The steps, condensed from §4.4.1:
- The user starts sign-in with A-AS. Your app records “A-AS” in the session and redirects to A-AS.
- A-AS immediately redirects the browser to H-AS, swapping in your app’s client ID at H-AS.
- The user signs in at H-AS, which they trust, and H-AS sends a code back to your shared callback.
- Your app still believes the flow is with A-AS, so “it will try to redeem the code at A-AS’s token endpoint.”
- The attacker now holds an H-AS code and can redeem it (for public clients) or inject it.
RFC 9700 also describes a variant with no suspicious first click. If the attacker can intercept the user’s first request to your app, “the user starts the flow with H-AS. The attacker intercepts this request and changes the user’s selection to A-AS” (RFC 9700 §4.4.1, retrieved 2026-10-21).
Four vertical lanes, left to right: your app, the user’s browser, the attacker’s authorization server, and the honest authorization server. Step 1: your app records the expected issuer as the attacker’s server and redirects the browser there. Step 2: the attacker’s server immediately redirects the browser to the honest server, swapping in your app’s client ID at the honest server. Step 3: the user signs in at the honest server, which returns an authorization code to your shared callback together with iss set to the honest server’s issuer. Step 4: your app compares that iss value with the issuer it recorded, finds the honest issuer does not equal the recorded attacker issuer, and rejects the response. A dashed orange arrow at the bottom shows what happens without the check: your app sends the honest server’s code and its own PKCE code verifier to the attacker’s token endpoint. Sources: RFC 9700 section 4.4.1 and RFC 9207, retrieved 2026-10-21.
The honest server’s code comes back to a callback that expects the attacker
Condensed from RFC 9700 §4.4.1. The check in step 4 is RFC 9207 §2.4.
Your app
Browser
Attacker AS
Honest AS
1 record issuer = attacker, redirect via browser
2 bounce to H,
swap client_id
3 user signs in at H; code + iss=https://h.example returned
4 iss (honest) ≠ recorded (attacker)
reject. The code is never sent anywhere.
Without step 4: code + your code_verifier go to the attacker’s token endpoint
Sources: RFC 9700 §4.4.1 (January 2025); RFC 9207 §2.4 (March 2022). Retrieved 2026-10-21.
Why PKCE, state and the ID Token Do Not Catch It
Each of the defenses you already have is working correctly during this attack. That is the problem.
PKCE. The MCP security guidance states it plainly: “PKCE alone does not prevent this attack because the client transmits the code_verifier to the attacker’s token endpoint” (MCP Security Best Practices, Mix-Up Attacks, retrieved 2026-10-21). PKCE proves the token request comes from whoever started the flow. Your app did start the flow. It is just sending the proof to the wrong place.
state. ANALYSIS: state defends against a forged response arriving in a session that did not start a flow. In a mix-up, the response arrives in exactly the session that started it, carrying the state value your app generated, because H-AS echoes whatever the browser brought. The value matches. Keep validating it, as covered in our state parameter guide. It answers a different question.
The ID token’s iss claim. OpenID Connect Core requires that “the Issuer Identifier for the OpenID Provider … MUST exactly match the value of the iss (issuer) Claim” (OpenID Connect Core 1.0 §3.1.3.7, errata set 2, retrieved 2026-10-21). That check is required. But RFC 9207 treats an ID token as a mix-up defense only when it is returned “from the authorization endpoint (e.g., response_type=code id_token)” (RFC 9207 §4, retrieved 2026-10-21). ANALYSIS: with response_type=code, the ID token comes back in the token response. You only get it after posting the code and verifier to a token endpoint. If that endpoint belongs to the attacker, the check fails after the theft, not before it.
| Control | What it proves | Holds during a mix-up? |
|---|---|---|
PKCE code_verifier |
The token request comes from the party that started the flow | Yes, and the verifier goes to the attacker |
state |
The response belongs to a flow this browser session started | Yes, the value matches |
ID token iss (code flow) |
The token response came from the expected issuer | Checked after the code has left |
Authorization response iss (RFC 9207) |
The authorization response came from the issuer you sent the user to | No: it mismatches and stops the flow |
What RFC 9207 Adds to the Authorization Response
One parameter, one metadata flag, one comparison rule.
The parameter. “In authorization responses to the client, including error responses, an authorization server supporting this specification MUST indicate its identity by including the iss parameter in the response.” Its value is the server’s RFC 8414 issuer identifier, and it “MUST be a URL that uses the “https” scheme without any query or fragment components” (RFC 9207 §2, retrieved 2026-10-21). The RFC’s own example:
HTTP/1.1 302 Found
Location: https://client.example/cb?
code=x1848ZT64p4IirMPT0R-X3141MFPTuBX-VFL_cvaplMH58
&state=ZWVlNDBlYzA1NjdkMDNhYjg3ZjUxZjAyNGQzMTM2NzI
&iss=https%3A%2F%2Fhonest.as.example
The flag. A server publishing RFC 8414 metadata “MUST indicate its support for the iss parameter by setting the metadata parameter authorization_response_iss_parameter_supported … to true,” and “if omitted, the default value is false” (RFC 9207 §2.3 and §3, retrieved 2026-10-21). The issuer in metadata “MUST be identical to the iss parameter’s value.”
The comparison. Clients decode the value from application/x-www-form-urlencoded form, then compare it “to the issuer identifier of the authorization server where the authorization request was sent to,” using simple string comparison per RFC 3986 §6.2.1 (RFC 9207 §2.4, retrieved 2026-10-21). MCP spells out what that rules out: clients “MUST NOT apply scheme or host case folding, default-port elision, trailing-slash, or percent-encoding normalization” (MCP Authorization, 2026-07-28, retrieved 2026-10-21).
Two more rules in RFC 9207 are easy to miss, and both matter for the code below:
- Errors are covered. “For error responses, clients MUST NOT assume that the error originates from the intended authorization server” (§2.4). Check
issbefore you showerror_descriptionto anyone. - Issuers must be unique. Clients “MUST NOT allow multiple authorization servers to use the same issuer identifier,” and where provider details are configured by hand, “the client MUST ensure that the accepted
issvalues are unique for each authorization server” (§4).
The iss parameter is not signed. RFC 9207 explains why that is fine: in a mix-up, the client gets the response from the uncompromised server, and an attacker able to tamper with that response “would also have direct access to the authorization code” anyway (§4). Integrity protection is not needed for this defense.
The Callback Code: Record, Compare, Then Redeem
The order of operations is the whole defense. The issuer you compare against must come from your own stored record, never from anything in the response.
RFC 9700 states the storage rule: “clients MUST store, for each authorization request, the issuer they sent the authorization request to and bind this information to the user agent.” It adds a warning: “just storing the authorization server URL is not sufficient,” because an attacker “might declare an uncompromised authorization server’s authorization endpoint URL as “their” authorization server URL, but declare a token endpoint under their own control” (RFC 9700 §4.4.2, retrieved 2026-10-21). ANALYSIS: so key everything off the issuer, and load every endpoint from that issuer’s validated metadata. Never let a provider’s config carry an authorization endpoint and a token endpoint that came from different places.
The TypeScript below runs on Node 18 or later, using only built-ins. Session storage is whatever you already have. It must be server-side or encrypted, and bound to the browser.
Load and validate each provider once
import { randomBytes, createHash } from "node:crypto";
type Provider = {
key: string; // "google", "acme-sso", ...
issuer: string; // exactly as configured, exactly as compared
authorizationEndpoint: string;
tokenEndpoint: string;
issParamSupported: boolean; // RFC 9207 §3, default false
clientId: string;
redirectUri: string;
};
async function loadProvider(key: string, issuer: string,
clientId: string, redirectUri: string): Promise<Provider> {
// OIDC Discovery: strip one trailing slash, append the well-known path.
const url = issuer.replace(//$/, "") + "/.well-known/openid-configuration";
const meta = await (await fetch(url)).json();
// OIDC Discovery §4.3 / RFC 8414 §3.3: the document must name the issuer we asked for.
if (meta.issuer !== issuer) {
throw new Error(`${key}: metadata issuer ${meta.issuer} != configured ${issuer}`);
}
return {
key, issuer, clientId, redirectUri,
authorizationEndpoint: meta.authorization_endpoint,
tokenEndpoint: meta.token_endpoint,
issParamSupported: meta.authorization_response_iss_parameter_supported === true,
};
}
function indexByIssuer(providers: Provider[]): Map<string, Provider> {
const byIssuer = new Map<string, Provider>();
for (const p of providers) {
// RFC 9207 §4: accepted iss values MUST be unique per authorization server.
if (byIssuer.has(p.issuer)) throw new Error(`duplicate issuer ${p.issuer}`);
byIssuer.set(p.issuer, p);
}
return byIssuer;
}
Both checks run at startup or on config change, not per login. The metadata check is what stops a provider entry that claims someone else’s issuer. OpenID Connect Discovery describes exactly that attack: a document “that contains an issuer Claim using the Issuer URL of the OP being impersonated, but with its own endpoints and signing keys” (OpenID Connect Discovery 1.0 §7.2, errata set 2, retrieved 2026-10-21). For the rest of discovery, including caching and key rotation, see OIDC discovery and provider configuration.
Start the flow: record the issuer next to the verifier
const b64url = (b: Buffer) => b.toString("base64url");
type Pending = { issuer: string; verifier: string; nonce: string; createdAt: number };
function startLogin(session: { pending?: Record<string, Pending> },
p: Provider): string {
const state = b64url(randomBytes(32));
const verifier = b64url(randomBytes(32));
const nonce = b64url(randomBytes(16));
session.pending ??= {};
session.pending[state] = { issuer: p.issuer, verifier, nonce, createdAt: Date.now() };
const u = new URL(p.authorizationEndpoint);
u.search = new URLSearchParams({
response_type: "code",
client_id: p.clientId,
redirect_uri: p.redirectUri,
scope: "openid email",
state,
nonce,
code_challenge: b64url(createHash("sha256").update(verifier).digest()),
code_challenge_method: "S256",
}).toString();
return u.toString(); // 302 the browser here
}
Keying pending flows by state lets a user run two tabs at once without one overwriting the other’s expected issuer. MCP requires the same shape: the client “MUST record the issuer value from the selected authorization server’s validated metadata document … and associate it with the same per-request record used to store the PKCE code verifier” (MCP Authorization, 2026-07-28, retrieved 2026-10-21).
Handle the callback: iss before error, iss before code
class Rejected extends Error {}
function one(params: URLSearchParams, name: string): string | undefined {
const all = params.getAll(name);
if (all.length > 1) throw new Rejected(`repeated ${name}`);
return all[0];
}
async function handleCallback(session: { pending?: Record<string, Pending> },
callbackUrl: string,
byIssuer: Map<string, Provider>) {
// URLSearchParams does the form-urlencoded decoding RFC 9207 §2.4 asks for.
const params = new URL(callbackUrl).searchParams;
// 1. Find this flow's record by state, and burn it whatever happens next.
const state = one(params, "state");
const pending = state ? session.pending?.[state] : undefined;
if (!pending) throw new Rejected("unknown or replayed state");
delete session.pending![state!];
if (Date.now() - pending.createdAt > 10 * 60_000) throw new Rejected("flow expired");
// 2. The provider comes from OUR record, never from the response.
const p = byIssuer.get(pending.issuer);
if (!p) throw new Rejected("provider removed mid-flow");
// 3. RFC 9207 §2.4: exact comparison, no normalization.
const iss = one(params, "iss");
if (iss !== undefined) {
if (iss !== pending.issuer) throw new Rejected("iss mismatch: possible mix-up");
} else if (p.issParamSupported) {
throw new Rejected("iss missing from a provider that advertises it");
}
// 4. Only now is the error trustworthy enough to act on or display.
const error = one(params, "error");
if (error) throw new Rejected(`provider error: ${error}`);
// 5. Redeem at the recorded issuer's token endpoint.
const code = one(params, "code");
if (!code) throw new Rejected("no code");
const res = await fetch(p.tokenEndpoint, {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "authorization_code",
code,
redirect_uri: p.redirectUri,
client_id: p.clientId,
code_verifier: pending.verifier,
}),
});
const tokens = await res.json();
// 6. Validate the ID token with your JOSE library: signature via the
// issuer's JWKS, iss === pending.issuer, aud includes p.clientId,
// nonce === pending.nonce, exp in the future.
return { provider: p, tokens, expectedNonce: pending.nonce };
}
Four details carry the security here:
- Step 2 reads the issuer from the session record. Nothing in the query string chooses the provider. If your current callback is
/callback?provider=google, that query value is attacker-controlled input. !==is the comparison.https://h.exampleandhttps://h.example/are different strings, and the spec wants them treated as different. If a real provider fails this, fix the configured issuer to match its metadata byte for byte. Do not loosen the check.- The
isscheck runs beforeerroris read. That follows RFC 9207 §2.4 on error responses, and MCP’s rule that “on mismatch the client MUST NOT act on or displayerror,error_description, orerror_uri” (MCP Authorization, 2026-07-28, retrieved 2026-10-21). - Repeated parameters are rejected. ANALYSIS: RFC 9207 does not address a response carrying two
issvalues. Taking the first or last silently would let a crafted URL pick which one you check. If you useresponse_mode=form_post, read the same fields from the POST body instead of the query string.
Step 6 is still required, even though it is not the mix-up defense. Our ID token validation guide walks through each claim.
Six boxes stacked top to bottom in the order the callback runs them. Box 1, slate: look up the pending flow by state and delete it so it cannot be replayed. Box 2, slate: take the provider from that stored record, not from the response. Box 3, blue and highlighted: compare the iss parameter with the recorded issuer by exact string equality, and reject if it is missing from a provider that advertises support. Box 4, slate: only now read error or code. Box 5, slate: post the code and the PKCE verifier to the recorded issuer’s token endpoint. A horizontal orange line between boxes 4 and 5 is labelled “the code leaves your server here”. Box 6, slate: validate the ID token signature, iss, aud and nonce. A note beside box 6 says that in the plain code flow this iss check runs after the code has left, so it cannot prevent a mix-up. Sources: RFC 9207 sections 2.4 and 4, OpenID Connect Core 1.0 section 3.1.3.7, retrieved 2026-10-21.
Only one issuer check runs before the code leaves
The callback above, as an ordered pipeline
1 Find pending flow by state, then delete it
2 Provider = stored record, not the response
3 iss === recorded issuer (RFC 9207 §2.4)
missing + advertised → reject
4 Only now read error or code
the code leaves here
5 POST code + verifier to recorded token endpoint
6 ID token: signature, iss, aud, nonce
Required, but in the
code flow it runs too late
to stop a mix-up
Sources: RFC 9207 §2.4, §4; OpenID Connect Core 1.0 §3.1.3.7. Retrieved 2026-10-21.
What to Do When a Provider Does Not Send iss
Support is per provider, so your client has to track it per provider. The code above does that with issParamSupported.
RFC 9207 requires it: clients talking to both kinds of server “MUST retain state about whether each authorization server supports the iss parameter” and “MUST reject authorization responses without the iss parameter from authorization servers that do support the parameter” (RFC 9207 §2.4, retrieved 2026-10-21).
The protection is only as wide as your providers’ support. The MCP guidance says so directly: “This mitigation depends on honest authorization servers emitting iss; it provides no protection against an honest server that does not” (MCP Security Best Practices, Mix-Up Attacks, retrieved 2026-10-21). ANALYSIS: the honest server is the one whose code gets stolen, so it is that server’s support that counts, not the attacker’s.
Sending iss is not required of servers today. RFC 9207 binds only servers that choose to support it, and the MCP specification still makes inclusion a SHOULD for authorization servers, and says “a future revision of this specification is expected to upgrade authorization server inclusion of iss from SHOULD to MUST” (MCP Authorization, 2026-07-28, retrieved 2026-10-21). We do not publish a survey of which providers send it. Check your own instead:
curl -s https://accounts.example.com/.well-known/openid-configuration
| jq '{issuer, authorization_response_iss_parameter_supported}'
Then work through the four cases:
| Metadata flag | iss in response |
RFC 9207 §2.4 | MCP 2026-07-28 |
|---|---|---|---|
true |
present | Compare, reject on mismatch | Compare, reject on mismatch |
true |
absent | MUST reject | Reject |
false / absent |
present | SHOULD discard; local policy may accept | Compare to recorded issuer |
false / absent |
absent | MAY accept, by local policy | Proceed |
The third row is where the two documents differ. RFC 9207 says clients “SHOULD discard” an iss from a server that does not advertise support, then concedes “there might be legitimate authorization servers that provide the iss parameter without indicating their support.” MCP picks the comparison, “to accommodate authorization servers that emit iss before updating their metadata” (MCP Authorization, 2026-07-28, retrieved 2026-10-21). ANALYSIS: the code above follows MCP. A present iss that matches costs nothing to accept, and a present iss that mismatches is the attack.
For providers in the fourth row, you have two other options. If the provider supports it, use response_type=code id_token, so an ID token arrives from the authorization endpoint and its iss can be checked before redemption. RFC 9207 allows this, adding that if “a client receives an authorization response that contains multiple issuer identifiers, the client MUST reject the response if these issuer identifiers do not match” (§4). Or fall back to distinct redirect URIs.
Distinct Redirect URIs Are the Fallback, Not the Fix
Giving each provider its own callback path is the older defense. RFC 9700 ranks it second.
The rule: “clients MUST use a distinct redirection URI for each issuer they interact with,” and check that the response arrived on the URI assigned to the expected issuer (RFC 9700 §4.4.2.2, retrieved 2026-10-21). It needs no provider support. It has two stated weaknesses:
- It “cannot be used in scenarios where clients only register once for the use of many different issuers,” and is “harder to deploy automatically.”
- An attacker “might be able to circumvent the protection … by registering a new client with the “honest” authorization server using the redirect URI that the client assigned to the attacker’s authorization server.”
RFC 9700’s conclusion: “This defense SHOULD therefore only be used if other options are not available.” The issuer defense, by contrast, it calls “a robust and relatively simple defense against mix-up” (§4.4.2.1).
Per-provider paths also have a trap of their own. RFC 9700 lists “Cross Social-Network Request Forgery” as a variant that works when clients use different redirect URIs but “do not store the selected authorization server in the user’s session, and authorization servers do not check the redirection URIs properly” (§4.4.1). ANALYSIS: so if you use distinct paths, still store the expected issuer per flow and check the path against it. The path alone is not enough. Exact redirect URI matching at each provider is a precondition either way. Our redirect URI validation guide covers that side.
Tests That Prove the Check Works
Each test drives handleCallback with a hand-built callback URL. None needs a live provider, because every rejection must happen before the token request.
import assert from "node:assert/strict";
const H = "https://h.example";
const A = "https://a.example";
const providers = indexByIssuer([
{ key: "h", issuer: H, authorizationEndpoint: H + "/authorize", tokenEndpoint: H + "/token",
issParamSupported: true, clientId: "app-at-h", redirectUri: "https://app.example/cb" },
{ key: "a", issuer: A, authorizationEndpoint: A + "/authorize", tokenEndpoint: A + "/token",
issParamSupported: false, clientId: "app-at-a", redirectUri: "https://app.example/cb" },
]);
const flow = (issuer: string) => ({
pending: { s1: { issuer, verifier: "v", nonce: "n", createdAt: Date.now() } },
});
const cb = (q: string) => `https://app.example/cb?state=s1&${q}`;
// The mix-up: flow started with A, response carries H's iss.
await assert.rejects(handleCallback(flow(A), cb(`code=c&iss=${encodeURIComponent(H)}`), providers),
/iss mismatch/);
// Stripped iss from a provider that advertises support.
await assert.rejects(handleCallback(flow(H), cb("code=c"), providers), /iss missing/);
// Trailing slash is a different issuer.
await assert.rejects(handleCallback(flow(H), cb(`code=c&iss=${encodeURIComponent(H + "/")}`), providers),
/iss mismatch/);
// Forged error from the wrong issuer is not surfaced as a provider error.
await assert.rejects(handleCallback(flow(A), cb(`error=access_denied&iss=${encodeURIComponent(H)}`), providers),
/iss mismatch/);
// Two iss values.
await assert.rejects(handleCallback(flow(H), cb(`code=c&iss=${encodeURIComponent(H)}&iss=${encodeURIComponent(A)}`), providers),
/repeated iss/);
// Two configured providers sharing an issuer fail at load time.
assert.throws(() => indexByIssuer([...providers.values(), { ...providers.get(H)!, key: "h2" }]),
/duplicate issuer/);
The happy path, a matching iss reaching the token endpoint, needs a stubbed fetch, which your test setup already has or does not. The six rejections above are the ones that matter. If any of them passes, the defense is not there.
If you are building an MCP client rather than a web login, the same function applies, because RFC 9207 is now part of MCP’s flow. Our MCP authorization walkthrough covers the rest of that client.
How This Guide Was Sourced
Written by the MojoAuth engineering and content team (authors, mojoauth.com).
Normative claims are drawn from these documents, all retrieved 2026-10-21. Quoted passages are verbatim. Passages marked ANALYSIS are MojoAuth’s reading, not statements from any source.
- RFC 9207, OAuth 2.0 Authorization Server Issuer Identification, March 2022, Standards Track. Sections 1, 2, 2.3, 2.4, 3 and 4.
- RFC 9700, OAuth 2.0 Security Best Current Practice, January 2025, BCP 240. Section 4.4 and its subsections.
- draft-ietf-oauth-v2-1-16, The OAuth 2.1 Authorization Framework, 3 September 2026, Internet-Draft. Section 2.3.4.
- OpenID Connect Core 1.0 incorporating errata set 2, dated 15 December 2023, Section 3.1.3.7; and OpenID Connect Discovery 1.0 incorporating errata set 2, Section 7.2.
- MCP Authorization specification, revision 2026-07-28, section Authorization Response Validation; and the 2026-07-28 Security Best Practices, section Mix-Up Attacks.
The attack and its formal analysis come from research that RFC 9207 cites: On the security of modern Single Sign-On Protocols: Second-Order Vulnerabilities in OpenID Connect (arXiv:1508.04324, August 2015) and A Comprehensive Formal Security Analysis of OAuth 2.0 (arXiv:1601.01229, January 2016). RFC 9207 says the iss parameter’s effectiveness “was analyzed and formally proven” in the latter.
Pin your reading. RFC 9207, RFC 9700 and the OpenID Connect errata sets are fixed documents. OAuth 2.1 is still a draft: the mix-up section is §7.14 in -15 (2 March 2026) and §7.15 in -16, so section numbers move between versions. The MCP text quoted is from revision 2026-07-28, which says the iss inclusion requirement is expected to change from SHOULD to MUST. Check the revision you target.
The code was written for this guide to show the order of checks. It uses only Node built-ins and is not taken from any library. Use your existing OAuth and JOSE libraries for the token request and ID token validation, and check that they expose the authorization response iss to you, or validate it themselves before redeeming the code.
Disclosure: MojoAuth sells consumer authentication, including social and enterprise sign-in, and builds Silent Auth, a carrier-network verification product. Everything in this guide applies to a client that uses MojoAuth as one of its providers too. Your app has to record the issuer and compare iss whichever servers are on the list.
No MojoAuth telemetry is used in this guide. No figures are cited; every requirement above is external and linked.
Frequently Asked Questions
Do I need RFC 9207 if my app only uses one identity provider?
No, not today. RFC 9207 says clients with one authorization server “are not vulnerable to mix-up attacks.” But the same section warns that adding a second makes you vulnerable. ANALYSIS: the check costs a few lines, and a “Sign in with X” button added next year is the second server. Recording the issuer now means the new provider ships protected.
Does PKCE protect against mix-up attacks?
No. In a mix-up, your client sends its own code_verifier to the attacker’s token endpoint, together with the stolen code. PKCE stops someone else redeeming your code. It cannot stop you redeeming it at the wrong server. The defense is comparing the authorization response’s iss to the issuer you recorded before redirecting.
Is checking the iss claim in the ID token enough?
Only if the ID token comes back from the authorization endpoint, for example with response_type=code id_token. RFC 9207 §4 accepts that as an alternative. In the plain response_type=code flow, the ID token arrives in the token response, after the code has been posted. Keep the ID token iss check, since OpenID Connect Core requires it, but do not count it as your mix-up defense.
Should I normalize trailing slashes or letter case before comparing iss?
No. RFC 9207 requires simple string comparison, and MCP explicitly forbids case folding, default-port elision, trailing-slash and percent-encoding normalization. If a provider’s iss does not match your configured issuer exactly, update your configuration to the exact issuer from its metadata document.
What if my identity provider does not send the iss parameter?
Record per provider whether its metadata sets authorization_response_iss_parameter_supported to true. Where it does, reject responses without iss. Where it does not, use response_type=code id_token if the provider supports it, or give that provider its own redirect URI and check that the response arrived on it. RFC 9700 says the redirect URI defense “SHOULD only be used if other options are not available.”
Can a single shared callback URL be safe with several IdPs?
Yes, if every flow stores its expected issuer server-side and the callback compares iss to it before anything else. RFC 9700’s attack assumes a shared redirect URI without an issuer check. With the check, the shared URI is fine. The provider must come from your stored record, never from a query parameter like ?provider=.
Conclusion
A mix-up attack works because the plain authorization response does not say who sent it. RFC 9207 fixes that with one parameter. Your callback has to use it in the right order:
- Validate each provider’s metadata once, and refuse two providers with the same issuer.
- Store the issuer with the PKCE verifier and nonce, keyed by
state. - On return, compare
issexactly, before readingerrorand before redeemingcode. - Reject a missing
issfrom any provider that advertises support.
PKCE, state and ID token validation all stay. None of them replaces this check, because each one passes during the attack.
For the wider design of a login with several providers, start with implementing OIDC with multiple identity providers. Then run the six rejection tests above against your own callback.

