Skip to content

One source IP can hold most of the node's handler slots #2502

Closed as not planned

Description

@thiras

Problem

One source IP can occupy most of the node's global handler slots (security.max_concurrent_handlers, default 256).

ConnectionLimiter (crates/node/src/dispatch.rs) has two layers: a global semaphore, and a per-source rate limit (token bucket, 100/s, burst 200). The per-source layer limits how fast a source connects, not how many connections it holds. An idle cdn/client/v1 connection keeps its slot until the 30 s application idle-close (APP_IDLE_TIMEOUT) reaps it. Probe and DHT connections keep theirs for up to the 5 s ACCEPT_BI_TIMEOUT. The bucket's burst of 200 plus 100/s lets one source fill all 256 slots in under a second, and it keeps them for as long as it keeps its connections open.

This is slot exhaustion, not memory. #2501 bounds the memory each slot can pin. Honest peers that arrive while the slots are full are closed with RATE_LIMITED (global-full).

Reported alongside the frame-size issue in #2501 (credit: Radeonares32).

Open question

Should ConnectionLimiter also cap concurrent connections per source key (/64 for IPv6)? Run it through the spec-discipline gates before adding it:

  • Binding: IPv4 addresses cost money; IPv6 /64 prefixes are cheap but grouped.
  • Redundancy: the token bucket plus the idle reaper may already make this expensive enough.
  • Relay-only connections: they carry no source key and bypass the per-source layer (dispatch_per_source_skipped_no_addr).

The outcome may be "no mechanism" if the existing layers bound it well enough. Record that reasoning here.

Activity

  1. self-assigned this
    on Oct 17, 2026
  2. thiras commented on Oct 17, 2026

    @thiras
    ContributorAuthor

    Outcome: no mechanism

    I checked a per-source concurrent-connection cap against the spec-discipline gates. It stays out. The reasoning is below, including one correction to the issue's own framing.

    The redundancy argument does not hold

    The token bucket limits how fast a source connects, not how many connections it holds. The idle reaper does not limit it either. The APP_IDLE_TIMEOUT clock starts over when a stream closes (handlers/client/mod.rs:116-127). So a source can send one cheap request on each connection every <30 s, for example a random hash that gets NotFound, and keep its slot indefinitely. The existing layers do not bound slot-holding by one determined source.

    Binding is what kills the cap (gate 2)

    • Relay-only connections dodge it for free. rate_limit::peer_ip returns None when the connection has only a relay path. acquire_inner then skips the per-source layer. An attacker who dials through the node's home relay with no direct address carries no source key, so a count cap never charges it. One iroh endpoint can open many connections to the same node, and NodeIds cost nothing.
    • IPv6 /64 grouping is weak. A /48 gives 65 536 keys.
    • The cap hits honest users. Many honest clients share one IPv4 egress behind CGNAT or a corporate NAT. A cap of K refuses the (K+1)th honest client there, while the attacker avoids it through the relay.

    At accept time there is no costly identity for a per-key cap to bind to. What remains is the general accept-flood exposure that every open QUIC server has.

    What already covers it

    MECHANISM: per-source concurrent-connection cap in ConnectionLimiter
    VERDICT:   keep out
    FAILS:     gate 2: relay-only connections carry no source key, so the cap is free to evade,
               and NAT'd honest clients are the ones it refuses
    INSTEAD:   nothing new; the client routes around RATE_LIMITED; the operator sizes
               max_concurrent_handlers against the per-slot memory bound
    

    A follow-up PR adds one line to ADR 013 recording that the node keeps no per-source connection count, and why.

  3. moved this from Backlog to Done in deCDNon Oct 17, 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

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions