Subscribe to the Non-Human & AI Identity Journal

Notifications
Clear all

PKCE in OAuth 2.1: are your code flows still safe?


(@nhi-mgmt-group)
Member Moderator
Joined: 1 year ago
Posts: 5855
Topic starter  

TL;DR: PKCE closes code interception and code injection gaps in OAuth Authorization Code flows by binding each token exchange to a one-time verifier, and OAuth 2.1 now requires it for all clients, according to WorkOS. The practical shift is that teams should treat PKCE as the default control layer, not an optional hardening step.

NHIMG editorial — based on content published by WorkOS: What is PKCE and why every OAuth app should use it

Questions worth separating out

Q: How should security teams implement PKCE across OAuth applications?

A: Security teams should require PKCE for every Authorization Code flow, use S256 exclusively, and verify that client libraries generate a fresh verifier per login attempt.

Q: Why do confidential OAuth clients still benefit from PKCE?

A: Confidential clients still benefit because a client secret does not fully protect the authorization response path.

Q: What breaks when PKCE is not enforced in OAuth 2.1?

A: Without PKCE, intercepted authorization codes can be redeemed by an attacker, and redirect tampering becomes easier to exploit.

Practitioner guidance

  • Enforce S256-only PKCE across all OAuth clients Reject plain method usage in policy, linting, and CI checks.
  • Verify verifier lifecycle handling in every SDK Test that the code verifier is generated per request, stored only for the duration of the exchange, and discarded immediately after token issuance.
  • Review redirect and proxy exposure paths Inspect browser extensions, reverse proxies, mobile handoff flows, and redirect handlers for code leakage points.

What's in the full article

WorkOS' full guide covers the implementation detail this post intentionally leaves for the source:

  • Step-by-step PKCE flow examples for Authorization Code integrations in browser, mobile, and server-side apps
  • Code samples showing verifier generation, challenge derivation, and token exchange handling
  • Specific guidance on common library behaviours that can silently weaken or break PKCE
  • Discussion of OAuth 2.1 migration considerations for teams updating existing auth stacks

👉 Read WorkOS' guide to PKCE in OAuth 2.1 →

PKCE in OAuth 2.1: are your code flows still safe?

Explore further

View Full Forum →  |  NHI Foundation Course →



   
Quote
(@mr-nhi)
Member Moderator
Joined: 1 month ago
Posts: 5343
 

PKCE is now part of the trust boundary, not an optional enhancement. The article shows that the security property of OAuth Authorization Code flows changes once the verifier is required at exchange time. That means identity programmes can no longer treat code interception as an edge case handled by client secrecy alone. The practitioner implication is that protocol hardening has moved into baseline access governance.

A few things that frame the scale:

  • 97% of NHIs carry excessive privileges, increasing unauthorised access and broadening the attack surface, according to Ultimate Guide to NHIs.
  • Only 5.7% of organisations have full visibility into their service accounts, which means identity controls often operate without complete state awareness.

A question worth separating out:

Q: Who is accountable when an OAuth implementation allows weak code exchange controls?

A: Application owners, identity architects, and platform teams share accountability because PKCE is a protocol control that must be enforced in both configuration and implementation. The governance expectation is to make the safer path the default, then prove that every client and library follows it consistently.

👉 Read our full editorial: PKCE is now the baseline for secure OAuth code flows



   
ReplyQuote
Share: