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
PR #643 added the three-layer cdn/dht/v1 rate limiter (per-peer NodeId, per-IP, global) per ADR 022 §DHT Rate Limiting. The per-IP and per-peer layers use governor::DefaultKeyedRateLimiter with no keyspace cap or pruning — an attacker churning many source IPs and/or many authenticated NodeIds can grow the keyed map without bound, same DoS shape that #440 fixed for the connection-level dispatch limiter.
Scope
Mirror the dispatch::ConnectionLimiter pattern at `crates/node/src/dispatch.rs`:
Add max_tracked_* knobs to DhtRateLimitConfig (per-IP and per-peer).
Resolve them via [dht] config (defaults consistent with the existing security.max_tracked_sources = 4096).
Lazy prune inside check() when the keyspace exceeds cap + cap/10, single-flighted via pruning_in_progress: AtomicBool + PruneGuard (already-modeled pattern).
Periodic GC task driven by the runtime, same governor::retain_recent call as ConnectionLimiter::gc_per_source.
Metric counters for prune sweeps + tracked-set sizes.
Unit tests cover: bounded growth under flood, recovery after refill, layer-disable short-circuits.
Acceptance
Per-IP and per-peer keyspaces stay bounded under sustained-distinct-key load.
No regression in admission throughput on the happy path (the prune fires only over-cap).
decdn_dht_rate_limit_tracked_{per_ip,per_peer} gauges visible in the scrape.
Raised by PR #643 review feedback (Copilot, crates/node/src/dht/rate_limit.rs:120).
Related: #440 (the dispatch-limiter equivalent).
An unbounded keyspace DoS vulnerability in the DHT rate limiter introduced by PR #643. An attacker churning distinct source IPs or NodeIds can grow governor::DefaultKeyedRateLimiter maps without limit, mirroring the exact shape fixed for the dispatch limiter in #440. The issue is well-specified with clear implementation scope (mirroring ConnectionLimiter) and concrete acceptance criteria.
📊 Assessment
Dimension
Value
Reasoning
Type
Task
Implementation follow-up from a PR review; clear scope, no design ambiguity
Labels
security, technical, high
Memory-exhaustion DoS via attacker-controlled input is a security concern; high priority given the gap was introduced in a recently merged PR
Coding agent
Suitable
Requirements are fully specified: config knobs, lazy prune with cap + cap/10 threshold, AtomicBool single-flight guard, periodic GC task, metric gauges, and explicit unit test cases. Pattern already exists in crates/node/src/dispatch.rs to copy from.
Add max_tracked_ips: usize and max_tracked_peers: usize to DhtRateLimitConfig in crates/node/src/dht/rate_limit.rs; default both to 4096 to match security.max_tracked_sources
Wire defaults through [dht] config block in common config schema
In DhtRateLimiter::check(): after inserting a new key, compare keyspace len against cap + cap/10; if over, set pruning_in_progress and spawn a prune task (mirror ConnectionLimiter::maybe_prune)
Add PruneGuard RAII type (or reuse if extractable) to clear pruning_in_progress on drop
Add periodic GC task in node runtime wiring, calling governor::retain_recent on both keyed limiters (mirror ConnectionLimiter::gc_per_source)
Expose decdn_dht_rate_limit_tracked_per_ip and decdn_dht_rate_limit_tracked_per_peer gauge metrics; register in the existing metrics registry
Unit tests:
Flood with N > cap distinct keys → assert keyspace len ≤ cap + cap/10 + tolerance
Verify admission throughput unchanged when under-cap (no spurious prune)
Verify layer-disable short-circuit still works (no prune attempted when layer disabled)
Activity
github-actions commentedon May 21, 2026
🎯 Triage report
An unbounded keyspace DoS vulnerability in the DHT rate limiter introduced by PR #643. An attacker churning distinct source IPs or NodeIds can grow
governor::DefaultKeyedRateLimitermaps without limit, mirroring the exact shape fixed for the dispatch limiter in #440. The issue is well-specified with clear implementation scope (mirroringConnectionLimiter) and concrete acceptance criteria.📊 Assessment
security,technical,highcap + cap/10threshold,AtomicBoolsingle-flight guard, periodic GC task, metric gauges, and explicit unit test cases. Pattern already exists incrates/node/src/dispatch.rsto copy from.🔗 Similar issues
ConnectionLimiter; the fix there is the explicit template for this issue.💡 Notes and suggestions
Implementation checklist (derived from scope):
max_tracked_ips: usizeandmax_tracked_peers: usizetoDhtRateLimitConfigincrates/node/src/dht/rate_limit.rs; default both to4096to matchsecurity.max_tracked_sources[dht]config block incommonconfig schemaDhtRateLimiter::check(): after inserting a new key, compare keyspace len againstcap + cap/10; if over, setpruning_in_progressand spawn a prune task (mirrorConnectionLimiter::maybe_prune)PruneGuardRAII type (or reuse if extractable) to clearpruning_in_progresson dropgovernor::retain_recenton both keyed limiters (mirrorConnectionLimiter::gc_per_source)decdn_dht_rate_limit_tracked_per_ipanddecdn_dht_rate_limit_tracked_per_peergauge metrics; register in the existing metrics registryKey file:
crates/node/src/dht/rate_limit.rs:120(flagged in PR #643 review)Reference pattern:
crates/node/src/dispatch.rs—ConnectionLimiterstructAnti-panic note: Remember the workspace-wide
unwrap_used/expect_used/indexing_slicingdeny — use.get()andResult/Optioncombinators throughout.fix(node): apply consolidated review fixes from PR #643 multi-agent r…
feat(node): cdn/dht/v1 handler + routing table + 3-layer rate limiter…
feat(node,cache): record store + Store/FindValue + cache hook (PR 3/4…
fix(node): add missing keyspace-cap fields to dht_lookup test config
fix(node): mask IPv6 /64 in DHT per-IP rate limiter (#841)