Skip to content

Remove the trusted-IP rate-limit exemption (ADR 005/022) #1440

Closed

Description

@alpergundogdu

Decision (2026-07 ADR simplification audit). Filed under the Protocol simplifications milestone — sibling to #1396, #1394, #1419. Verdict: DROP. A special-case allow-list bypass whose benefit the default limiter headroom already covers; raise the numeric limit instead.

Drop the trusted-IP rate-limit exemption (probe + DHT)

Status: proposal for discussion, not a decision.

Summary

Both cdn/probe/v1 (ADR 005 §Probe rate limiting) and cdn/dht/v1 (ADR 022
§DHT Rate Limiting) run the same three-layer token-bucket limiter: global →
per-IP → per-peer. On top of that shared limiter, each ALPN carries a
trusted_ips allow-list that lets an operator exempt configured source IPs
from the middle (per-IP) layer only. This proposes removing that allow-list
from both ADRs and the code. Keep all three limiter layers exactly as they are;
an operator who needs more per-IP headroom raises per_ip_rate_per_sec /
per_ip_burst instead of maintaining a list of IPs that skip the layer.

This is a special-case bypass whose stated benefit the default headroom already
covers. It is scale-independent — dropping it does not lower any ceiling.

Motivation

  1. The stated use cases already sit under the default limits. The ADRs
    justify the exemption with "peer operators with predictable cache-miss / DHT
    traffic" and "in-cluster monitoring." Node-to-node traffic uses stable IPs
    and, per ADR 022 §Headroom against rate limits, realistic steady-state load
    runs ~two orders of magnitude below the per-peer cap — nowhere near the
    per-IP cap either (DHT per-IP default 100/s burst 200; probe per-IP default
    50/s burst 200). Nothing in the modeled traffic needs the middle layer
    lifted.

  2. On the probe path the exemption barely does anything. The probe handler
    runs the ADR 005 per-IP layer and the always-on ConnectionLimiter
    per-source IP bucket (security.per_source_*, default 100/s), which
    trusted_ips does not bypass (documented at
    crates/node/src/handlers/probe_rate_limit.rs:24). So exempting a probe
    trusted IP only raises its effective per-IP ceiling from 50/s to the 100/s
    dispatch cap — never to unbounded. A knob that moves one number to another
    number the operator could have just set is not carrying its weight.

  3. In-cluster monitoring is local. A monitoring host scraping a node's
    admin/metrics surface does not go through cdn/probe/v1 or cdn/dht/v1 at
    the rates that would trip a token bucket. This is not a real pressure on the
    per-IP layer.

  4. It is a standing allow-list to maintain and a misconfiguration/abuse
    vector.
    Every exempted IP is an operator-curated hole in the middle
    defense layer. It has to be parsed, validated, IPv6-/64-masked to match the
    inbound key (crates/node/src/rate_limit.rs:244), kept current as peer IPs
    change, and reasoned about during incidents. A stale or shared-NAT entry
    silently widens the bypass. The fix for "this peer needs headroom" —
    raising the numeric per-IP limit — has none of that surface.

  5. It is redundant with the knob it shadows. The per-IP layer is already
    fully governable per node. "Exempt these IPs from the per-IP layer" and
    "raise the per-IP layer" solve the same problem; the numeric knob is the
    general one and keeps the layer's invariant (every IP is bounded) intact.

What removal touches

Blast radius is contained — the exemption is one field threaded through the
shared limiter, plus doc paragraphs and tests. No wire-format or contract
change.

  • ADRs.

    • ADR 005 (adr/005-protocol.md): delete the Trusted-IP exemption
      paragraph (line 104) under §Probe rate limiting.
    • ADR 022 (adr/022-content-discovery.md): delete the Trusted-IP
      exemption
      paragraph (line 164) under §DHT Rate Limiting; drop the
      dht.rate_limit.trusted_ips mention in the §DHT config-key prose.
  • Rust — shared limiter engine (crates/node/src/rate_limit.rs).

    • Remove the trusted_ips field from RateLimitConfig (line 89) and from
      ThreeLayerRateLimiter (line 225) plus its Default init (line 106) and
      the mask-into-set in new() (line 244).
    • Delete the per-IP bypass branch in try_admit_one
      (if !self.trusted_ips.contains(&ip), lines 302–316) — the per-IP layer
      then always charges when an IP key is present. Update the module-level
      "Trusted-IP exemption" doc block (lines 35–41).
    • Drop the field from both From<&Resolved{Dht,Probe}> impls (lines 128,
      144).
  • Rust — per-ALPN wrappers. crates/node/src/dht/rate_limit.rs and
    crates/node/src/handlers/probe_rate_limit.rs: trim the trusted-IP mentions
    in the header docs (dht line 1-block; probe lines 8–9, 24–27).

  • Rust — config resolver (crates/common/src/config/).

    • types.rs: remove trusted_ips: Option<Vec<String>> from
      DhtRateLimitConfig (line 942) and ProbeRateLimitConfig (line 996) plus
      their doc comments and the two section-doc references to the config key.
    • mod.rs: delete the parse_trusted_ips helper (lines 2885–2911) and its
      two call sites (lines 2725–2727, 2838–2840); drop trusted_ips from the
      two resolved-struct constructions (lines 2760, 2872). Remove the
      malformed-IP test resolve_probe_malformed_trusted_ip_reports_probe_key
      (line 10331) and the empty-set assertion at line 10293.
    • resolved.rs: remove trusted_ips from ResolvedDht and ResolvedProbe
      (lines 503, 542) and their Default inits (lines 520, 559); update the
      field doc at line 487.
  • Config keys. Retire probe.rate_limit.trusted_ips and
    dht.rate_limit.trusted_ips. Delete the two commented example lines in
    crates/cli/src/commands/config.rs (lines 531, 542) and the
    warn_ignored("dht.* (rate-limit, trusted_ips)") text at
    crates/node/src/runtime/reload.rs:1153. (Because the config structs use
    #[serde(deny_unknown_fields)], a leftover trusted_ips in a node's TOML
    becomes a hard config error — call out in release notes.)

  • Tests. Remove the ~7 dedicated exemption tests
    (trusted_ip_bypasses_per_ip_layer_only,
    trusted_ip_does_not_bypass_per_peer_or_global,
    trusted_ip_still_subject_to_per_peer_layer,
    trusted_ipv6_matches_masked_inbound_key in dht/rate_limit.rs;
    trusted_ip_exempts_per_ip_only in probe_rate_limit.rs; the two resolver
    tests above). Delete the trusted_ips: HashSet::new() line from the ~15
    config-construction sites across crates/node/tests/* (dht_bootstrap,
    dht_lookup, dht_loopback, dht_integration, self_hosted_discovery,
    probe_0rtt, probe_loopback) and the in-module test fixtures — these are
    mechanical struct-literal edits once the field is gone.

What we keep

The three-layer token-bucket limiter is unchanged and stays fully governable:

  • Global layer (default 1000/s burst 2000, both ALPNs).
  • Per-IP layer (DHT 100/s burst 200; probe 50/s burst 200) — now with no
    bypass; every source IP is bounded.
  • Per-peer (NodeId) layer (DHT 20/s burst 40; probe 5/s burst 5).
  • Cheapest-first ordering, batch-token accounting for BatchStoreRequest, the
    keyspace bound (DHT rate limiter: bound per-IP / per-peer keyed limiter keyspace #645) and its GC sweeps, and all per-layer rejection metrics.
  • The always-on ConnectionLimiter per-source bucket that already sits in
    front of the probe path.

An operator who genuinely needs more per-IP headroom raises
per_ip_rate_per_sec / per_ip_burst
for that node. That keeps the layer's
invariant — no IP is ever unbounded — while giving the exact same relief the
allow-list was for.

Counter-argument

[your call] The one scenario the numeric knob covers less precisely: an
operator who wants one specific peer or monitoring host to have a much
higher per-IP ceiling than everyone else. With the allow-list you lift the cap
for just that IP; with the numeric knob you raise the per-IP cap for all
sources on that node. If a deployment has a heavily-trafficked peering partner
(say a co-located sibling node doing bursty cross-peer DHT STOREs at cold
start) and the operator wants to keep a tight per-IP cap for strangers while
uncapping the partner, per-IP-raise is a blunter instrument. Whether that
precision is worth a standing allow-list — versus setting a per-IP cap high
enough to cover the partner and leaning on the per-peer + global layers (which
still bound the partner and still bound the aggregate) — is the judgment call
here. Note the partner is still bounded by per-peer and global even when
per-IP-exempt today, so the exemption never removed all bounds; it only removed
the middle one.

Open questions

  1. Is there any current or near-term deployment that actually sets a non-empty
    trusted_ips on either ALPN? If the field is unset everywhere (the default
    is empty), removal is pure surface reduction with zero behavioral change for
    live nodes.
  2. On the probe path the exemption only lifts 50/s to the 100/s dispatch cap
    (motivation 2) — does anyone view even that narrow bump as load-bearing, or
    does it confirm the probe-side exemption is dead weight regardless of the
    DHT decision? (We could drop probe-side only and keep DHT, but the symmetry
    argument cuts the other way.)
  3. #[serde(deny_unknown_fields)] turns a stale trusted_ips key into a
    startup error. Acceptable as a loud migration signal, or do we want a
    one-release grace where the key is ignored with a warning (via the existing
    warn_ignored path) before hard-removing it?

Activity

  1. altanoruc commented on Jul 24, 2026

    @altanoruc
    Contributor

    Automated implementation triage note for a later run: the decision header resolves removal, but the config migration remains open. Because deny_unknown_fields makes a stale trusted_ips key a startup error, please choose immediate hard removal versus a one-release warn-and-ignore grace period. Also confirm whether any current deployment uses a non-empty allow-list. Once the migration behavior is pinned, the code scope is otherwise prescriptive.

  2. self-assigned this
    on Jul 24, 2026
  3. added a commit that references this issue on Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions