SSRF Exploitation Guide
Server-Side Request Forgery is one of the most versatile vulnerabilities in modern web applications. When a server fetches a URL you control, you gain a proxy into internal infrastructure — cloud metadata, internal APIs, and in some cases code execution.
What is SSRF?
The server makes an HTTP request on your behalf. You control the destination URL. The response may be reflected to you (basic SSRF) or only the side-effects are observable (blind SSRF).
Common entry points:
- URL or link parameters:
?url=,?src=,?path=,?redirect= - Webhooks: “notify me at this URL”
- PDF / screenshot generators
- Import from URL features (avatar, document, feed)
- XML parsers with DTD (XXE can become SSRF)
Hostheader injection in some configurations
Basic Detection
Replace the target URL with your server:
|
If you get a hit on your server, SSRF is confirmed. If not, try:
|
Internal Service Enumeration
Port scanning
|
Different response sizes/times indicate open vs closed ports.
Internal subnet scanning
|
Use Burp Intruder on the last octet to map live hosts.
Cloud Metadata APIs
This is where SSRF becomes critical. Most cloud platforms expose instance metadata at a link-local address.
AWS EC2
|
The credentials endpoint returns temporary AWS keys:
|
Use them with the AWS CLI: aws --profile stolen s3 ls
IMDSv2 requires a PUT request to get a token first — some SSRF primitives can’t do PUT, but many can:
|
Google Cloud
|
Azure
|
URL Filter Bypass Techniques
Applications often try to block 127.0.0.1 or 169.254.169.254. Bypass:
IP obfuscation
|
DNS rebinding
Register rebind.attacker.com to resolve to a public IP initially (to pass validation), then change the DNS to 127.0.0.1 before the second request. The server fetches your internal target.
Redirect chain
Host a page that 302-redirects to the internal URL:
|
If the application follows redirects, it fetches the metadata endpoint.
URL parser confusion
|
Protocol tricks
|
Gopher Protocol — Attacking Internal Services
The gopher:// protocol lets you send raw bytes to a TCP port. This is SSRF-to-RCE territory.
Redis RCE via gopher
Write a cron job to Redis:
|
Tool: Gopherus — auto-generates gopher payloads for Redis, MySQL, FastCGI, SMTP, etc.
|
Blind SSRF
No response reflected. Use out-of-band confirmation.
- DNS callback:
http://YOUR_ID.interactsh.com/— confirms DNS resolution. - HTTP callback: full HTTP hit on your server — confirms TCP + HTTP.
- Timing differences: open port responds faster than closed/filtered.
Tools: Burp Collaborator, interactsh, requestbin.
SSRF to Internal API Abuse
Many microservice architectures trust internal traffic without auth:
|
Tools
|
Remediation
- Maintain an allowlist of permitted domains/IPs — deny everything else.
- Block requests to
169.254.0.0/16,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16, and127.0.0.0/8. - Don’t follow redirects, or re-validate after redirect resolution.
- Use IMDSv2 on AWS (requires token PUT, blocks naive SSRF).
- Parse URLs with a consistent library and validate the resolved IP, not just the hostname string.
Discussion
Leave a comment · All fields required · No spam
No comments yet. Be the first.