SSRF: making the server fetch for you
Stage 3 · Lesson 8 · 20 minutes · Requires Stage 2
The one-line answer
Server-side request forgery (SSRF) is when an attacker gets the server to make a web request to a destination of the attacker's choosing — often somewhere inside the organisation's network that the attacker could never reach directly.
The boundary: SSRF reaches internal systems by design. On a real target that's exactly the kind of access you must never take without explicit permission. Labs only.
Why you should care
Many organisations treat their internal network as trusted: admin panels with no password "because only internal machines can reach them", internal APIs, databases. SSRF turns the public web server into a doorway into that trusted zone.
In the cloud, SSRF is especially dangerous: it has been the starting point of major breaches where attackers obtained cloud credentials through a vulnerable server.
How it actually works
The feature that becomes a bug
Plenty of applications legitimately fetch URLs on the server side:
- "Import a profile picture from a URL"
- link previews (paste a link, the app shows its title and image)
- webhooks ("we'll call this URL when your order ships")
- PDF generators that load a page
- a stock checker that asks another internal service
Recall Stage 0 Lesson 5 (reading a URL) — the ?url= example:
POST /product/stock HTTP/2
Content-Type: application/x-www-form-urlencoded
stockApi=http://stock.internal.shop:8080/check?productId=3The browser sends a URL; the server fetches it and returns the result. If the server doesn't restrict where it will fetch from, the attacker changes the URL.
Where an attacker points it
1. The server itself. http://localhost/admin or http://127.0.0.1/admin. Recall Stage 2 Lesson 1: 127.0.0.1 means "this machine". Many admin pages only allow requests from localhost — and an SSRF request comes from localhost.
2. The internal network. Private address ranges like 10.x.x.x, 192.168.x.x and 172.16–31.x.x (recall Stage 0 Lesson 1 on IP addresses). These aren't reachable from the internet, but the server can reach them.
3. Cloud metadata services. Cloud servers (AWS, Azure, GCP) can query a special internal address — commonly 169.254.169.254 — to learn about themselves, and in some configurations to obtain temporary credentials for the cloud account. An SSRF that can read this can turn one vulnerable web form into access to the company's cloud.
Impact
- Reading internal pages and admin panels.
- Performing admin actions via internal-only interfaces.
- Stealing cloud credentials from metadata services.
- Mapping the internal network (which hosts and ports respond).
Blind SSRF
Sometimes the server makes the request but doesn't show you the response. The vulnerability still exists — testers confirm it by having the server contact a system they control and checking whether the request arrived (PortSwigger's labs show how). Same root cause, same fix.
See it yourself
Only on PortSwigger labs:
- Read the SSRF topic introduction (link below).
- Do the apprentice lab basic SSRF against the local server. Find the stock-check request in HTTP history, send it to Repeater, and change the URL to point at the local admin interface as the lab describes.
- Do the apprentice lab basic SSRF against another back-end system. This one needs a small range of internal addresses — a good, short use of Intruder (Stage 2 Lesson 2).
- Write down: which feature fetched URLs, what you changed it to, and what the server returned.
How attackers abuse this
Attackers look for any parameter that contains a URL, hostname or IP — url=, link=, callback=, image=, webhook=, even inside JSON bodies or uploaded documents that the server renders. Then they redirect it inward, step by step: localhost, internal ranges, cloud metadata.
The defensive fix:
- Allowlist destinations. If the feature only needs to call
stock.internal.shop, only allow that exact host — and don't take full URLs from the client at all if you can avoid it (send a product ID; let the server build the URL). - Block internal and special ranges for any user-supplied URL: localhost, private ranges, link-local (including
169.254.169.254). Check after DNS resolution — a public-looking hostname can resolve to an internal IP — and re-check after redirects. - Disable unused URL schemes. If you only need
https://, rejectfile://,gopher://and others. - Protect cloud metadata: use the provider's hardened metadata service version (e.g. AWS IMDSv2, which requires a session token) and give servers least-privilege cloud roles.
- Network segmentation: the web server shouldn't be able to reach systems it doesn't need. Don't leave internal admin panels without authentication just because they're "internal".
- Don't return raw responses from fetched URLs to the user.
Common mistakes
- Blocklisting
localhostby name. There are many ways to write the same address (other notations, DNS names that resolve to it). Allowlist instead, and validate the resolved IP. - Validating the URL once, then following redirects. A safe URL can redirect to an internal one.
- Trusting "internal only". Internal services need authentication too.
- Forgetting blind SSRF. No visible response doesn't mean no vulnerability.
- Testing on real cloud-hosted sites. Reaching metadata on a real system is serious unauthorised access.
Check yourself
- Why can an SSRF request reach an admin page that's blocked for normal internet users?
- Why is SSRF particularly dangerous for applications hosted in the cloud?
- Why is an allowlist better than a blocklist for SSRF defence?
Answers
- The request is made by the server itself, so it comes from localhost or the internal network — which the admin page trusts.
- Cloud servers can query an internal metadata service that may hand out cloud credentials. SSRF can read it, turning one bug into access to the cloud account.
- There are endless ways to express internal destinations (alternative IP notations, DNS tricks, redirects). An allowlist of the few legitimate destinations is far easier to get right than blocking every bad one.
Your lab
- PortSwigger SSRF: https://portswigger.net/web-security/ssrf
Writeup: the URL-fetching feature, the internal target you reached, impact, and the allowlist-based fix.
Summary in your language
தமிழில் சுருக்கம்
SSRF என்பது attacker தேர்ந்தெடுக்கும் இடத்துக்கு server-ஐயே web request அனுப்ப வைப்பது — பெரும்பாலும் வெளியிலிருந்து அடைய முடியாத உள் network-க்கு. URL-ஐ server-இல் fetch செய்யும் அம்சங்கள் (image import, link preview, webhook) இதன் தொடக்கப் புள்ளி. Localhost admin pages, உள் IP வரம்புகள், cloud metadata (169.254.169.254) ஆகியவை இலக்குகள். தீர்வு: அனுமதிக்கப்பட்ட இடங்களின் allowlist, உள் வரம்புகளைத் தடுத்தல் (DNS-க்குப் பிறகு சரிபார்த்து), தேவையற்ற URL schemes-ஐ முடக்குதல், IMDSv2, network பிரிப்பு.
हिंदी में सारांश
SSRF में attacker server से ही अपनी चुनी हुई जगह पर web request भिजवाता है — अक्सर उस internal network में जहाँ बाहर से पहुँचा नहीं जा सकता। Server पर URL fetch करने वाले features (image import, link preview, webhook) इसकी शुरुआत हैं। निशाने: localhost admin pages, internal IP ranges और cloud metadata (169.254.169.254)। इलाज: मंज़ूर destinations की allowlist, internal ranges को block करना (DNS resolve होने के बाद जाँच), बेकार URL schemes बंद करना, IMDSv2 और network segmentation।
Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.
What's next
From making the server fetch to making it run commands: Command injection