-
Is it possible to remove |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I spent a bit of time digging into whether Connecting to either of An address like It's currently unclear to me how Free|Open|NetBSD behave in these cases, or what macOS or Windows do. Best not take to take any chances and just keep them in the IPvXSpecialPurpose set ensuring we don't even allow the dial to take place. It's one more entry to check, I'm sure we'll survive. You can try all of this yourself with a simple snippet like the following and observing your network traffic with Wireguard: package main
import (
"fmt"
"net"
"code.dny.dev/ssrf"
)
func main() {
fmt.Println(regularDial("0.0.0.1:443"))
fmt.Println(safeDial("0.0.0.1:443"))
}
func regularDial(address string) error {
conn, err := net.Dial("tcp", "0.0.0.1:443")
if err == nil {
conn.Close()
}
return err
}
func safeDial(address string) error {
dialer := &net.Dialer{
Control: ssrf.New().Safe,
}
conn, err := dialer.Dial("tcp", "0.0.0.1:443")
if err == nil {
conn.Close()
}
return err
}
In the case of |
Beta Was this translation helpful? Give feedback.
I spent a bit of time digging into whether
0.0.0.0/8
and::/128
could be removed from the list. Turns out we can't, because they actually go places we don't want them to go.Connecting to either of
0.0.0.0
and[::]
works. The addresses aren't valid destination addresses and as such sending it out of this machine wouldn't be valid and the OS should ensure that doesn't happen. In the case of Linux at least, this results in localhost being copied into the destination address instead, resulting in it being functionally equivalent to127.0.0.1
or::1
and the packet being sent out through the loopback interface. As such, if a DNS lookup of a name would return0.0.0.0
for an A-record or::
for A…