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 (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 / targetSinkValidator ↔ client gap
CVE-2026-87996 Open-WebUISafePlaywrightURLLoader RAG fetchPython gethostbyname check vs. headless Chromium’s independent resolution → AWS/GCP/Azure IMDS creds into the model’s chat context
CVE-2026-27127 Craft CMSGraphQL Asset create-from-URLgethostbyname 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 proxyisInternalHost resolves once; proxy-chain resolves again at connect. safeFetch helper in the same repo already checked the socket remote address
CVE-2025-69660 simstudioai/simproxy + file-parse APIsTOCTOU; fixed by DNS pinning (resolve once, reuse that IP)
CVE-2024-24759 MindsDBURL fetchpublic-then-private rebind; Flask PoC
CVE-2026-53708 IBM mcp-context-forge (fixed 1.0.3, CVSS 6.6)gateway URL validationblocks 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/detailcheckUpstreamAllowed() vs. unpinned resolution in fetchWithSafeRedirects(); attacker-controlled authoritative DNS
mcp-atlassian (post-fix)URL fetcherprior 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/AVideoisSSRFSafeURL() callersfunction returns $resolvedIP for pinning but 8 of 9 callers discard it and re-resolve
LarkSuite (sirleeroyjenkins)metadata fetchrebinding 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 (xalgorix).
  • Network-layer egress controls (SSRF Prevention) and IMDSv2 blunt impact even when the app-layer race is won.

Sources