# What is PKCE?

> 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.

Explainer by Boston Identity, 2026-10-27. 6 min read. https://insights.bostonidentity.com/glossary/pkce

- What it is: protocol
- Defined by: IETF, RFC 7636 (2015)
- Who it's for: Teams building or buying OAuth apps and agents

## 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 [S1 §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 [S1 §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 [S1 §1.1].

Think of it like this: It is like a coat check where you tear a ticket in half before handing over your coat: the attendant keeps a photo of your half, and only the matching half gets the coat back. With the recommended S256 method the comparison stops at the photo: the server holds only a fingerprint of your half, never the half itself.

Not the same as: PKCE does not replace the rest of OAuth's security analysis. RFC 7636 says all the OAuth security analysis in RFC 6819 still applies [S1 §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: 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.]

1. **The client makes a code verifier.** For each authorization request, the client creates a new code verifier: a high-entropy random string of 43 to 128 characters. The RFC recommends making it from 32 random octets, base64url-encoded [S1 §4.1].
2. **The client derives the code challenge.** The client turns the verifier into a code challenge. With the S256 method the challenge is the base64url-encoded SHA-256 hash of the verifier. With the plain method it is the verifier unchanged. A client that can use S256 must use it [S1 §4.2].
3. **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 [S1 §4.3].
4. **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 [S1 §4.4].
5. **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 [S1 §4.5].
6. **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 [S1 §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 [BI-FIND-2026-0946](https://insights.bostonidentity.com/ref/BI-FIND-2026-0946). 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 [BI-FIND-2026-0397](https://insights.bostonidentity.com/ref/BI-FIND-2026-0397).

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 [BI-FIND-2025-0351](https://insights.bostonidentity.com/ref/BI-FIND-2025-0351). 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 [BI-FIND-2026-1109](https://insights.bostonidentity.com/ref/BI-FIND-2026-1109). Revision -16, posted in September 2026, forbids the plain method outright [BI-FIND-2026-1111](https://insights.bostonidentity.com/ref/BI-FIND-2026-1111). Auth0 made a strict mode for third-party apps generally available on April 30, and that mode requires PKCE [BI-FIND-2026-1182](https://insights.bostonidentity.com/ref/BI-FIND-2026-1182).

## Where does it fit?

- Compared with DPoP: DPoP is one of the ways OAuth 2.1 lets a server bind a public client's refresh token to the client instance [BI-FIND-2026-1109](https://insights.bostonidentity.com/ref/BI-FIND-2026-1109). PKCE instead ties an authorization code to the challenge sent with the request [S1 §4.4].
- Compared with Pushed Authorization Requests: One agent delegation profile lists pushed authorization requests and PKCE as separate parts it builds on [BI-FIND-2026-0858](https://insights.bostonidentity.com/ref/BI-FIND-2026-0858). PKCE itself adds a challenge to the authorization request rather than changing how the request is sent [S1 §4.3].
- Compared with 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 [BI-FIND-2018-0003](https://insights.bostonidentity.com/ref/BI-FIND-2018-0003).
- Compared with 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 [BI-FIND-2026-1653](https://insights.bostonidentity.com/ref/BI-FIND-2026-1653).

## 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 [S1 §1] [S1 §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 [S1 §7.2]. Yet a request that omits the method is treated as plain [S1 §4.3].
- Enforcement was optional in 2015. Servers may accept clients that do not use PKCE and fall back to ordinary OAuth for them [S1 §5]. A server that requires PKCE of public clients must reject such a client's request with no challenge as invalid_request [S1 §4.4.1]. Clients should send the PKCE parameters to every server [S1 §5]. A server without PKCE support simply ignores the unknown verifier [S1 §7.2].
- The verifier must stay secret and unguessable. The client should give it at least 256 bits of entropy [S1 §7.1]. A client library that hands its verifier to the wrong server undoes the protection [BI-FIND-2026-0397](https://insights.bostonidentity.com/ref/BI-FIND-2026-0397).
- 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 [BI-FIND-2026-1032](https://insights.bostonidentity.com/ref/BI-FIND-2026-1032). 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 [BI-FIND-2025-0451](https://insights.bostonidentity.com/ref/BI-FIND-2025-0451).

## What should a security leader ask?

1. Do our authorization servers reject an authorization request that has no code challenge, and do they refuse the plain method?
2. Which of our MCP servers or agent integrations allow open client registration, and does each one enforce PKCE with S256?
3. When a vendor says it supports OAuth 2.1, does its server enforce PKCE for every public client or only accept it when sent?
4. 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 Clients](https://www.rfc-editor.org/rfc/rfc7636) (IETF, RFC 7636, Standards Track, September 2015)

## Evidence

- [BI-FIND-2026-0946](https://insights.bostonidentity.com/ref/BI-FIND-2026-0946): PKCE, 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. (from "114 of 119 MCP servers that let outsiders register an OAuth client let them choose where sign-in codes are sent")
- [BI-FIND-2026-0397](https://insights.bostonidentity.com/ref/BI-FIND-2026-0397): Three 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. (from "Three MCP auth flaws in a month, and the spec had already written the rule the SDKs skipped")
- [BI-FIND-2025-0351](https://insights.bostonidentity.com/ref/BI-FIND-2025-0351): Several 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". (from "RFC 9700 bans OAuth's password grant and loose redirect matching; binding access tokens stays a SHOULD")
- [BI-FIND-2026-1109](https://insights.bostonidentity.com/ref/BI-FIND-2026-1109): Revision -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. (from "OAuth 2.1's March draft builds in the security best practice, but 2.1-only clients can fail with older servers")
- [BI-FIND-2026-1111](https://insights.bostonidentity.com/ref/BI-FIND-2026-1111): Six 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. (from "OAuth 2.1's March draft builds in the security best practice, but 2.1-only clients can fail with older servers")
- [BI-FIND-2026-1182](https://insights.bostonidentity.com/ref/BI-FIND-2026-1182): Ping, 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. (from "Microsoft and Google made AI agent identity generally available in April; Okta's notes put its GA in May")
- [BI-FIND-2026-0858](https://insights.bostonidentity.com/ref/BI-FIND-2026-0858): Kumar'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. (from "An OAuth agent profile has the token server block any widening of scope, and leaves revoking the chain optional")
- [BI-FIND-2018-0003](https://insights.bostonidentity.com/ref/BI-FIND-2018-0003): Only 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. (from "RFC 8414 tells an OAuth client to discard server metadata whose issuer differs from the URL it started from")
- [BI-FIND-2026-1653](https://insights.bostonidentity.com/ref/BI-FIND-2026-1653): Daniel’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. (from "MCP client setup moves from registration to metadata checks in a Spring walkthrough")
- [BI-FIND-2026-1032](https://insights.bostonidentity.com/ref/BI-FIND-2026-1032): A 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. (from "An OAuth client brokering many tools, as agent services do, can let a rogue tool take over a user's other tools")
- [BI-FIND-2025-0451](https://insights.bostonidentity.com/ref/BI-FIND-2025-0451): The 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. (from "A rogue OAuth server can collect a client's signed assertion and replay it at an honest server the client also uses")

---

© 2026 Boston Identity LLC. All rights reserved. Published by Boston Identity LLC.
Quote up to 100 words with the credit "Boston Identity, IAM Insights" and a link to https://insights.bostonidentity.com/glossary/pkce. Claim numbers may be cited freely. Training, fine-tuning and text-and-data-mining use of this page is permitted.
Terms: https://insights.bostonidentity.com/terms · How to cite: https://insights.bostonidentity.com/cite
