Lion Cipher Lab

Exploit and fix a DNS rebinding attack (the resolve-twice gap that defeats an SSRF IP allowlist)

Why it matters

The standard advice for stopping SSRF (Server-Side Request Forgery -- tricking your server into fetching an attacker-chosen URL) is: before you fetch a user-supplied URL, resolve the hostname, check the IP against a denylist of private/internal ranges, and only proceed if it looks public. That check feels airtight -- and DNS rebinding walks straight through it. The trick is that there are TWO DNS lookups hiding in 'validate the IP, then connect': one when you resolve to check, and another when the HTTP client resolves to actually open the socket. An attacker who controls the authoritative DNS…

What you'll learn

Steps in this lab

  1. What DNS rebinding is -- and what it is NOT (SSRF, host-header injection)
  2. Stand up the offline lab: a real internal secret, a real attacker server, and an honest DNS stub
  3. Write the vulnerable guard -- the one that resolves TWICE
  4. Prove the flip, then run the EXPLOIT
  5. Fix A -- resolve ONCE and pin the IP (the one move that matters)
  6. Fix B -- the post-connect peer check (for code that must connect by name)
  7. The INCOMPLETE fix: pin the first request, then follow a redirect by name
  8. Fix C -- a Host allowlist of expected destinations
  9. The judgment: where each fix breaks, and the control that actually holds
  10. What you built -- and the one sentence to carry

Open the full interactive lab →