URL Parser Differentials

SSRF filter bypasses that exploit two components parsing the same URL string differently — the validator reads one host, the HTTP client dials another — because userinfo, backslashes, fragments, schemes, or Unicode are handled divergently across WHATWG vs RFC 3986 and across language libraries.

How it works

A safe-URL check and the fetcher are rarely the same parser. The guard extracts a “host,” approves it, and passes the original string onward; the client re-parses and resolves a different authority. RFC 9525 §7.4 names the pattern exactly: “one component enforces a security rule… whereas a second component correctly classifies the identifier but incorrectly assumes that rules… have been enforced by the first.” The binding between the approved authority and the socket is lost.

xclow3n’s audit frames it as six handoffs where the binding can break — parse → object-build → resolve/select → connect, plus authority-emit and redirect/route — and most parser bugs live at the first box: pick a URL, find the two parsers an app runs it through, and diff what each calls the host. Beyond parsing, the same loss happens at resolve time (DNS Rebinding / A-vs-AAAA), at Host-header emit, in HTTP/2 :authority, and on redirect re-entry (Open Redirect to SSRF).

Techniques / payloads

Authority-boundary confusion — @, backslash, brackets. Anything before @ is userinfo; parsers disagree where the host starts, especially with invalid input. WHATWG treats \ as / (host→path transition); RFC 3986 does not — the backslash trick.

https://trusted.example.com@evil.attacker.com/   # startsWith()/prefix check sees trusted, host is evil
https://expected-host@evil-host                  # embedded creds
http://169.254.169.254:80\@example.com/          # validators.url sees example.com; urllib3 dials 169.254.169.254
http://localhost:\@google.com/../                # CVE-2025-0454 AutoGPT: allowlist sees google.com, request hits localhost
https://example.com\[@internal                   # CVE-2024-22243/-22262 Spring UriComponentsBuilder: '[' in userinfo
https://evil-host#expected-host                  # fragment confusion
https://attacker.com%2523@victim                 # double-encoded '#' to defeat split("#")
http://1.1.1.1 &@2.2.2.2# @3.3.3.3/              # per-parser: urllib2→1.1.1.1, requests→2.2.2.2, urllib→3.3.3.3

Scheme-regex divergence. Two regexes for RFC 3986 scheme grammar disagree. Apache Solr’s AllowListUrlChecker used (\w+)(://.*) (accepts digits/uppercase), so 2130706433://realnode:8983/... was rewritten to a safe host; the fetcher’s ^([a-z]*?://) didn’t match, re-prefixed http://, and 2130706433: parsed as host=2130706433 = 127.0.0.1 (RFC 2396 allows an empty port). Guard saw realnode, client dialled loopback.

Prefix / substring allowlists (not parsing at all):

https://webdav.yandex.com.attacker.tld/evil     # ChatGPT-Next-Web: no delimiter after allowed prefix
https://attacker.com/{allowed}  https://{allowed}.attacker.com

Broken-parser grab-bag (confuse filter vs back-end): URL-encode host chars when the two layers decode differently; DNS hierarchy expected-host.evil-host; attacker%00.com, attacker%E3%80%82com (。), //attacker.com, http:/\/\attacker.com. Orange Tsai’s “A New Era of SSRF” primitives: http://127.1.1.1:80\@@127.2.2.2:80/, http://127.1.1.1:80#\@127.2.2.2:80/. PHP filter_var() bypass: 0://evil.com:80;http://google.com:80/. Fuzz filter edges with recollapse; generate host-mangling corpora with SSRF-PayloadMaker / the PortSwigger URL-validation-bypass webapp.

Charset / emit. Node emits different ASCII from the Unicode a caller validated (IDN drift, charset narrowing) — bytes on the wire the validator never saw.

Notable cases

  • CVE-2026-27696 changedetection.io — three parsers on one string: PyPI validators.url(), urllib.parse.urlparse().hostname, and urllib3. http://169.254.169.254:80\@example.com/ ran the full IMDSv2 flow and stored the instance-id as watch content; unauthenticated, default Docker image. Patch still wired its check to urlparse().hostname (wrong parser).
  • Apache Solr — dual scheme-regex differential (shards param, AllowListUrlChecker CVE-2017-3164/CVE-2021-27905 lineage) dialled loopback.
  • CVE-2025-0454 AutoGPT — requests+urllib.parse mismatch on http://localhost:\@google.com/../.
  • CVE-2024-22243/-22262 Spring UriComponentsBuilder — [ in userinfo parsed differently than browsers.
  • CVE-2026-3125 @opennextjs/cloudflare — path-normalization differential (backslash substitution) between Cloudflare’s edge and the JS URL class in /cdn-cgi/image/; CWE-706. Shows the same divergence class at the path, not just the host.

Defenses

  • Parse once, with the fetcher’s parser, and carry that result to the socket; never let the client re-parse an un-pinned string. changedetection.io’s correct check is urllib3.util.parse_url(url).host, the parser that actually dials.
  • Reject invalid-input recovery: refuse backslashes in authority, refuse @/userinfo, enforce a scheme allowlist with a single canonical grammar, strip/forbid fragments before validation.
  • Allowlist hosts with an exact match after a required delimiter, not startsWith/substring. Validate the resolved IP (IP Address Encoding Bypasses) and re-validate every redirect hop.

See also: CORS Misconfiguration

See also: Path Traversal · Zip Slip and Archive Extraction

Sources