You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
node: DHT per-IP rate limiter keys on full IpAddr — IPv6 /64 rotation bypasses it (dispatch limiter already masks) #841
Surfaced by a full-repository review (2026-06-09).
Finding
The DHT per-IP rate-limit layer (crates/node/src/dht/rate_limit.rs:249-259) keys buckets on the full IpAddr. The dispatch limiter already solved this: source_key() in crates/node/src/dispatch.rs:60-71 masks IPv6 addresses to their /64 prefix.
Impact
An attacker with a customer-grade IPv6 /64 allocation has 2^64 distinct source addresses and defeats the per-IP DHT tier entirely by rotating — each request lands in a fresh bucket. The keyspace cap (max_tracked_per_ip + lazy prune, #645) bounds memory but not the rate-limit bypass. The per-peer (NodeId) and global layers still apply, but the per-IP tier is silently ineffective against IPv6 floods.
Fix
Apply the same /64 mask as dispatch.rssource_key() before check_key/contains in try_admit_one, and to the trusted_ips membership test. Consider extracting the mask helper so both limiters share it.
Security bug in crates/node/src/dht/rate_limit.rs where the per-IP DHT rate limiter keys on the full IpAddr. An attacker with a standard consumer /64 IPv6 allocation has 2^64 distinct addresses and can trivially rotate them to land each request in a fresh bucket, making the per-IP tier silently ineffective. The dispatch limiter already carries the correct fix (source_key() in dispatch.rs:60-71); this is purely a masking gap that was not carried across when the DHT limiter was implemented.
📊 Assessment
Dimension
Value
Reasoning
Type
Bug
Existing mitigation is bypassed by a trivially accessible IPv6 rotation technique
Labels
bug, security, medium (already applied)
Correct; the per-IP tier is defeated, but per-peer NodeId and global layers still apply
Coding agent
Suitable
Exact file + line references, fix pattern already in codebase (dispatch.rs:source_key()), no design decisions required
Extract the IPv6 /64 masking logic from dispatch.rs:source_key() into a shared helper (e.g., fn mask_to_prefix(addr: IpAddr) -> IpAddr in crates/node/src/ or common) so both limiters share one implementation
Apply the masked key in dht/rate_limit.rs:249-259 (try_admit_one) before every check_key / contains call
Apply the same mask to the trusted_ips membership test in dht/rate_limit.rs so a trusted /64 match works correctly regardless of source address within the prefix
Add a unit test: send N > per_ip_burst requests from distinct addresses within the same /64, assert all are admitted up to limit and then rate-limited (proving the mask collapses them into one bucket)
Scope note
The fix is intentionally narrow — masking only; no changes to bucket state, eviction, or config schema. The /64 prefix mask is already the established codebase convention and matches [RFC 6177]((www.rfceditor.org/redacted) typical end-site allocation size. If in future the node is deployed in an environment where attacker-controlled /48s are realistic (e.g., transit providers), the mask prefix could be made a config knob, but that is out of scope here.
Activity
github-actions commentedon Jun 9, 2026
🎯 Triage report
Security bug in
crates/node/src/dht/rate_limit.rswhere the per-IP DHT rate limiter keys on the fullIpAddr. An attacker with a standard consumer /64 IPv6 allocation has 2^64 distinct addresses and can trivially rotate them to land each request in a fresh bucket, making the per-IP tier silently ineffective. The dispatch limiter already carries the correct fix (source_key()indispatch.rs:60-71); this is purely a masking gap that was not carried across when the DHT limiter was implemented.📊 Assessment
bug,security,medium(already applied)dispatch.rs:source_key()), no design decisions required🔗 Similar issues
💡 Notes and suggestions
Fix checklist
dispatch.rs:source_key()into a shared helper (e.g.,fn mask_to_prefix(addr: IpAddr) -> IpAddrincrates/node/src/orcommon) so both limiters share one implementationdht/rate_limit.rs:249-259(try_admit_one) before everycheck_key/containscalltrusted_ipsmembership test indht/rate_limit.rsso a trusted /64 match works correctly regardless of source address within the prefixN > per_ip_burstrequests from distinct addresses within the same /64, assert all are admitted up to limit and then rate-limited (proving the mask collapses them into one bucket)Scope note
The fix is intentionally narrow — masking only; no changes to bucket state, eviction, or config schema. The /64 prefix mask is already the established codebase convention and matches [RFC 6177]((www.rfceditor.org/redacted) typical end-site allocation size. If in future the node is deployed in an environment where attacker-controlled /48s are realistic (e.g., transit providers), the mask prefix could be made a config knob, but that is out of scope here.
Add this agentic workflows to your repo
To install this agentic workflow, run
fix(node): mask IPv6 /64 in DHT per-IP rate limiter (#841)
Merge pull request #865 from decdn/fix/quick-win-medium-batch
fix: batch of six quick-win MEDIUM bug fixes (#865)