SSRF Explained: The Bug That Turns a Server Into an Attacker’s Puppet


Some of the most damaging web bugs are not about breaking in — they are about tricking the server into doing the attacker’s work for them. Server-Side Request Forgery, or SSRF, is the best example, and it is a favourite in bug bounty programs for a reason.

What SSRF actually is

Imagine a website with a feature that fetches a URL for you: a “preview this link” box, an image upload from URL, a webhook tester, or a PDF generator that loads a page. The server takes the URL you give it and makes the request itself.

The problem starts when the server does not check that URL properly. An attacker can hand it an internal address instead — like http://169.254.169.254/, the cloud metadata service, or http://localhost:8080/admin. The server, sitting safely inside the private network, happily fetches it and hands the result back to the attacker.

Suddenly the attacker is reading internal services they could never reach from the outside, because the server is fetching them on their behalf. In cloud environments, the metadata endpoint can even leak temporary credentials — and that turns SSRF into a full account takeover.

Where hunters look for it

SSRF hides in any feature where the server fetches something for the user:

  • URL preview or “fetch this page” tools
  • Image uploads by URL
  • Webhook and callback testers
  • File converters and PDF generators
  • API parameters that accept a URL, like?url= or?image=

A classic first test, on systems you are authorised to test, is pointing such a feature at an address you control and watching whether your server logs a request from the target. If it does, you have confirmed the server will fetch arbitrary URLs — and that is the core of the bug.

How to confirm it safely

In a lab or a bug bounty target within scope, hunters use a collaborator-style service: a unique URL that records incoming requests. If the target’s server contacts that URL, SSRF is confirmed without touching any internal system. This matters because blindly pointing SSRF at internal addresses on a live target can disrupt real services — a good hunter proves the bug without causing damage.

How developers stop it

If you build web applications, SSRF is very preventable:

  • Allowlist, don’t blocklist. Only let the feature fetch domains you explicitly approve. Blocklists always miss something.
  • Block private and internal ranges. Reject requests to localhost, 10.x, 172.16.x, 192.168.x and the cloud metadata address 169.254.169.254 before they are made.
  • Resolve, then check. Resolve the hostname to an IP address first, check that IP against your blocklist, and only then make the request. Otherwise an attacker can use DNS tricks to slip past a domain check.
  • Disable redirects or validate them. A redirect from an allowed URL to an internal one is the same bug wearing a different coat.

The rule that keeps you legal

SSRF is powerful, which is exactly why it must only be tested where you have permission: your own lab, a CTF challenge, or a bug bounty program whose scope explicitly includes the target. Only test systems you own or have written permission to test — probing a random company’s URL preview feature is not research, it is unauthorised access.

Learn it in a lab first, and SSRF goes from a scary acronym to one of the most satisfying bugs you will ever find.

Comments

Popular Posts