Server-Side Request Forgery (SSRF)¶
← Back to index · Stage 2/3 (reach internal functionality) · Read the mindset page first.
Why it exists: the app makes an HTTP request to a URL you supply (fetch a preview, check a supplier, load an image from a link). The server then acts as a confused proxy — it can reach internal services that trust it and that you can't reach directly (an admin interface on localhost, cloud metadata). On BSCP it's typically a route to internal admin functionality or a Collaborator-confirmed foothold.
The one rule: confirm the fetch reaches somewhere first (a Collaborator ping proves SSRF even when every internal address is filtered) → then refine the target and defeat the filter.
Decision tree¶
flowchart TD
A["Server fetches a URL you supply?"] --> B{"Is the response shown back?"}
B -->|yes| C["Point at an internal service"]
B -->|no| BL["Blind: confirm via Collaborator"]
C --> D{"Filtered?"}
D -->|no| HIT["localhost/admin, 169.254.169.254"]
D -->|allowlist| AL["@ / # / redirect tricks"]
D -->|blocklist| BLK["decimal IP / 127.1 / [::1]"]
HIT --> OUT["Use the internal response"]
AL --> OUT
BLK --> OUT
BL --> OUT
Reading the response: if the fetched content is returned, read it for the internal service's response (an admin page, cloud metadata). If it isn't, the signal moves out-of-band — a Collaborator hit proves the server made the request at all, confirming the bug even when every internal target is filtered. No hit at all = the parameter probably isn't fetched server-side; re-confirm the sink before trying filter bypasses.
1. Find the fetcher¶
A parameter holding a URL or hostname: a stock check against another store, a webhook, a link preview, an avatar-from-URL. If the server goes and fetches what you put there, it's an SSRF candidate.
2. Targets — why these¶
Why localhost/metadata: services bound to 127.0.0.1 assume only the server itself can reach them, so they skip auth — and the SSRF lets you be the server. Cloud metadata (169.254.169.254) hands out credentials to anything on the box.
http://localhost/admin # internal admin, often unauthenticated
http://localhost/admin/delete?username=carlos
http://169.254.169.254/latest/meta-data/ # cloud credentials
3. Filter bypass — why each works¶
The app tries to stop you reaching internal hosts; you exploit the gap between its URL parsing and the actual request:
# allowlist (URL must contain a trusted host) — abuse userinfo/fragment parsing:
https://trusted.com@localhost/admin (everything before @ is a username; the host is localhost)
https://localhost#trusted.com/admin (# starts a fragment; the host is still localhost)
# blocklist (blocks 'localhost'/'127.0.0.1') — same destination, different spelling:
http://127.1/ http://2130706433/ (decimal) http://[::1]/ http://0177.0.0.1/ (octal)
# open-redirect chain — point SSRF at an on-site redirect that bounces to internal (filter only sees the allowed URL)
https://TARGET/next?path=http://169.254.169.254/
4. Blind SSRF¶
Why Collaborator: when the response isn't returned, a DNS/HTTP hit to Collaborator proves the server made the request at all — which confirms the bug exists so you can then work on the filter bypass.
Failure modes¶
- No Collaborator hit at all → the parameter may not be fetched server-side; re-confirm the sink is real.
- Allowlist blocks you →
@,#, or an open-redirect so the trusted host appears but resolves internal. - Blocklist blocks you → alternate IP encodings (decimal, octal,
127.1,[::1]) — same host, spelling the filter didn't anticipate. - Fetched but no body returned → blind; pivot to an open redirect or infer from response differences.
- Reaching the secret → SSRF reaches services, not files directly; to read
/home/carlos/secretyou usually chain SSRF to an internal admin action, not a direct file read.