This article presents an interactive lab teaching server-side request forgery (SSRF) through a practical scenario where an avatar fetcher application can be exploited to retrieve cloud metadata credentials. SSRF is a critical vulnerability because it abuses a server's internal network access and trust relationships to reach systems the attacker cannot access directly. The lab demonstrates why this matters: a misconfigured URL fetcher becomes a pivot point into cloud infrastructure, and understanding this attack is essential for both defensive and offensive security practitioners.
- How SSRF exploits server trust relationshipsSSRF works because metadata services on cloud platforms trust requests originating from the server itself, operating at a fixed internal address like AWS's 169.254.169.254. When the server fetches a user-supplied URL pointing to this address, the metadata service treats it as legitimate, returning sensitive data including temporary access keys and IAM role credentials that would normally be inaccessible to external attackers.
- The AvatarFetcher vulnerability mechanismThe application accepts any URL without validation, requests it from the server, and returns the response directly to the user. The lab requires no allowlist and no destination checking, meaning an attacker can simply replace a legitimate image URL with the cloud metadata service address to retrieve the server's internal secrets in one request.
- Real-world impact and precedentThe 2019 Capital One breach exposed over 100 million people's data by using SSRF against a misconfigured web application firewall to reach AWS metadata and steal credentials. This breach was significant enough that SSRF was added as its own category to the OWASP Top 10 in 2021, and AWS subsequently released IMDSv2 partly to mitigate this specific attack vector.
- Validation timing and DNS rebinding preventionA key defensive principle is to block internal ranges—loopback, private, link-local, and metadata address ranges—after DNS resolution, not before. This prevents attackers from bypassing allowlists with DNS tricks or redirects; the check must happen after the domain resolves and again after each redirect the server follows.
- IMDSv2 as a targeted mitigationAWS introduced IMDSv2, which requires a session token obtained via a PUT request before any metadata can be read. This stops simple SSRF attacks from retrieving metadata via GET requests, but the article notes it does not fix SSRF against other internal services, making it one layer of defense rather than a complete solution.
- Allowlist over blocklist strategyThe article recommends allowlisting destinations by hostname where possible instead of trying to block bad ones. This shifts the burden to the defender to explicitly permit only known safe destinations, a stronger security posture than attempting to enumerate all dangerous addresses.
- Broader SSRF attack surfaceThe article identifies any feature that accepts a URL as a potential SSRF vector: avatars, link previews, webhooks, PDF generators, and import-from-URL tools. This wide attack surface means SSRF defense must be built into all user-facing URL-handling functionality, not just specialized services.
- Response validation prevents data exfiltrationBeyond blocking dangerous destinations, the article recommends not returning raw responses to users; validate that the fetched content is actually an image. This reduces the attacker's ability to see metadata or internal error messages that reveal system topology and credentials.
Bottom line: SSRF is a critical vulnerability that turns a server's network access into a weapon against itself, and cloud environments amplify the risk because metadata services expose credentials at fixed, predictable addresses. Effective defense requires multiple layers: allowlisting destinations, blocking internal ranges after DNS resolution, enforcing IMDSv2 or equivalent, isolating the fetching function, and validating response content.
📋 In this walkthrough
What this lab teaches
Server-side request forgery (SSRF) is when you make a server send a request on your behalf to somewhere you choose. The danger is not the request itself but where it comes from: inside the network, with the server’s own trust and access.
Cloud servers make SSRF especially serious, because each one can reach a metadata service at a fixed internal address that returns configuration and, often, temporary access keys.
How AvatarFetcher downloads images
The fetcher takes any URL, requests it from the server and returns what it gets. There is no allowlist and no check on where the URL points. The lab is solved when the response contains the secret token from the internal metadata service.
The attack approach
- Fetch a normal public image URL first to see how responses are shown.
- Ask what this server can reach that you cannot: loopback, private ranges and the cloud metadata address.
- Major cloud providers expose metadata at a well-known link-local IP address. Point the fetcher there.
- Explore the metadata paths until you find the credentials for the server’s role.
Full walkthrough (spoiler)
Stuck after a few attempts? Open the steps below. Solving it yourself first is worth more XP, and more learning.
Show the step-by-step solution
- Enter a normal image URL and confirm the fetcher downloads it.
- Replace it with the metadata service address used by AWS (the link-local 169.254.169.254 address) and its latest meta-data path.
- Follow the listing down to the IAM security credentials section and request the role name shown there.
- The response now contains the internal secret token. The lab detects it and marks you solved.
Why it works
The metadata service trusts any request that comes from the machine itself, because only the machine should be able to reach that address. The fetcher is the machine, so when it fetches your URL, the metadata service answers. You never touched the internal network; you persuaded something inside it to do it for you.
Where this happens in the real world
The 2019 Capital One breach, which exposed data on more than 100 million people, used an SSRF against a misconfigured web application firewall to reach the AWS metadata service and steal credentials. SSRF was added to the OWASP Top 10 as its own category in 2021, and AWS introduced IMDSv2, which requires a session token, largely to block this attack.
How to defend against it
- Allowlist destinations by host name where you can, instead of trying to block bad ones.
- Resolve, then check. Block loopback, private, link-local and metadata ranges after DNS resolution, and on every redirect.
- Enforce IMDSv2 on AWS (or the equivalent on other clouds) so simple GET requests cannot read metadata.
- Fetch from an isolated service with no access to internal networks or credentials.
- Do not return raw responses to the user; validate that the result really is an image.
Try it, then go further
Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.
