Lion Cipher Lab

Sign an AWS API request with Signature Version 4 — from scratch

Why it matters

Every request to nearly every AWS service is authenticated with Signature Version 4, and yet most engineers treat it as an opaque thing the SDK does. That opacity is a security blind spot. If you cannot explain WHY AWS signs each request instead of sending a static token, you cannot reason about the failure modes that actually bite: a leaked long-lived access key, a presigned URL that outlives its purpose, a clock-skew replay window, a signature that silently breaks the moment a proxy reorders a query string. SigV4 is a small, fully-knowable algorithm — HMAC-SHA256 chained four times over a…

What you'll learn

Steps in this lab

  1. What SigV4 is, and the one bit it proves
  2. The four artifacts, in the order you'll build them
  3. Set up the inputs and two tiny crypto helpers
  4. Build the canonical request
  5. Build the string-to-sign
  6. Derive the signing key: four chained HMAC-SHA256 steps
  7. Compute the signature and assemble the Authorization header
  8. Run it and PROVE it byte-for-byte
  9. Independent check: re-derive the signing key with openssl
  10. Break it on purpose: the SignatureDoesNotMatch failure modes
  11. The judgment: why a per-request signature beats a static token
  12. When NOT to hand-roll this — the better way in production

Open the full interactive lab →