Repository navigation
Description
Context
ADR 022's threat model addresses prefetch-poisoning Sybil attacks but does not cover the broader permissionless surface on cdn/dht/v1. STORE is gated by active-staker membership (#431), but FIND_VALUE / FIND_NODE are unauthenticated beyond QUIC NodeId, and the DHT ALPN inherits no rate limit from ADR 005's probe-only token bucket. Reputation is local-EWMA-only today (gossip aggregation deferred per ADR 008 §14a), so the "false STORE → reputation penalty" mitigation has receiver-local blast radius, not the network-wide hit ADR 022 implies.
These gaps are not addressed by #320's wire-type and handler scope. This issue captures the hardening work needed alongside the base implementation.
Scope
Per-publisher STORE quota (handler)
ADR 022 caps stored records at 100k/node but specifies no eviction policy and no per-publisher quota. A single staker can flood a receiver's table; if eviction is global LRU, attacker churn evicts legitimate records on demand.
- Add
max_records_per_publisherconfig (recommended default: 200). - Eviction is per-publisher LRU, not global LRU. Publisher A flooding cannot evict publisher B's records.
- Reject STORE with
StoreAck { accepted: false }once a publisher's quota is full. - Requires ADR 022 text update in § Content Records and TTL.
Three-layer DHT rate limit (handler)
Mirror ADR 005's probe rate-limit machinery onto cdn/dht/v1:
| Layer | Recommended default | Source |
|---|---|---|
| Per-peer (NodeId) | 20 req/sec | QUIC connection NodeId |
| Per-IP | 100 req/sec | Source IP |
| Global | 1000 req/sec | All inbound DHT traffic |
Apply before any routing-table lookup or response serialization. Failed admission closes the stream with RATE_LIMITED per ADR 013. Cheapest-first ordering (global → per-IP → per-peer), matching the probe limiter. Requires ADR 022 to gain a new § DHT Rate Limiting section symmetric to ADR 005's.
Requester-side lookup invariants (handler)
Pure-defense changes that don't touch wire format but ADR 022 does not currently specify:
- XOR-distance invariant. Requester MUST reject any
closer_nodesentry from a responder whose XOR distance to the target is not strictly less than the responder's own. - Requester-side provider randomization. Move randomization off the responder. Requester MUST shuffle
FindValueResponse.providersbefore probing. Closes the modified-responder selection-bias gap that ADR 022 explicitly acknowledges as unenforceable. - Active-staker sanity filter. Requester filters returned providers against its cached active-staker set before probing, silently dropping non-stakers.
Negative probe cache (handler)
ADR 001 has a 15-second positive probe cache. Add the symmetric negative cache — (NodeId, hash) → has_blob: false with 5-minute TTL, max 1024 entries — so K-closest false-STORE publishers aren't re-probed on every cache miss inside the window. Closes the probe-budget-exhaustion attack where false STOREs at K-closest nodes drain a victim's outbound probe rate.
Mechanics live in ADR 001 (symmetric to its existing positive cache). ADR 022 § FIND_VALUE Flow and § Threat model cross-reference the negative cache as the load-bearing mitigation for K-closest false STORE.
Re-publish jitter + K+overflow (handler)
ADR 022 publishes at deterministic T + 45min to exactly K=20 closest peers. Predictable timing plus minimum-cardinality target set make a 15-minute targeted DoS sufficient to expire records, dropping the blob to the on-chain directory fallback.
- Jitter: randomize next re-publish to
T + uniform(30min, 50min)per record. - Overflow: publish STORE to K+3 closest peers. Receivers at the overflow positions accept or reject by their own routing-table policy.
- Requires ADR 022 text update in § STORE Flow.
Out of scope
- NodeId grinding mitigation. ADR 019's ed25519 signature proves NodeId control but not origin — operator picks the keypair freely. Constraining NodeId to
hash(operator_address, registrationNonce)would close grinding but touches ADR 003 (NodeId-to-Ethereum binding) and ADR 019 (registration signature). Needs its own ADR amendment. - Holdings/hash enumeration privacy. Inherent property of any global content-discovery layer; aligns with ADR 005's stance that probe responses are public information. Belongs in an ADR 022 Consequences update, not here.
- Active-staker cache event subscription. The event-subscription pattern (
NodeRegistered,NodeDeregistered,NodeAutoEjected) is already established in ADR 019. The DHT handler should consume the same cache. Folds into Implement content discovery via cdn/dht/v1 Kademlia DHT #320, not a separate concern.
Acceptance criteria
- A single staked publisher cannot exceed
max_records_per_publisherrecords at any receiver; eviction is per-publisher LRU. cdn/dht/v1inbound traffic is bounded by global / per-IP / per-peer token buckets; rejections emit a metric labeled by layer (matchesdecdn_probe_rate_limit_rejections_totalshape).- A responder returning
closer_nodescontaining entries not strictly closer than itself is rejected by the requester. FindValueResponse.providersis randomized requester-side before probing; tests assert order independence from responder.- A NodeId that returned
has_blob: falsefor hash H within the last 5 minutes is not re-probed for H during that window. - Re-publish time per record is jittered uniformly in
[T+30min, T+50min]; STORE targets are K+3 closest peers.
ADR updates required
- Fix A (per-publisher quota): ADR 022 § Content Records and TTL — add per-publisher quota and per-publisher LRU eviction policy. Without this, the 100k-record cap is exploitable; this fix is also the load-bearing bound on STORE-flooding cost. Mention in § Threat model.
- Fix B (DHT rate limit): ADR 022 — new § DHT Rate Limiting section symmetric to ADR 005's probe rate limiting. Highest-leverage hardening: caps the rate at which most other DHT attacks can be mounted. Mention in § Threat model.
- Fix F (negative probe cache): ADR 001 § Probe cache — add the symmetric negative variant alongside the existing positive cache. ADR 022 § FIND_VALUE Flow + § Threat model cross-reference it as the mitigation for K-closest false STORE probe-budget exhaustion.
- Fix G (re-publish jitter + K+overflow): ADR 022 § STORE Flow — randomize re-publish to
[T+30, T+50]minutes, publish to K+3 closest peers. Closes the deterministic re-publish suppression window. - Fixes C, D (lookup invariants): ADR 022 § FIND_VALUE Flow — XOR-distance invariant on
closer_nodesand requester-sideprovidersrandomization, both as MUSTs. C also strengthens against NodeId grinding's lookup-redirection variant.
A, B, F are the highest-compounding fixes (each touches multiple attacks; see issue thread for leverage matrix) and should be reflected explicitly in ADR 022's threat model so the rationale is preserved alongside the mechanics.
References
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon May 21, 2026
🎯 Triage report
This issue identifies five concrete DoS hardening gaps in the
cdn/dht/v1handler that are not covered by the base DHT implementation in #320: per-publisher STORE quota with per-publisher LRU eviction, a three-layer rate limit mirroring ADR 005, requester-side lookup invariants (XOR-distance, provider randomization, active-staker filter), a negative probe cache closing probe-budget exhaustion, and re-publish jitter + K+3 overflow. Each scope item includes a specific ADR 022 section that must be updated. The issue is labeledpoc-blocking, meaning all six acceptance criteria must be met before the PoC network launch.📊 Assessment
security,adr-review,high(added);technical,poc-blocking(existing)high🔗 Similar issues
cdn/dht/v1Kademlia DHT implementation; this issue is the hardening companion and explicitly depends on Implement content discovery via cdn/dht/v1 Kademlia DHT #320 landing first💡 Notes and suggestions
Suggested implementation order (minimises re-work):
cdn/probe/v1(ADR 005 /ConnectionLimiter). The DHT limiter is a parallel instantiation — copy the probe limiter pattern, wire it intocdn/dht/v1before any routing-table access. Metric label shape should matchdecdn_probe_rate_limit_rejections_total.max_records_per_publisher: usizeto the DHT handler config (default 200). TrackHashMap<NodeId, VecDeque<RecordKey>>per publisher; on insertion, if len ≥ limit, evict the oldest entry for that publisher (per-publisher LRU), not the globally oldest.HashMap<(NodeId, Hash), Instant>with a 5-min TTL and bounded at 1024 entries (evict by insertion order). Check before any outbound probe in the FIND_VALUE path.XOR-distance check: on receivingcloser_nodes, computexor(node.id, target)andxor(responder.id, target); drop entries wherexor(entry.id, target) >= xor(responder.id, target).Provider shuffle: callrand::seq::SliceRandom::shuffleonprovidersimmediately after decode, before any probe.Active-staker filter: use the same cached set already consumed for STORE gating (docs(adr): pin cdn/dht/v1 stake check, provider ordering, and stream cap #431).T + 45minwithT + rand::thread_rng().gen_range(30min..=50min). Change target peer count fromKtoK + 3.Testing notes:
StoreAck { accepted: false }, assert a different publisher's records are unaffected.permissive_limiterin tests not exercising rate-limit behaviour (per repo convention); add a dedicated test that saturates the per-peer bucket.has_blob: falseresponse, a second probe to the same(NodeId, hash)within 5 min is suppressed.closer_nodesresponse containing an entry farther than the responder; assert it is silently dropped.[30min, 50min].