Review follow-ups: IPv6 peers, constant-time admin key, magnet hash validation#6
Merged
Conversation
…alidation Three lower-priority findings from the 2026-06-13 review: - internal/client: unpackPeers only handled the 6-byte IPv4 compact form and the tracker response never decoded peers6, so IPv6 swarms were silently dropped. Decode the BEP 7 peers6 key and parse both forms (4- and 16-byte addresses) via a length-parameterized unpacker. Adds an IPv6 test. - internal/tracker: registry POST/DELETE admin-key check used a plain string compare (timing side-channel); switch to subtle.ConstantTimeCompare for parity with the HMAC announce path. - cmd/wl: 'wl get' discarded the hex.DecodeString error for the v1 info hash, handing a truncated hash to the downloader. Reject a malformed value at the boundary (empty v1 hash for v2-only magnets is still fine). The wire.go payload-cap 'comment mismatch' from the review was a false positive: 2<<20 is exactly 2 MiB, matching the comment.
iksnerd
added a commit
that referenced
this pull request
Jun 21, 2026
Review follow-ups: IPv6 peers, constant-time admin key, magnet hash validation
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.
The lower-priority findings from the 2026-06-13 review (follow-up to #5).
Changes
IPv6 peer support —
internal/client/tracker.gounpackPeersonly handled the 6-byte IPv4 compact form and the tracker response struct never decoded thepeers6key, so IPv6 swarms were silently dropped. Now decodes BEP 7peers6and parses both the 6-byte (IPv4) and 18-byte (IPv6) compact forms through a length-parameterized unpacker. IPv6 test added.Constant-time admin-key compare —
internal/tracker/registry.goThe registry POST/DELETE
X-Weightless-Keycheck used a plain!=string compare (timing side-channel). Switched tosubtle.ConstantTimeCompare, matching the HMAC announce path.Magnet v1-hash validation —
cmd/wl/main.gowl getdiscarded thehex.DecodeStringerror for the v1 info hash, handing a truncated/garbage hash to the downloader. Now rejects a malformed value at the boundary; an empty v1 hash (v2-only magnet) is still accepted.Dropped (false positive)
The review's
wire.go"payload cap comment mismatch" —2<<20is exactly 2 MiB, which matches the "2MB max payload" comment. No change.Verification
go build ./...,go vet ./...,gofmtcleango test ./...— all pass, including the newTestUnpackPeersIPv6🤖 Generated with Claude Code