Lion Cipher Lab

Steal cloud metadata credentials via SSRF — and defeat it with IMDSv2

Why it matters

The single most valuable thing an attacker can reach through a Server-Side Request Forgery on a cloud server is not a database or an admin page — it is the Instance Metadata Service, or IMDS: a fixed internal address (169.254.169.254) that every major cloud runs, which hands the machine's temporary credentials to any process that asks. Those credentials are what the server uses to call the cloud's own APIs — to read storage buckets, list databases, spin up machines — so stealing them is stealing the server's identity. This is not theoretical. The Capital One breach of 2019, which exposed data…

What you'll learn

Steps in this lab

  1. Why 169.254.169.254 is the crown jewel — and the ground rules
  2. Set up: confirm Python, make a folder, install Flask and requests
  3. Build the mock metadata service — IMDSv1 (hands out fake credentials)
  4. Build the VULNERABLE fetcher (the SSRF bug, on purpose)
  5. The IMDSv1 attack: one GET, and the credentials fall out
  6. The defense: upgrade the mock to IMDSv2 (PUT-then-GET, token-bound)
  7. Re-run the attack: the URL-only SSRF now fails
  8. The hop-limit defense — and layering the real fixes
  9. When IMDSv2 does NOT save you — and the other clouds
  10. What you did — and the reflex to keep

Open the full interactive lab →