Safeguard
AI Security•

Does PKCE stop an OAuth mix-up attack on MCP clients?

No. PKCE alone does not stop a mix-up attack, because the client sends its code verifier to the attacker. The MCP draft requires issuer checks. See how.

Safeguard Security Team
3 min read

No. The MCP security guidance says PKCE alone does not prevent a mix-up attack, because the client sends its code verifier to the attacker's token endpoint. The defense is to record the expected issuer before redirecting, then compare the iss value in the response before sending the authorization code anywhere.

What a mix-up attack is

An MCP client talks to many authorization servers over its life. If an attacker controls one of them, they may try to make the client send a code or token meant for an honest server to the attacker's server instead. The attack is described in RFC 9207.

PKCE protects against a stolen authorization code being used by someone without the verifier. In a mix-up, the client itself hands over the verifier, so PKCE cannot help. Resource indicators do not help either when the attacker's server intercepts requests before they reach the honest one.

The draft's defense

The authorization section requires clients to record the issuer from the validated metadata of the chosen authorization server before redirecting the user, and store it with the PKCE verifier and state. When the response comes back, they must validate it before transmitting the code to any token endpoint.

Server advertises iss supportiss in responseClient action
YesPresentCompare with the recorded issuer
YesAbsentReject
No or unknownPresentCompare with the recorded issuer
No or unknownAbsentProceed

The comparison is a simple string comparison with no case folding, port elision, trailing slash or percent encoding normalization. On a mismatch, the client must not act on or display the error fields either.

Limits to know

The protection depends on the recorded issuer being authentic, so it must come from validated metadata. It also depends on honest servers emitting iss. The guidance states it gives no protection against an honest server that does not. The draft expects a future revision to raise server inclusion of iss from should to must.

What to do

The fix is small for client builders and cheap to test. Keep the checklist short and make it part of release checks.

  1. If you build a client, implement issuer recording and validation now.
  2. If you run an authorization server, emit iss and advertise support in your metadata.
  3. If you buy a client, ask whether it validates iss before sending codes.
  4. Keep the allowed list of authorization servers short.
  5. Test with a mismatched issuer and confirm the client refuses.
  6. Log refusals, since a mismatch is a signal worth looking at.

Safeguard includes agent identity and policies, gates and guardrails, plus a free scan at https://gold.safeguard.sh/scan.

Quick check

Should I drop PKCE then?

No. PKCE still stops a different attack, the use of a stolen code. Keep it and add issuer validation.

Who must implement the check?

The client. The authorization server helps by sending iss and advertising it in its metadata.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.