Skip to main content
Module 9 · Lesson 1 of 331/42 in the course~20 min
Module lessons (1/3)

PKCE S256 & Anti-CSRF state Handshake

Lesson preview6 hands-on exercises readyApplication & Web Security · Module 9 — OAuth 2.1, OIDC & Federated Login Flows

Reproduce OAuth Login CSRF callbacks and verify Web Crypto SHA-256 PKCE challenges alongside constant-time state binding.

What you'll learn in this lesson

  • Understand how Authorization Code interception and OAuth Login CSRF exploit flows missing PKCE or state.
  • Compute deterministic PKCE S256 challenges in the browser and edge runtimes using crypto.subtle.digest('SHA-256', ...).
  • Reject code_challenge_method=plain downgrade attacks and bind client login attempts strictly to a cryptographic state nonce.

Overview

OAuth 2.1 mandates Proof Key for Code Exchange (PKCE) for every authorization code client — even confidential server-rendered apps. Without PKCE, malware or custom URI scheme hijackers that intercept a one-time code on the redirect can redeem it immediately at /oauth/token.

Meanwhile, omitting an unguessable session-bound state token invites Login CSRF: an attacker starts OAuth with their own account, captures /callback?code=attacker_code, and tricks a victim browser into loading that callback URL — silently signing the victim into the attacker's workspace so saved search queries, API keys, or billing cards belong…

Sections covered in this lesson

  1. 11. PKCE S256 & state Cryptography in Practice
  2. 22. Interactive Explorer: OAuth 2.1 PKCE & Login CSRF Lab
  3. 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
  4. 44. Checkpoints & Code Review
Pro Lesson · Module 9 — OAuth 2.1, OIDC & Federated Login Flows

Unlock "PKCE S256 & Anti-CSRF state Handshake" and the full Application & Web Security curriculum

Reproduce OAuth Login CSRF callbacks and verify Web Crypto SHA-256 PKCE challenges alongside constant-time state binding.

Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Application & Web Security plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.