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

Exact redirect_uri Pinning & Token Leakage

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

Bypass prefix redirect validation, then enforce canonical HTTPS origin+pathname equality and Referrer-Policy safeguards.

What you'll learn in this lesson

  • Exploit prefix and wildcard bugs in OAuth redirect_uri validation that allow attackers to steal code tokens.
  • Implement strict canonical URI equality matching (origin + pathname) over https: with zero userinfo, fragments, or path smuggling.
  • Prevent authorization code leakage via HTTP Referer headers, open redirects on ?next=, and third-party callback scripts.

Overview

Authorization servers deliver the single-use code directly to whichever redirect_uri passes validation. Whenever engineers write uri.startsWith('https://app.acme.test/oauth') or permissive regex host globs, attackers redirect the authorization code straight to their own server:

OAuth 2.1 mandates exact pre-registered URI equality — zero substring checks, zero wildcards, zero path normalization tricks.

Sections covered in this lesson

  1. 11. Redirect URI Parsing Pitfalls & Callback Isolation
  2. 22. Interactive Explorer: Hardened OAuth Flow & Redirect Boundaries
  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 "Exact redirect_uri Pinning & Token Leakage" and the full Application & Web Security curriculum

Bypass prefix redirect validation, then enforce canonical HTTPS origin+pathname equality and Referrer-Policy safeguards.

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.