CYBER LIBRARY
Explore the bootcamp
Security essentialsIntermediate

Proof Key for Code Exchange (PKCE)

PKCE binds an OAuth authorization-code exchange to a verifier created by the initiating client.

3 min readUpdated 12 Oct 20263 connections
Markdown

What it means

PKCE binds an OAuth authorization-code exchange to a verifier created by the initiating client. The authorization request carries a challenge derived from that verifier, and the token exchange presents the verifier. This reduces the usefulness of an intercepted authorization code when correctly implemented.

A practical example

A public client generates a fresh unpredictable verifier for each flow and uses the recommended challenge method. It stores the verifier only for the relevant exchange and rejects attempts to complete a flow with a mismatched value.

What to check

Check per-flow randomness, challenge derivation, verifier handling, and enforcement by the authorization server. Review redirect and response-correlation protections separately, because PKCE is one part of the overall flow.

A common pitfall

PKCE does not replace validating redirect destinations or every other OAuth security requirement. Reusing a predictable verifier defeats the intended binding.

Think it through

Why must the verifier be unpredictable and fresh?

Answer: An interceptor who knows or can reuse it may redeem the code, undermining the protection PKCE is meant to provide.

The code and verifier travel different paths

A fictional mobile client begins an authorization flow by creating a verifier and deriving its challenge. The challenge accompanies the authorization request, while the verifier is retained for the later token exchange. The authorization server binds the resulting code to that challenge. Possessing the code alone should therefore be insufficient to complete the protected exchange.

This is a binding mechanism, not a hidden client password. A public client still has the properties of a public client, and the user must still be sent to the correct authorization service. The server must enforce the expected challenge method and verify the code exchange; a client generating a verifier is not enough if the server silently accepts an unprotected fallback.

Freshness matters when several login attempts occur at once. Each flow needs its own context, and the client should associate the correct verifier with the correct response. Reusing a fixed value across installations or requests removes the protection's intended unpredictability. Use a maintained library's supported implementation instead of improvising encoding or storage rules.

Explain a failed exchange

For a local protocol exercise, draw one authorization request and its corresponding token request. Label the challenge and verifier without using real credentials. Then describe what the authorization server should do if the verifier is missing or does not match the challenge. The useful result is an expected rejection, not a successful workaround.

Finally, identify what PKCE does not decide: the registered redirect destination, the resource permissions granted, and the application's interpretation of returned identity information. These remain separate protocol requirements. Understanding that scope prevents a correct PKCE implementation from being mistaken for a complete review of the entire login and delegation design.

GO TO THE SOURCE

References & further reading

Original explanations, with primary references for deeper study.

OWASP: OAuth2IETF RFC 7636: Proof Key for Code Exchange
EXPLORE THIS IDEA’S CONNECTIONS

A small part of a bigger picture.

4 notes · 4 connections
100%
Proof Key for Code Exchange (PKCE) · depth 1
Drag to pan · Pinch or use +/− to zoom · Click to preview · Double-click to read
Browse notes as a list (4)
FOLLOW ANOTHER THREADExplore the rest of the library
Start with a concept. Follow its connections.
Detection & responseAbuse Elevation Control MechanismElevation-control abuse bypasses or misuses mechanisms governing privileged execution.Making change happenAcceptance criteriaDefine observable conditions for a deliverable to be accepted.Security essentialsAccess controlUnderstand subjects, resources, permissions, and enforcement through a shared-drive example, including how access changes over time.Detection & responseAccess Token ManipulationAccess token manipulation changes or adopts operating-system security contexts.Risk & resilienceAccount Access RemovalAccount access removal disrupts legitimate users by changing, deleting, or restricting their identities.Evidence & investigationAccount DiscoveryAccount discovery enumerates identities available in a system or environment.Detection & responseAccount ManipulationAccount manipulation changes identity settings to preserve or expand access.Adversarial thinkingAcquire InfrastructureInfrastructure acquisition obtains domains, servers, or other resources used to support operations.Adversarial thinkingActive ScanningActive scanning probes target infrastructure to learn reachable services or weaknesses.Security essentialsAdversary in the middleAn intermediary may observe or alter a communication path.Security essentialsAESA symmetric block cipher whose safe use depends on its mode and implementation.Making change happenAgile deliveryUse short feedback cycles to adapt toward a useful outcome.