# DNS Rebinding > An SSRF filter bypass that exploits the TOCTOU gap between the DNS lookup a validator uses to approve a host and the independent lookup the HTTP client makes at connect time, so the same hostname resolves to a public IP during validation and an internal IP during the fetch. ## How it works A safe-URL guard typically resolves the user-supplied hostname once (`socket.gethostbyname`), checks the result against private/loopback/link-local/metadata ranges, and — if it passes — hands the **original hostname string** to the HTTP client. The client (libcurl/Guzzle, `requests`/urllib3, Chromium's net stack, a headless-browser proxy) does its **own** second resolution. If the attacker controls the authoritative zone for the hostname and serves records with `TTL 0`, the two lookups can return different addresses: `8.8.8.8` / `93.184.216.34` for the check, `169.254.169.254` or an RFC 1918 host for the connect. Nothing binds the approved address to the socket, so the fetch reaches an internal target. CWE-367. This is a **server-side validate-to-fetch race**, distinct from the classic browser same-origin rebinding workflow; the browser-oriented Singularity framework is not a drop-in for it. A related non-race variant exists where a single static hostname carries divergent `A` and `AAAA` records and the validator uses an IPv4-only resolver (`gethostbyname`) while the client does a dual-stack `getaddrinfo(AF_UNSPEC)` — Mealie checked `A`=`8.8.8.8` and dialled `AAAA`=`fd00::beef` with no rebinding at all (see [[URL Parser Differentials]]). ## Techniques / payloads - **Authoritative zone, TTL 0.** Run a custom nameserver (dnslib/Flask-based PoC, or NCC Group `Singularity`) that alternates `A`/`AAAA` per query; log queries to distinguish the validation lookup from the connection lookup. Answer each record type's first query with a public IP and later queries with the internal target. - **Public rebinding services** (no infra): `rbndr.us` (encode two IPs into one hostname, e.g. loopback ↔ `8.8.8.8`), `1u.ms` (`make-127-0-0-1-rr.1u.ms` → `127.0.0.1`), and wildcard-DNS helpers `nip.io`/`sslip.io` for the static-resolution case. See [[IP Address Encoding Bypasses]]. - **Caveat — a low TTL does not guarantee a second lookup.** If the client reuses a connection, pins DNS, or a caching resolver sits in the path, the second query never leaves. Reliability is probabilistic: one writeup landed ~1 in 30 attempts. Fire repeatedly and confirm from your DNS log that the server made a second lookup *and* that the second address was reached. - **Proving the fix (and the bug).** A 403 for `http://169.254.169.254/` proves nothing about rebinding. Test with a TTL-0 name whose first answer is public and next is internal, assert the client connects only to the validated address and never performs the second lookup, add a separate test that a first-answer blocked address is refused, and repeat to account for the race ([[raw/xalgorix.com/a-passed-check-is-not-proof-the-ssrf-filter-that-resolves-dns-twice-15832|xalgorix]]). - **Static DNS-to-metadata (degenerate case).** If the guard is a pure string denylist that never resolves, you don't need rebinding — just point an attacker domain's `A` record straight at `169.254.169.254` (defeated a denylist on an Azure target). Cloud metadata still needs its header, e.g. `Metadata: true` for Azure IMDS. ## Notable cases | CVE / target | Sink | Validator ↔ client gap | |---|---|---| | CVE-2026-87996 Open-WebUI | `SafePlaywrightURLLoader` RAG fetch | Python `gethostbyname` check vs. headless Chromium's independent resolution → AWS/GCP/Azure IMDS creds into the model's chat context | | CVE-2026-27127 Craft CMS | GraphQL `Asset` create-from-URL | `gethostbyname` check vs. Guzzle/libcurl re-resolve; patch of CVE-2025-68437 (string denylist) was the thing bypassed. Fixed by validating Guzzle `ON_STATS` `primary_ip` mid-request | | CVE-2026-116066 Firecrawl (<2.11.586) | Playwright scraper SSRF proxy | `isInternalHost` resolves once; `proxy-chain` resolves again at connect. `safeFetch` helper in the same repo already checked the socket remote address | | CVE-2025-69660 simstudioai/sim | proxy + file-parse APIs | TOCTOU; fixed by **DNS pinning** (resolve once, reuse that IP) | | CVE-2024-24759 MindsDB | URL fetch | public-then-private rebind; Flask PoC | | CVE-2026-53708 IBM mcp-context-forge (fixed 1.0.3, CVSS 6.6) | gateway URL validation | blocks private/loopback/link-local/metadata, then passes the hostname to a client that "independently re-resolves DNS at connection time"; source carried a TODO admitting it | | CVE-2026-123207 LibreTV (< 2.21.2, CVSS 2.3, CWE-367) | `/api/source/test`, `/api/proxy`, `/api/search`, `/api/detail` | `checkUpstreamAllowed()` vs. unpinned resolution in `fetchWithSafeRedirects()`; attacker-controlled authoritative DNS | | mcp-atlassian (post-fix) | URL fetcher | prior SSRF fix "returns a string verdict, not a pinned IP"; author calls the PoC a boundary demonstration, not live end-to-end | | CVE-2026-43884 WWBN/AVideo | `isSSRFSafeURL()` callers | function returns `$resolvedIP` for pinning but 8 of 9 callers discard it and re-resolve | | LarkSuite (sirleeroyjenkins) | metadata fetch | rebinding to exfiltrate AWS metadata past a resolving denylist | ## Defenses - **DNS pinning** is the core fix: resolve the hostname once, validate that address, then connect to **that IP** (pass it to the client / pin the socket), not the hostname. simstudioai/sim and Firecrawl both converged on this. - Validate at the **point of use**: inspect the actual connected peer — Guzzle `ON_STATS.primary_ip`, the socket's remote address at connect — rather than a pre-flight resolve. Re-validate on every redirect hop (see [[Open Redirect to SSRF]]). - Check **both** `A` and `AAAA` / use a dual-stack resolver so an IPv4 check can't miss an IPv6 target; block IPv4-mapped and NAT64 forms. - Validate **every** returned record, not the first, and pin one validated address; rewriting the URL to the IP breaks TLS verification, so pin via a custom resolver/transport that keeps the hostname for `Host`, SNI and cert checks. Apply the policy to retries and connection-pool fallbacks too ([[raw/xalgorix.com/a-passed-check-is-not-proof-the-ssrf-filter-that-resolves-dns-twice-15832|xalgorix]]). - Network-layer egress controls ([[SSRF Prevention]]) and [[IMDSv2]] blunt impact even when the app-layer race is won. ## Related - [[Server-Side Request Forgery]] - [[URL Parser Differentials]] — the static validator-vs-client divergence that needs no race - [[IP Address Encoding Bypasses]] — wildcard-DNS and rebinding services - [[Cloud Metadata Service Exploitation]] · [[IMDSv2]] — the usual rebinding target - [[Open Redirect to SSRF]] — the other common validate-to-fetch gap - [[Blind SSRF]] · [[Out-of-Band Detection]] — confirming the second lookup - [[SSRF Prevention]] ## Sources - [[raw/sh3llc0d3.com/open-webui-toctou-dns-rebinding-ssrf-to-cloud-metadata-13399|Open-WebUI TOCTOU DNS Rebinding SSRF (CVE-2026-87996)]] - [[raw/cvereports.com/cve-2026-27127-weaponizing-dns-rebinding-to-bypass-ssrf-filters-in-cra-3199|Weaponizing DNS Rebinding to Bypass SSRF Filters in Craft CMS (CVE-2026-27127)]] - [[raw/theinjection.dev/firecrawl-a-dns-rebinding-ssrf-bypass-12461|Firecrawl: a DNS rebinding SSRF bypass (CVE-2026-116066)]] - [[raw/clear-gate.com/ssrf-with-dns-rebinding-clear-gate-3204|SSRF with DNS Rebinding]] - [[raw/blog.cyberadvisors.com/using-dns-to-bypass-ssrf-protections-3201|Using DNS To Bypass SSRF Protections]] - [[raw/aydinnyunus.github.io/ssrf-vulnerability-bypassing-protection-with-dns-rebinding-attack-4779|SSRF DNS Rebinding (CVE-2025-69660, simstudioai/sim)]] - [[raw/github.com/mindsdb-bypass-ssrf-protection-with-dns-rebinding-3198|Bypass SSRF Protection with DNS Rebinding (MindsDB, CVE-2024-24759)]] - [[raw/mokhansec.medium.com/bypassing-filters-ssrf-exploitation-via-dns-rebinding-with-just-1-in-3-5103|SSRF via DNS Rebinding with 1 in 30 successful requests]] - [[raw/book.hacktricks.xyz/url-format-bypass-hacktricks-43|URL Format Bypass - HackTricks]] - [[raw/intigriti.com/ssrf-advanced-exploitation-guide-3318|SSRF advanced exploitation guide]] - [[raw/xclow3n.com/the-validator-can-lie-ssrf-beyond-url-validation-gitlab-mealie-apache-11882|The Validator Can Lie: SSRF Beyond URL Validation]] - [[raw/vulncheck.com/libretv-ssrf-protection-bypass-via-dns-rebinding-15833|LibreTV SSRF protection bypass via DNS rebinding]] - [[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]]