PKCE
Proof Key for Code Exchange · RFC 7636
By Boston Identity · Explained · 6 min read
The short answer
PKCE is an OAuth add-on that makes a stolen authorization code useless. The app keeps a one-time secret, sends a transformed version of it when it asks to sign in, and must show the secret itself to get a token.
- What it is
- A protocol
- Defined by
- IETF, RFC 7636 (2015)
- Who it's for
- Teams building or buying OAuth apps and agents
- In our briefings
- 420by month, last 12
What is PKCE?
Proof Key for Code Exchange (PKCE, said "pixy") is an extension to OAuth 2.0, the standard that lets an app get access to an account without holding the user's password. In OAuth's authorization code flow, the authorization server hands the app a code, and the app trades that code for an access token. PKCE closes a gap in that trade for public clients, apps that cannot keep a secret of their own.S1
The gap is the authorization code interception attack. On a phone, a malicious app can register the same custom link scheme as the real app and receive its code. With the code in hand it can ask for a token itself.§1 The RFC notes that secrets shipped inside an app cannot be considered confidential, and that every copy of a native app shares one client ID.§1 PKCE's answer is a fresh secret for every request. An attacker who intercepts the code cannot redeem it, because the attacker does not hold that secret.§1.1
PKCE does not replace the rest of OAuth's security analysis. RFC 7636 says all the OAuth security analysis in RFC 6819 still applies.§7.4
How does PKCE work?
Two actors take part: the client, which is the app asking for access, and the authorization server, which has an authorization endpoint that issues codes and a token endpoint that issues tokens.
Figure steps
- The client makes a code verifier
- The client derives the code challenge
- The client sends the challenge
- The server ties the challenge to the code
- The client presents the code and the verifier
- The server compares before issuing a token
The secret never travels until the last trip: the authorization endpoint sees only its hash, and the token endpoint hands over a token only to the app that can show the original.
Drawn from RFC 7636, sections 1.1 and 4
Swipe for the full figure →
The client sends the challenge
The client adds code_challenge to its normal authorization request, with code_challenge_method naming the method. The method parameter is optional, and if it is left out the server treats the request as plain.§4.3
The server ties the challenge to the code
When the server issues the authorization code, it must associate the challenge and the method with that code so it can check them later. It may store them inside the code in encrypted form or keep them on the server.§4.4
The client presents the code and the verifier
The client sends the code to the token endpoint as usual, with one extra parameter: the original code_verifier. The method bound to the code when it was issued is the one the token endpoint must use to check it.§4.5
The server compares before issuing a token
The token endpoint transforms the verifier with the recorded method and compares the result with the stored challenge. If they match, it continues as normal and issues the token. If not, it must return an invalid_grant error.§4.6
Why does PKCE matter now?
Researchers who tested 119 servers found PKCE optional in practice on 81 of them: their authorization servers let the challenge be left out or downgraded to plain. In one case study, that gap plus an open redirect was enough to take over an account.1 Three MCP (Model Context Protocol) authentication flaws were written up in one month. One was in the official Python SDK, which let a malicious server collect a client secret, an authorization code and a PKCE verifier.2
The requirements have tightened since 2015. RFC 9700, OAuth's security best current practice, requires authorization servers to support PKCE and public clients to use it, while PKCE for confidential clients stays only recommended.3 OAuth 2.1 is still a draft. Its revision -15 requires clients to send a code challenge and servers to enforce it, with an exception for some confidential clients.4 Revision -16, posted in September 2026, forbids the plain method outright.5 Auth0 made a strict mode for third-party apps generally available on April 30, and that mode requires PKCE.6
Where does it fit?
| Compared with | How PKCE differs |
|---|---|
| DPoP | DPoP is one of the ways OAuth 2.1 lets a server bind a public client's refresh token to the client instance.4 PKCE instead ties an authorization code to the challenge sent with the request.§4.4 |
| Pushed Authorization Requests | One agent delegation profile lists pushed authorization requests and PKCE as separate parts it builds on.7 PKCE itself adds a challenge to the authorization request rather than changing how the request is sent.§4.3 |
| OAuth 2.0 Authorization Server Metadata | Authorization server metadata is how a client learns what a server supports. A server whose metadata omits code_challenge_methods_supported does not support PKCE.8 |
| Client ID Metadata Documents | Client ID Metadata Documents identify a client by a URL the authorization server fetches metadata from. In one walkthrough, a public client set up this way still had a request fail without a PKCE code challenge, then received a code once it sent one.9 |
What goes wrong?
- The plain method is weak. Under plain the challenge is the verifier itself, so an attacker who can read the request, for example through leaked HTTP logs on the device, learns the verifier. The RFC says plain should not be used in new implementations unless S256 is technically impossible.§1,§7.2
- Downgrade is a trap. Servers that support PKCE are required to support S256, so a client must not fall back to plain after S256 fails: that error can only mean a faulty server or an attacker.§7.2 Yet a request that omits the method is treated as plain.§4.3
- Enforcement was optional in 2015. Servers may accept clients that do not use PKCE and fall back to ordinary OAuth for them.§5 A server that requires PKCE of public clients must reject such a client's request with no challenge as invalid_request.§4.4.1 Clients should send the PKCE parameters to every server.§5 A server without PKCE support simply ignores the unknown verifier.§7.2
- The verifier must stay secret and unguessable. The client should give it at least 256 bits of entropy.§7.1 A client library that hands its verifier to the wrong server undoes the protection.2
- PKCE does not stop every attack on the code flow. One OAuth draft describes an attack in which the victim completes the entire flow, and says PKCE alone cannot mitigate it.10 A paper finds that in FAPI 2.0, PKCE does not stop a replay attack, because the attacker sends both the pushed request and the token request.11
What should a security leader ask?
- 01
Do our authorization servers reject an authorization request that has no code challenge, and do they refuse the plain method?
- 02
Which of our MCP servers or agent integrations allow open client registration, and does each one enforce PKCE with S256?
- 03
When a vendor says it supports OAuth 2.1, does its server enforce PKCE for every public client or only accept it when sent?
- 04
Where does our client library keep the PKCE verifier, and can it ever send that verifier to a server other than the one that issued the code?
Sources
- S1
Proof Key for Code Exchange by OAuth Public ClientsIETF · RFC 7636, Standards Track, September 2015
›Evidence: 11 claims from 10 briefings
- 1BI-FIND-2026-0946 · 114 of 119 MCP servers that let outsiders register an OAuth client let them choose where sign-in codes are sentPKCE, the check meant to stop a stolen authorization code from being redeemed, was optional in practice on 81 of the 119 servers: their authorization servers let the code challenge be left out or downgraded to the plain method. In the authors' third case study, that gap plus an open redirect was enough to take over an account. The consent page was the other weak point. The paper counts servers whose consent page did not show the user the redirect address as 72 in its text and 62 in its chart, and only 62 makes the chart's totals add up.
- 2BI-FIND-2026-0397 · Three MCP auth flaws in a month, and the spec had already written the rule the SDKs skippedThree MCP authentication flaws written up in one month share a cause: a verification step that existed on the happy path and not on another. The official Python SDK checked the authorization server's issuer, then skipped the check when a server answered the metadata request with a 404 and fell back to the legacy flow, or returned 403 insufficient_scope, and it stored credentials without binding them to an issuer, so a malicious server could collect a client secret, an authorization code and a PKCE verifier. The Rust SDK never compared the resource field in the server's RFC 9728 metadata with the server it was talking to. LiteLLM's MCP route, on a failed key check, fell through to an empty authentication object when the caller sent a fabricated Authorization header. WorkOS's line is the right one: code 'accepted authentication input that nobody verified'. The thirty days are when the advisories landed; the Rust fix shipped on 29 June and LiteLLM's on 30 June, three months before anyone wrote them up together.
- 3BI-FIND-2025-0351 · RFC 9700 bans OAuth's password grant and loose redirect matching; binding access tokens stays a SHOULDSeveral of RFC 9700's MUSTs are checks an IAM team can run against its own stack. Authorization servers must match redirect URIs by exact string, with only the port of a native app's localhost URI exempt. They must support PKCE (Proof Key for Code Exchange) and refuse a token request that carries a code_verifier when the authorization request had no code_challenge. Public clients must use PKCE, and their refresh tokens must be sender-constrained or rotated. The resource owner password credentials grant must not be used. Two neighbouring rules are softer: the implicit grant gets a SHOULD NOT with an exception, and PKCE for confidential clients is only RECOMMENDED. The authors concede that following the document "may break interoperability" and still recommend upgrading "as soon as feasible".
- 4BI-FIND-2026-1109 · OAuth 2.1's March draft builds in the security best practice, but 2.1-only clients can fail with older serversRevision -15 of OAuth 2.1 turns the advice in OAuth 2.0's security best current practice (RFC 9700) into the base protocol. The authorization code grant now carries PKCE: clients are REQUIRED to send a code challenge and authorization servers MUST enforce it, unless the client is confidential and the server has reasonable assurance that it implements the OpenID Connect nonce properly. Redirect URIs are registered in full and must match exactly, except for the port on loopback redirects. The implicit and password grants are left out, clients MUST NOT send access tokens in a URI query parameter, and for public clients the authorization server MUST catch refresh-token replay, either by binding the token to the client instance (DPoP and mutual TLS are the examples given) or by rotating it on every refresh.
- 5BI-FIND-2026-1111 · OAuth 2.1's March draft builds in the security best practice, but 2.1-only clients can fail with older serversSix years after the first draft, posted in March 2020, the March 2026 text was still open on details implementers code against. Section 9, on browser-based apps, holds only a TODO to bring in that best practice's normative text once it is finished. Revision -15 also still let PKCE use the plain method: code_challenge_method was optional and "defaults to plain", with S256 mandatory to implement on servers and plain allowed for clients that cannot support S256 and know the server accepts it. Revision -16, posted in September 2026, forbids plain outright and makes the iss parameter required in the authorization response. The browser-apps placeholder is still there.
- 6BI-FIND-2026-1182 · Microsoft and Google made AI agent identity generally available in April; Okta's notes put its GA in MayPing, Auth0 and Cloudflare each tightened what a third-party or delegated token can reach in April. Ping's April 14 regular channel let token exchange requests name an audience, which can be limited to an allowlist, and gave partial support for rich authorization request (RAR) details at its authorize and pushed-authorization endpoints. Auth0 made strict mode for third-party applications GA on April 30: PKCE required, a client grant for each API, and default permissions applied to apps created by dynamic client registration. Cloudflare let users grant a third-party OAuth app chosen accounts instead of all of them. Ping's September notes let access tokens carry RAR details through the authorization code and refresh token grants.
- 7BI-FIND-2026-0858 · An OAuth agent profile has the token server block any widening of scope, and leaves revoking the chain optionalKumar's profile builds agent delegation only from parts OAuth already has: pushed authorization requests, PKCE, one resource per token, a key bound to every token that the API checks on every call, and standard token exchange with the actor recorded in the act claim. Narrowing is the token server's job: it "MUST reject a requested scope that is not contained in the subject token", and a delegated token may not outlive its parent, must be bound to the receiving agent's key and keeps the person as its subject. We read this as placing the narrowing check at the token server during exchange. The API server must still validate the token, enforce scopes and check token status when the deployment’s risk model requires online state.
- 8BI-FIND-2018-0003 · RFC 8414 tells an OAuth client to discard server metadata whose issuer differs from the URL it started fromOnly two fields are required outright: issuer and response_types_supported. The authorization and token endpoints are required unless the server's grant types do not use them. Most other fields are optional, scopes_supported is RECOMMENDED, and a few become required only when a related value is listed, which means a client cannot assume most fields are there. Some absences carry meaning: a server that omits code_challenge_methods_supported does not support PKCE. New fields go into an IANA registry the RFC creates with 23 initial entries, on a Specification Required basis after a two-week review period. Our briefings on two later OAuth drafts found each adding its own metadata field.
- 9BI-FIND-2026-1653 · MCP client setup moves from registration to metadata checks in a Spring walkthroughDaniel’s local CIMD flow identifies a client with a URL from which the authorization server retrieves client metadata. It avoids the dynamic client registration exchange and the client records that repeated open registration creates in his earlier example. The work shifts to checking the document and the request: he discusses redirect-address policy and unsafe fetch destinations, and reports a failed public-client request without a PKCE code challenge before correcting it and receiving an authorization code.
- 10BI-FIND-2026-1032 · An OAuth client brokering many tools, as agent services do, can let a rogue tool take over a user's other toolsA second attack in the update exploits confusion over which user a connection belongs to. Some clients carry a session identifier in the state parameter or a pre-authorization link because they cannot see the user's session where the flow ends; the draft's examples are a native app's backend that opens a tool-linking page in the browser and a client that outsources OAuth to an OAuth-as-a-Service provider. An attacker starts a flow, sends the link to a victim, and once the victim approves, "the attacker's account at the client now gains access to the victim's resources." The draft says "PKCE alone cannot mitigate this new attack", because the victim completes the entire flow. Its rule is that the client "MUST ensure that an OAuth flow initiated by one user is completed by the same user", by validating the carried session against the user's existing session before it requests the token.
- 11BI-FIND-2025-0451 · A rogue OAuth server can collect a client's signed assertion and replay it at an honest server the client also usesThe authors give the client credentials grant, decoupled flows such as CIBA in all three modes, the device grant and a login through the implicit flow as instances of the second phase, and call their list by no means exhaustive. They write that "it suffices if the client and/or AS merely support a vulnerable protocol, even if that protocol is never used" between them. In FAPI 2.0, PKCE does not stop the replay because the attacker sends both the pushed request and the token request, and the paper says sender-constrained tokens do not prevent the attack either. A clause in FAPI 1.0 happens to prevent the second phase.
›In our briefings
The claim each of the newest briefings on PKCE would have you leave with.
WorkOS's checklist limits a delegated agent to the intersection of what the agent is allowed to do and what the user it acts for is "currently allowed to do," and says to check both on every tool call, not once per session. Its example code reads the agent's ceiling from the token and makes a live check for the user, and its test is that revoking a user's access to a project mid-task makes the agent's next call on that project fail. In the post's own example, an agent whose ceiling includes projects:delete still cannot delete a project the user cannot.
WorkOS's agent checklist limits a delegated agent to what it and its user may both do, checked on every callBI-FIND-2026-1997
Revision -05 adds a warning that a stolen sign-in token reaches far beyond the identity provider. A client holding the user's ID token, SAML assertion or identity-provider refresh token can trade it for an ID-JAG, the signed assertion the grant defines, at any app the identity provider's policy permits, so a stolen one "exposes not only the IdP, but potentially every downstream resource reachable through it", with no further step by the user. The thief also needs the client's credentials, but the draft notes these usually sit in the same deployment and says deployments "SHOULD NOT rely on client authentication alone". Clients that keep these tokens SHOULD store them apart from their credentials and out of logs. Identity providers SHOULD record every exchange's audience, resource, scope and client, and offer a way to revoke refresh tokens and end a user's sessions.
Cross-App Access draft warns that one stolen sign-in token could reach every app the identity provider permitsBI-FIND-2026-1904
In the November 2025 revision, MCP changes how a client gets its identity. Authorization servers and MCP clients SHOULD support Client ID Metadata Documents, an IETF draft cited at revision -00 in which the client_id is an HTTPS URL pointing at a document about the client; the page calls this the case of client and server with "no prior relationship (most common)". Dynamic Client Registration drops to a MAY, kept "for backwards compatibility". A client that supports every option SHOULD use pre-registered credentials first, then a metadata document if the authorization server advertises support, then dynamic registration if it offers a registration endpoint, and only then ask the user for client details. Read against our copies of the neighbouring revisions, this is the middle step: in June 2025 dynamic registration was the SHOULD and metadata documents were absent, and by July 2026 the page called dynamic registration deprecated.
MCP's November 2025 authorization spec puts metadata documents ahead of dynamic client registrationBI-FIND-2025-0584
›Cited in 42 briefings
Every briefing that discusses this term, newest first.
- WorkOS's agent checklist limits a delegated agent to what it and its user may both do, checked on every call
Article · · WorkOS Blog · Maria Paktiti · Sep 30, 2026
- Cross-App Access draft warns that one stolen sign-in token could reach every app the identity provider permits
Draft · · IETF Datatracker · Aaron Parecki et al. · May 21, 2026
- MCP's November 2025 authorization spec puts metadata documents ahead of dynamic client registration
Article · · Model Context Protocol · Nov 25, 2025
- OAuth tokens prove an agent's rights, not a person's consent; revision 05 adds a day-long grant with spend caps
Draft · · IETF Datatracker · Meiling Chen et al. · Oct 27, 2026
- MCP client setup moves from registration to metadata checks in a Spring walkthrough
Video · · OWASP Foundation · Oct 24, 2026
- From Level 2 up, OWASP's AI security standard asks for an identity per agent and a check on every MCP tool call
Video · · OWASP Foundation · Oct 21, 2026
- An OAuth agent profile has the token server block any widening of scope, and leaves revoking the chain optional
Draft · · IETF Datatracker · Sanjeev Kumar, Orchestrum Technologies LLP · Aug 30, 2026
- Auth0's own Claude Code tutorial runs the agent on the developer's login and hands it fifteen admin scopes
Article · · Auth0 Blog · Manish Hatwalne · Sep 29, 2026
- TPX replaces an app's embedded AI provider key with a capped, metered grant the user approves at their provider
Article · · tokenpony.dev · Alex Polvi · Jul 20, 2026
- NIST and CISA advise one-hour tokens, 90-day keys and hardware key storage; AI agents get one paragraph
Article · · NIST (CSRC) · Ryan Galluzzo et al. · Sep 15, 2026
- A survey rates only workload identity ready for agents, and argues no standard can tell what an agent intends
Paper · · arXiv · Takumi Otsuka et al. · Apr 25, 2026
- Three MCP auth flaws in a month, and the spec had already written the rule the SDKs skipped
Article · · WorkOS Blog · Maria Paktiti · Oct 2, 2026
- OAuth handles an agent in one company, working while you watch. The OpenID paper says that is where it stops.
Article · · OpenID Foundation · Tobin South et al. · Oct 2025
- xChk ships human OIDC portfolios and a separate agent approval API
Paper · · arXiv · Sean MacGuire · Jul 15, 2026
- The browser OAuth draft favors a backend that keeps tokens out of JavaScript
Draft · · IETF Datatracker · Aaron Parecki et al. · Jul 6, 2026
- A July OAuth draft keeps agent identity stable as keys rotate
Draft · · IETF Datatracker · Karl McGuinness · Jul 5, 2026
- 114 of 119 MCP servers that let outsiders register an OAuth client let them choose where sign-in codes are sent
Paper · · arXiv · Huijun Zhou et al. · May 21, 2026
- A 'decentralized' agent identity draft blocks risky calls when its Registry is down, and did:aip is taken
Draft · · IETF Datatracker · Paras Singla · Apr 17, 2026
- Microsoft and Google made AI agent identity generally available in April; Okta's notes put its GA in May
Release tracker · · 8 vendors' release notes · Apr 2026
- OAuth 2.1's October draft bans plain PKCE and adds browser-app rules; 2.1-only clients can fail on older servers
Draft · · IETF Datatracker · Dick Hardt et al. · Mar 2, 2026
- An OAuth client brokering many tools, as agent services do, can let a rogue tool take over a user's other tools
Draft · · IETF Datatracker · Tim Würtele et al. · Mar 2, 2026
- OAuth's in-app login draft lets a native app collect the password itself, and leaves each server to vet the app
Draft · · IETF Datatracker · Aaron Parecki et al. · Feb 28, 2026
- OAuth's cross-device guidance ranks FIDO first, then CIBA backchannel login, and the device-code flow last
Draft · · IETF Datatracker · Pieter Kasselman et al. · Jan 23, 2026
- On its authors' tasks, an LLM check of agent scopes works at one tool and refuses most valid three-tool requests
Paper · · arXiv · Majed El Helou et al. · Oct 30, 2025
- Huawei-led OAuth draft lets clients chain narrower tokens offline but leaves revocation delivery out of scope
Draft · · IETF Datatracker · Li Ruochen et al. · Oct 20, 2025
- OpenID's credential issuance standard is OAuth for wallets, and assumes a trusted wallet is an app on a phone
Article · · OpenID Foundation · Torsten Lodderstedt et al. · Sep 16, 2025
- A WSO2 draft puts the AI agent in OAuth consent and the access token, but not how the agent gets its credential
Draft · · IETF Datatracker · Thilina Shashimal Senarath et al. · Aug 26, 2025
- The July 2025 Cross App Access draft lets the IdP decide app-to-app access and treats agents as plain clients
Draft · · IETF Datatracker · Aaron Parecki et al. · Jul 2, 2025
- MCP's June 2025 authorization spec: a server accepts only tokens issued for it and passes none upstream
Article · · Model Context Protocol project · Jun 18, 2025
- An MCP gateway can do OAuth for servers that have none; this one passes them a user header
Paper · · arXiv · Ivo Brett · Apr 28, 2025
- An A2A threat model flags the Agent Card as an attack path, and its example flow never passes on the user's identity
Paper · · arXiv · Idan Habler et al. · Apr 23, 2025
- A rogue OAuth server can collect a client's signed assertion and replay it at an honest server the client also uses
Article · · IACR Cryptology ePrint Archive · Pedram Hosseyni et al. · Apr 7, 2025
- FAPI 2.0 issues only sender-constrained access tokens and leaves public clients out
Article · · OpenID Foundation · Daniel Fett et al. · Feb 22, 2025
- RFC 9700 bans OAuth's password grant and loose redirect matching; binding access tokens stays a SHOULD
Article · · IETF (RFC Editor) · Torsten Lodderstedt et al. · Jan 2025
- In May 2023, Parecki described OAuth 2.1 as consolidation and DPoP as token protection
Video · · Identiverse - A CRA Resource · Jun 17, 2024
- OpenID Connect Core says only issuer plus subject identify a user; email must never be the key
Article · · OpenID Foundation · Nat Sakimura et al. · Dec 15, 2023
- DPoP token binding depends on checks at the resource server
Article · · RFC Editor · Daniel Fett et al. · Sep 2023
- In draft FAPI, token binding did not make phished tokens useless: the attacker had the bound client spend them
Paper · · arXiv · Daniel Fett et al. · Jan 31, 2019
- RFC 8414 tells an OAuth client to discard server metadata whose issuer differs from the URL it started from
Article · · RFC Editor · Michael B. Jones et al. · Jun 1, 2018
- RFC 8252 puts native-app OAuth authorization outside the host app’s browser control
Article · · IETF / RFC Editor · William Denniss et al. · Oct 1, 2017
- PKCE's 2015 standard let servers accept clients that skip it and treated an omitted method as the weaker plain
Article · · RFC Editor · Nat Sakimura et al. · Sep 2015
- RFC 6749 admits a server can't tell who presents a token; the fixes arrived in 2020 and 2023
Article · · RFC Editor · D. Hardt et al. · Oct 2012
In our columns
Related terms
What appears alongside PKCE in the same briefings.
Client ID Metadata DocumentsCrabby EditorPKCE downgrade attackDynamic Client RegistrationOAuth 2.0 Authorization Server MetadataDPoPResource Indicators for OAuth 2.0Pushed Authorization Requests
Was this explainer useful?
Share this explainer
Pass it on. Every claim has a permanent number, so what you share today still points at the same words next year.