btcd/addrmgr
Eric Grill 4a4e2d2495 addrmgr: fix IsRoutable for IPv6 addresses starting with 0
In this commit, we fix `IsRoutable` to correctly reject IPv6 addresses
whose first 16-bit group is zero (i.e., in the `0000::/16` reserved
block per RFC 4291). Differential fuzzing between btcd and Bitcoin Core
revealed that addresses like `0:9881:8181:8181:fe00🅰️9e:9801` were
slipping through as routable when they shouldn't be.

We add a new `zero6Net` (`0000::/16`) definition alongside the existing
`zero4Net`, and introduce an `IsZero` helper that checks both. The /16
prefix width is intentional: the broader /8 reservation would
incorrectly catch allocated sub-ranges like `0064:ff9b::/96` (RFC 6052,
NAT64). We also carve out an exception for RFC 6145 translated IPv4
addresses (`::ffff:0:0:0/96`), which live within `0000::/16` but are
valid for routing.

Test coverage includes the original bug report address, various
zero-prefix IPv6 addresses, the RFC 6145 exclusion, and corresponding
`GroupKey` entries to confirm they land in the "unroutable" bucket.

Fixes #2431
2026-03-23 20:46:11 -04:00
..
addrmanager.go multi: update addrmgr, server to use NetAddressV2 instead of legacy 2022-02-24 13:11:15 -05:00
addrmanager_internal_test.go multi:use t.TempDir replace os.MkdirTemp 2025-03-07 16:54:47 +08:00
addrmanager_test.go multi: update addrmgr, server to use NetAddressV2 instead of legacy 2022-02-24 13:11:15 -05:00
cov_report.sh multi: deprecation gocov 2025-03-19 09:45:48 +08:00
doc.go multi: Run gofmt on the entire repository 2023-06-21 22:31:09 +09:00
internal_test.go multi: update addrmgr, server to use NetAddressV2 instead of legacy 2022-02-24 13:11:15 -05:00
knownaddress.go multi: update addrmgr, server to use NetAddressV2 instead of legacy 2022-02-24 13:11:15 -05:00
knownaddress_test.go multi: update addrmgr, server to use NetAddressV2 instead of legacy 2022-02-24 13:11:15 -05:00
log.go Relicense to the btcsuite developers. 2015-05-01 12:00:56 -05:00
network.go addrmgr: fix IsRoutable for IPv6 addresses starting with 0 2026-03-23 20:46:11 -04:00
network_test.go addrmgr: fix IsRoutable for IPv6 addresses starting with 0 2026-03-23 20:46:11 -04:00
test_coverage.txt Add more reserved IP space to address manager. 2014-12-16 13:02:39 -05:00