Skip to content

fix(iroh-relay): implement connection accept rate limiting#4102

Open
emrul wants to merge 1 commit inton0-computer:mainfrom
emrul:fix/accept-rate-limit
Open

fix(iroh-relay): implement connection accept rate limiting#4102
emrul wants to merge 1 commit inton0-computer:mainfrom
emrul:fix/accept-rate-limit

Conversation

@emrul
Copy link
Copy Markdown

@emrul emrul commented Apr 12, 2026

Summary

The accept_conn_limit and accept_conn_burst fields on Limits were defined but not implemented (marked with a TODO). This left the relay server vulnerable to connection flooding: an attacker could open thousands of TCP connections that each hold resources for up to 30 seconds (the establish timeout), exhausting file descriptors and memory.

Implements a token bucket rate limiter in the accept loop. When configured, incoming connections that exceed the rate are immediately dropped before a handler task is spawned. The bucket refills at accept_conn_limit tokens per second and allows bursts up to accept_conn_burst.

Test plan

  • All iroh-relay tests pass
  • cargo check -p iroh-relay clean

The accept_conn_limit and accept_conn_burst fields on Limits were
defined but not implemented (marked with a TODO). This left the relay
server vulnerable to connection flooding: an attacker could open
thousands of TCP connections that each hold resources for up to 30
seconds (the establish timeout), exhausting file descriptors and memory.

Implement a token bucket rate limiter in the accept loop. When
configured, incoming connections that exceed the rate are immediately
dropped before a handler task is spawned. The bucket refills at
accept_conn_limit tokens per second and allows bursts up to
accept_conn_burst.
@n0bot n0bot bot added this to iroh Apr 12, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚑 Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant