btcd icon indicating copy to clipboard operation
btcd copied to clipboard

[bug]: `IsRoutable` not catching ipv6 addresses starting with `0:`

Open brunoerg opened this issue 3 months ago • 0 comments

By running differential fuzzing between btcd and Bitcoin Core for the addrv2 message, I noticed that btcd isn't correctly checking if the addresses are routable. The address 0:9881:8181:8181:fe00:a:9e:9801 is parsed as routable which is not true since this address is not valid for global routing (starts with 0). To reproduce:

diff --git a/addrmgr/network_test.go b/addrmgr/network_test.go
index f4bc5d88..5c6f424c 100644
--- a/addrmgr/network_test.go
+++ b/addrmgr/network_test.go
@@ -85,6 +85,8 @@ func TestIPTypes(t *testing.T) {
                        false, false, false, false, false, true, false, true, false),
                newIPTest("203.0.113.1", false, false, false, false, false, false, false,
                        false, false, false, false, false, false, false, true, false),
+               newIPTest("0:9881:8181:8181:fe00:a:9e:9801", false, false, false, false, false, false, false,
+                       false, false, false, false, false, false, false, true, false),
        }

        t.Logf("Running %d tests", len(tests))

brunoerg avatar Sep 25 '25 13:09 brunoerg