addrmgr: mark IPv6 zero addresses as non-routable#2474
Merged
Roasbeef merged 1 commit intobtcsuite:masterfrom Mar 24, 2026
Merged
addrmgr: mark IPv6 zero addresses as non-routable#2474Roasbeef merged 1 commit intobtcsuite:masterfrom
Roasbeef merged 1 commit intobtcsuite:masterfrom
Conversation
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
a267409 to
4a4e2d2
Compare
Member
|
Resolved some issues I found locally, pushed directly to the branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zero6Netdefinition for IPv6 0::/8 block (reserved per RFC 4291)IsZerofunction that checks both IPv4 and IPv6 zero address blocksIsRoutableto reject zero addresses, matching Bitcoin Core behaviorTest plan
0::1and similar addresses in 0::/8 are now rejected by IsRoutableCloses #2431
🤖 Generated with Claude Code