# 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 `302`s 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): ```python # 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 ([[raw/xalgorix.com/a-passed-check-is-not-proof-the-ssrf-filter-that-resolves-dns-twice-15832|xalgorix]]). - **Traewelling GHSA-4h3f-pf38-2rhj** — webhook delivery via Guzzle with default `allow_redirects` (5 hops): an `https://` attacker host `302`s to `http://169.254.169.254/latest/meta-data/`, switching POST to GET ([[raw/github.com/traewelling-ssrf-via-outgoing-webhook-url-15834|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 - [[raw/leviathansecurity.com/bypassing-ssrf-filters-using-r3dir-4198|Bypassing SSRF Filters Using r3dir]] - [[raw/osintteam.blog/ssrf-filters-bypass-using-redirects-15192|SSRF Filters Bypass Using Redirects]] - [[raw/sirleeroyjenkins.medium.com/just-gopher-it-escalating-a-blind-ssrf-to-rce-for-15k-1995|Just Gopher It: Escalating a Blind SSRF to RCE for $15k]] - [[raw/book.hacktricks.xyz/url-format-bypass-hacktricks-43|URL Format Bypass - HackTricks]] - [[raw/0xn3va.gitbook.io/server-side-request-forgery-82|Server-Side Request Forgery - 0xn3va cheat sheet]] - [[raw/intigriti.com/ssrf-advanced-exploitation-guide-3318|SSRF advanced exploitation guide]] - [[raw/pravinponnusamy.medium.com/ssrf-payloads-1987|SSRF payloads]] - [[raw/xalgorix.com/a-passed-check-is-not-proof-the-ssrf-filter-that-resolves-dns-twice-15832|A passed check is not proof: the SSRF filter that resolves DNS twice]] - [[raw/github.com/traewelling-ssrf-via-outgoing-webhook-url-15834|Traewelling SSRF via outgoing webhook URL]]