Home › Vulnerabilities › Server-Side Request Forgery
Server-Side Request Forgery
URL parsing, cloud metadata theft, blind SSRF, DNS rebinding and egress-control defences.
▶ Here to build, not read? Jump to the Hands-On Practice.
Prerequisites: HTTP for Security Testing · DNS · Cloud Platform Security
Overview
Server-Side Request Forgery abuses a server's willingness to make outbound requests to URLs it derives from user input. The application is a trusted client sitting inside a trusted network; if an attacker can choose where it connects, they borrow that position to reach things they cannot reach directly — internal services, cloud metadata endpoints, admin interfaces bound to localhost, or other tenants. The server becomes a confused deputy.
SSRF matters far more in cloud environments than the name suggests, because cloud instances expose a metadata service at a fixed link-local address (169.254.169.254) that hands out temporary credentials to anything on the instance that asks. An SSRF that can reach that endpoint frequently converts into full cloud account compromise. The defence is not "validate the URL string" — URL parsers disagree in exploitable ways — but "control where the server is allowed to connect", enforced after DNS resolution.
How it works
A vulnerable endpoint typically looks benign: "fetch this URL and show me the result" — a link preview, a webhook tester, a PDF renderer, an image proxy. The flaw is that the destination is attacker-controlled. Exploitation explores where the server can be pointed:
- Cloud metadata —
http://169.254.169.254/latest/meta-data/iam/security-credentials/on AWS (pre-IMDSv2), or the GCP/Azure equivalents, to steal credentials. - Internal services —
http://10.0.0.5:6379/orhttp://localhost:8080/adminthat have no external route. - Blind SSRF — no response is returned, but a callback (DNS/HTTP to attacker infrastructure) confirms the request fired, and can still be weaponised.
- Filter bypass — parser confusion (
http://127.0.0.1@evil), alternate encodings, redirects, DNS rebinding (a name that resolves to a safe IP on validation and a target IP on use).
The bytes crossing the boundary are a destination, and the server's network position is the asset.
flowchart TD
A["Server-Side Request Forgery"] --> B["Concepts & terminology"]
A --> C["Internal mechanics"]
C --> D["Trust boundaries"]
D --> E["Attack surface"]
D --> F["Defensive controls"]
E --> G["Detection & telemetry"]
F --> G
G --> H["Verification in the lab"]
- Metadata service (IMDS) — A cloud endpoint at 169.254.169.254 serving instance data and temporary credentials.
- IMDSv2 — Session-token-protected metadata access that defeats naive SSRF-to-metadata.
- Blind SSRF — SSRF where the response is not returned; confirmed via an out-of-band callback.
- DNS rebinding — Bypassing validation by resolving a hostname to a safe IP at check time and a target IP at use time.
- SSRF-to-RCE — Chaining SSRF into code execution via internal services (Redis, unauthenticated admin APIs).
- Egress filtering — Network controls restricting which destinations a server may connect to.
service and retrieved the credentials of an over-privileged IAM role, which could list and read ~700 S3 buckets. ~100M US and ~6M Canadian records were exposed. Root causes worth extracting: SSRF reachability to IMDS, an over-permissioned role, and no egress control — three independent failures, each of which alone would have broken the chain.
Hands-On Practice
🧪 Lab setup — Vulnerabilities
bWAPP / DVWA / Juice Shop— the web bug targets (see the Web Security part environment)pwn-box— Ubuntu build/debug container for buffer/heap/format-string labs
# vuln-lab/docker-compose.yml — Vulnerabilities part environment
services:
bwapp:
image: raesene/bwapp
ports: ["8081:80"]
networks: [labnet]
dvwa:
image: vulnerables/web-dvwa
ports: ["8082:80"]
networks: [labnet]
pwn-box:
image: ubuntu:22.04
container_name: pwn-box
cap_add: ["SYS_PTRACE"] # allow gdb inside the container
security_opt: ["seccomp=unconfined"]
command: sleep infinity
networks: [labnet]
networks:
labnet:
driver: bridgeUses the Vulnerabilities lab environment.
Guided walkthrough
# bring up the part environment, then confirm you can reach `bWAPP / DVWA / Juice Shop` from KaliExpected output
Target reachable; you have a clean starting point.# perform the core server-side request forgery technique step by step against bWAPP / DVWA / Juice ShopExpected output
You observe the expected effect and can repeat it reliably.# inspect logs / responses / process or network activityExpected output
You can point to exactly where and why it worked.# implement the single most important fix for this techniqueExpected output
Repeating the technique now fails.Live terminal
labserver/README.md), then click Connect lab runner and paste the token. Until then, copy commands from the walkthrough and run them in your own Kali terminal.
Try it yourself
Challenge 1. Extend the walkthrough with one variation of the server-side request forgery technique and predict the result before running it.
Hint
Change one variable (payload, target, or control) at a time.
Solution
Answers vary — the goal is a correct prediction confirmed by observation.
Challenge 2. Find and apply a second defensive control for server-side request forgery and show it also blocks the technique.
Hint
Think in layers: prevention, detection, and least privilege.
Solution
Any independent control that breaks the chain counts — name why it works.
Challenge 3. Write a one-paragraph report of your server-side request forgery test mapped to CWE/ATT&CK and the fix.
Hint
Structure: finding → impact → evidence → remediation.
Solution
A defender should be able to act on your report without asking you anything.
Detect & defend (blue-team view)
- Re-run the technique while watching your telemetry — attack and detection are two views of one event.
- Turn what you observed into a detection rule (Sigma/YARA) and confirm it fires without flooding.
Skills check
You can move on when you can, without notes:
Going deeper — Why URL validation fails, and what to do instead
Attackers exploit the gap between the parser that validates the URL and the client that fetches it. Classic bypasses:
http://127.0.0.1 http://0177.0.0.1 (octal) http://2130706433 (decimal)
http://[::1] http://127.0.0.1.nip.io http://evil.com#@169.254.169.254/
http://localhost@target/ http://target%2f@safe/ 302 redirect to an internal URLRobust defence stops trying to bless the string and instead controls the connection:
- Resolve the hostname yourself, then validate the resulting IP against a deny-list of private, loopback, link-local and cloud-metadata ranges — and re-validate after any redirect.
- Pin the connection to the validated IP so DNS rebinding cannot swap it between check and use.
- Disable redirects or re-run validation on each hop.
- Enforce egress filtering at the network so a compromised fetcher simply cannot route to sensitive ranges.
- Require IMDSv2 and set the metadata hop limit to 1 so a proxied request cannot reach it.
Check Yourself
Quick self-test — answers hidden. If you can't answer without notes, redo the relevant walkthrough step.
Q1. In one sentence, what security problem does Server-Side Request Forgery address or create?
Show answer
Server-Side Request Forgery matters because its behaviour determines where trust is placed; misplacing that trust is the root of the associated bug class.
Q2. Name one trust boundary involved in Server-Side Request Forgery and what crosses it.
Show answer
Any point where attacker-influenced data meets privileged processing — e.g. user input reaching an interpreter, or a token reaching a verifier.
Q3. Give one attack against Server-Side Request Forgery and the single control that most reduces its impact.
Show answer
State the attack precisely, then the primary control (validation, encoding, isolation, authentication, or least privilege) — not a laundry list.
Interview angles
- Walk me through how Server-Side Request Forgery works, then tell me where you would attack it.
- How would you detect Server-Side Request Forgery being abused in an environment you defend?
- What is the difference between mitigating and eliminating the risk associated with Server-Side Request Forgery?
Pitfalls & Best Practice
Common mistakes
- Validating the URL string instead of the resolved IP and the actual connection.
- Validating before a redirect but not after — the redirect target is never checked.
- Allowing the fetcher to reach the metadata service (no IMDSv2, no hop-limit, no egress filter).
- Treating blind SSRF as low-risk because 'nothing comes back'.
- Relying on a single allow/deny list without pinning DNS, leaving rebinding open.
Do this instead
- Resolve, validate the IP against private/link-local/metadata ranges, and pin the connection to it.
- Disable or re-validate redirects; treat each hop as a fresh request.
- Enforce network egress filtering so sensitive ranges are unreachable regardless of app bugs.
- Require IMDSv2 and set the metadata hop limit to 1 on cloud instances.
- Prefer allow-lists of exact destinations for server-side fetchers where the use case permits.
Reference
MITRE ATT&CK Mapping
| Technique | ID |
|---|---|
| ATT&CK technique | T1190 |
| ATT&CK technique | T1552.005 |
OWASP Mapping
CWE Mapping
| CWE | Weakness |
|---|---|
| CWE-918 | Server-Side Request Forgery |
CAPEC Mapping
| CAPEC | Attack pattern |
|---|---|
| CAPEC-664 | Server Side Request Forgery |
CVE References
NIST References
- NIST CSRC Publications — search for the control family or guide relevant to this topic.
RFC References
- No governing RFC for this topic. Where a protocol is involved, its RFC is linked from the relevant networking chapter.
Research Papers
- Reflections on Trusting Trust — Ken Thompson, 1984
- Smashing the Stack for Fun and Profit — Aleph One, Phrack 49, 1996
- The Protection of Information in Computer Systems — Saltzer & Schroeder, 1975
Books
- The Web Application Hacker's Handbook, 2nd ed. — Stuttard & Pinto
- Real-World Bug Hunting — Peter Yaworski
- The Tangled Web — Michal Zalewski
- Web Security for Developers — Malcolm McDonald
Official Documentation
Related Chapters
- HTTP Request Smuggling
- Cloud Platform Security
- Remote Code Execution
- Vulnerability Taxonomy
- SQL Injection
- Blind SQL Injection
Part of the Vulnerabilities section of Cybersecurity-Mastery. 🟠 Advanced · ~72 min hands-on · Last updated 2026-08-12.