liveBook · Manning

Code challenge

As explained in Software Security for Developers

A code challenge is a value derived from a PKCE code verifier and sent to an authorization server to bind an authorization session to that verifier.

An intercepted authorization code can let an attacker impersonate a legitimate client and access protected resources. A code challenge helps prevent that failure. section 13.1

A code challenge is a value derived from a random code verifier. The client hashes the verifier, commonly with SHA-256, and sends the resulting challenge to the authorization server during the login redirect. section 13.1

PKCE uses the pair across two stages:

  • The client creates a unique, unpredictable code verifier. section 13.1
  • The client hashes the verifier into a code challenge and includes it in the authentication request. section 13.1
  • After receiving the authorization code, the client presents the original verifier when requesting an access token. section 13.1 section 13.5
  • The authorization server issues the token only when the verifier matches the earlier challenge. section 13.1

Why the pairing matters

If an attacker steals only the authorization code, the attacker still lacks the original verifier. The authorization server therefore refuses the token exchange, blocking the stolen code from granting access. section 13.1 section 13.5

How Software Security for Developers covers it

How deep it goes
Explains generation, hashing, redirect binding, and token validation, without detailing cryptographic internals beyond one-way hashing.
Examples
Uses login redirects, intercepted authorization codes, verifier-based token requests, and verifier-to-challenge diagrams.
What it assumes
Builds from the authorization code flow and introduces the verifier, challenge, and hashing relationship directly.
What you can do after
Apply it via PKCE by generating a verifier, sending its challenge, and presenting the verifier during token exchange.
How it connects
Connects PKCE with the authorization code flow, code verifier, authorization server, cryptographic hashing, and access tokens.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.