PKCE binds the code exchange to the session that started the flow. Without it, an attacker who obtains a victim's authorisation code (from logs, a leaky redirect or a malicious app) can inject it into their own session with the confidential client, which redeems it with its own secret, so the attacker ends up logged in as the victim. The client secret doesn't help, because the legitimate client is the one redeeming the code. The OAuth 2.0 Security Best Current Practice (RFC 9700, January 2025) therefore recommends PKCE for confidential clients too, and the OAuth 2.1 draft requires it for all clients. ASP.NET Core's OIDC handler enables it by default (UsePkce = true).
Checks understanding of authorisation code injection, not just public clients
Last updated 23 Nov 2026.