Lion Cipher Lab

Stop token theft with DPoP: bind an OAuth token to a key so a stolen token is useless

Why it matters

A normal OAuth 2.0 access token is a BEARER token, and 'bearer' is the whole problem: like a paper banknote, it is valid for whoever is holding it, no questions asked. If that token ends up somewhere it should not — a log file, a crash report, a shared proxy, an SSRF response, a cross-site-scripting payload that reads it out of the browser — the attacker replays it and IS you until it expires. Short lifetimes shrink that window but never close it. The professional fix is to stop making tokens spendable by anyone who holds them: bind each token to a cryptographic key the legitimate client…

What you'll learn

Steps in this lab

  1. The words first: bearer vs sender-constrained, and what DPoP actually is
  2. When to reach for DPoP — and when NOT to (read before you build)
  3. Start Keycloak in Docker (dev mode)
  4. Create a realm, a DPoP-enabled client, and a test user
  5. Set up the tiny signing script (Node + jose)
  6. Generate an EC key pair and compute its thumbprint (the future cnf.jkt)
  7. Build a DPoP proof and request a token from Keycloak
  8. Decode the token and prove cnf.jkt equals your key's thumbprint
  9. Use the token correctly at the resource endpoint (proof carries htm/htu/ath)
  10. Now steal the token: prove it is useless three ways
  11. The pro move: DPoP here, mTLS there, short tokens everywhere

Open the full interactive lab →