Proof Key for Code Exchange

A security mechanism used to prevent authorization code interception attacks in OAuth 2.0.

Description

Proof Key for Code Exchange (PKCE) is an extension to the OAuth 2.0 authorization framework designed to enhance security, particularly in mobile and public client applications that cannot securely store client secrets. PKCE addresses vulnerabilities associated with authorization code interception attacks, where an attacker can obtain an authorization code and exchange it for an access token. PKCE works by requiring the client to generate a 'code verifier' and a 'code challenge' during the authorization request. The code challenge is sent along with the request, and the code verifier is sent when exchanging the authorization code for an access token. This ensures that only the client that initiated the request can complete the process, as they are the only ones who possess the correct code verifier. By implementing PKCE, developers can greatly improve the security of their applications, making it a recommended practice for all OAuth 2.0 implementations, especially in environments where client secrets cannot be securely stored.

Examples

  • Mobile applications like Spotify use PKCE to secure user login without storing secrets.
  • Web applications utilizing OAuth 2.0 with APIs, such as GitHub, implement PKCE to prevent code interception.

Additional Information

  • PKCE is especially important for public clients where client secrets cannot be protected.
  • It has been widely adopted by major identity providers like Google and Microsoft to enhance OAuth security.

References