Skip to content

addrmgr: mark IPv6 zero addresses as non-routable#2474

Merged
Roasbeef merged 1 commit intobtcsuite:masterfrom
EricGrill:fix/ipv6-zero-address-routable
Mar 24, 2026
Merged

addrmgr: mark IPv6 zero addresses as non-routable#2474
Roasbeef merged 1 commit intobtcsuite:masterfrom
EricGrill:fix/ipv6-zero-address-routable

Conversation

@EricGrill
Copy link
Copy Markdown
Contributor

Summary

  • Adds zero6Net definition for IPv6 0::/8 block (reserved per RFC 4291)
  • Adds IsZero function that checks both IPv4 and IPv6 zero address blocks
  • Updates IsRoutable to reject zero addresses, matching Bitcoin Core behavior

Test plan

  • 0::1 and similar addresses in 0::/8 are now rejected by IsRoutable
  • Existing IPv4 zero address handling continues to work via IsLocal

Closes #2431

🤖 Generated with Claude Code

@Roasbeef Roasbeef added this to the v0.25.1 milestone Mar 10, 2026
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:a: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 btcsuite#2431
@Roasbeef Roasbeef force-pushed the fix/ipv6-zero-address-routable branch from a267409 to 4a4e2d2 Compare March 24, 2026 00:47
@Roasbeef
Copy link
Copy Markdown
Member

Resolved some issues I found locally, pushed directly to the branch.

@Roasbeef Roasbeef merged commit c70d6b9 into btcsuite:master Mar 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants