Join our Newsletter — 33% off our NHI Course

Who is exposed when OAuth codes are intercepted with PKCE?

 

(@nhi-mgmt-group)
Member Moderator
Joined: 2 years ago
Posts: 20230
Topic starter  

TL;DR: PKCE removes the assumption that a stolen OAuth authorization code is enough to obtain tokens, because the exchange also requires a verifier held by the originating client, according to Ory. OAuth code flows need S256, short-lived verifiers, and default PKCE use to reduce interception and injection risk.

Editorial analysis by NHI Mgmt Group, based on content published by Ory: “What Is PKCE and Why Does It Matter”.

Key questions

Q: Why does code interception create token risk even when a client secret exists?

A: A client secret only helps when the secret actually stays with the legitimate client.

Q: How do security teams know PKCE is being used correctly?

A: PKCE is being used correctly when every authorization code flow uses a fresh, high-entropy verifier, S256 is the only accepted challenge method, and the verifier is never exposed in URLs or logs.

Q: What breaks when OAuth clients use the wrong flow or skip PKCE?

A: When teams choose the wrong grant type or skip PKCE, the authorization process becomes easier to intercept or misuse.

Practitioner guidance

  • Mandate S256 for every authorization code flow Reject plain challenge generation except for tightly justified platform constraints.
  • Treat client-side secrets as non-viable Remove embedded client secrets from apps that cannot keep them confidential and assume interception-resistant design must come from PKCE plus redirect URI validation.
  • Keep verifiers ephemeral and out of logs Store the code verifier only for the duration of the flow, preferably in memory or platform-secure storage, and never place it in URLs, logs, or persistent storage.

Bottom line: PKCE removes the assumption that a stolen OAuth authorization code is enough to obtain tokens, because the exchange also requires a verifier held by the originating client.

Glossary terms: Proof Key for Code Exchange, Code Verifier, Code Challenge, Authorization Code Interception

Explore further

View Full Forum →  |  NHI Foundation Course →  |  Our Services →  |  Read the full analysis →


This topic was modified 1 week ago by NHI Mgmt Group

   
Quote
(@mr-nhi)
Member Moderator
Joined: 7 months ago
Posts: 20718
 

PKCE turns OAuth code redemption into a possession test, not a trust assumption. The authorization server no longer accepts a code as proof that the right client is finishing the flow. It requires evidence that the same party that started the request still holds the verifier. That matters because client-side applications cannot safely keep a secret, so the old confidence model was already broken.

A few things that frame the scale:

A question worth separating out:

Q: Should organisations require PKCE for confidential clients, or only for public clients?

A: Require it for both. Public clients need PKCE because they cannot rely on a client secret, but confidential clients still benefit because PKCE ties the authorization request to the token request. That reduces the impact of intercepted codes and narrows the assumptions a token endpoint must make about the caller.

👉 Read our full editorial: PKCE makes OAuth code interception a closed risk



   
ReplyQuote
Share:

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.