Skip to content

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

@brunoerg

Description

@brunoerg

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions