HackBlue

Labs / Web and API security

SSRF allowlist evaluator

An image import feature fetches URLs on the server. Combine host matching, address checks, redirect checks, and pinning until nine test URLs behave.

  • Interactive lab
  • Advanced
  • 5 steps
  • 0 of 5 solved

What you’re looking at

An image import feature fetches URLs on the server. Combine host matching, address checks, redirect checks, and pinning until nine test URLs behave.

Your goal: Configure the image fetcher so both partner images load and nothing reaches an internal address or a host that is not on the list.

Host check
three buttons on the left: no check, a loose text match, or an exact match on the parsed host name.
Controls
three switches: reject internal addresses after DNS, re-check every redirect, and connect only to the checked address.
Test plan
nine URLs on the right, each with what should happen, what did happen, and a Show trace button.
Walkthrough
the numbered path beside the workbench (below it on a phone). Each step says what to do and what you should see. Hints open one at a time.

Words you will meet

SSRF
server-side request forgery, making a server fetch a web address for you
URL
web address
DNS
Domain Name System, which turns names into addresses

Start with step 1 in the walkthrough. Every step says what to do and what you should see. The whole thing takes about 2 min to talk through.

Briefing

A catalog tool lets suppliers paste an image URL, and the server downloads it. The server sits in a cloud network next to an admin service and the instance metadata endpoint.

Nine URLs from the test plan are listed below. Choose the host check and turn on the controls you need until both partner images load and nothing reaches an internal address or an unlisted host. DNS and redirects are simulated.

Host check

Controls

Allowlist

  • images.partner.example
  • cdn.partner.example
  • media.partner.example
  • legacy.partner.example
Test plan5 wrong
  • fetched
    https://images.partner.example/catalog/42.pngAn ordinary product image · should load
  • fetched
    https://cdn.partner.example/i/7Partner CDN link that redirects to the image host · should load
  • reached unlisted host
    https://images.partner.example.attacker.example/x.pngThe allowed name followed by another domain · should be blocked
  • reached unlisted host
    https://images.partner.example@203.0.113.9/x.pngThe allowed name before an @ sign · should be blocked
  • blocked
    http://169.254.169.254/latest/meta-data/The cloud instance metadata address · should be blocked
  • blocked
    http://0x7f000001:8080/Loopback written in hexadecimal · should be blocked
  • reached internal
    https://cdn.partner.example/r/old-logoAn allowed host that redirects inside the network · should be blocked
  • reached internal
    https://legacy.partner.example/logo.pngAn allowed name whose DNS points at a private address · should be blocked
  • reached internal
    https://media.partner.example/a.pngA name whose DNS answer changes between check and connect · must not reach inside

The whole walkthrough

Every step in order, written to be read aloud: 293 words, about 2 min. It gives away every answer, so try the steps first.