Repository navigation
fix(ratelimit): limit pad messages per connection with a burst allowance - #8498
Conversation
commitRateLimiting was keyed on the client IP at 10 messages/second. Behind a TCP proxy or NAT every client shares that budget, and a single WebRTC join (one message per ICE candidate per peer) can exceed it alone. The over-limit client is disconnected, rejoins, and the rejoin burst kicks the other tabs in a loop. Key the limiter on the socket.io connection and add a burst budget (burstPoints/burstDuration, default 50 per 10s) on top of the steady points/duration rate. Sustained flooding still disconnects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcYAoDMav4BPPE9JrMtSvw
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoLimit pad messages per connection with burst allowance
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1.
|
…imiter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcYAoDMav4BPPE9JrMtSvw
|
Addressed the Qodo finding in b81a8c5: the burst keys are destructured out and the rest of |
With the burst allowance a connection can sustain up to ~15/s, so 99 ms spacing no longer trips the limiter. Document the effective ceiling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TcYAoDMav4BPPE9JrMtSvw
commitRateLimitinggave each IP 10 messages per second. On instances behind a TCP proxy or NAT, every browser has the same IP. The Home Assistant add-on is one example: it uses a socat front-man, soX-Forwarded-Fordoesn't help. A few tabs on one pad used up the shared budget and got{disconnect: 'rateLimited'}. They rejoined, and each rejoin burst kicked the other tabs, in a loop. The over-limit messages were dropped, chat included.A single client can also trip the limit alone. I measured a 3-tab pad with ep_webrtc in production mode. Core sends only
CLIENT_READYon join. For each peer pair, ep_webrtc sends a hangup, an invite, a description and one message per ICE candidate. When the second tab joined, 14 messages arrived within 150 ms, and the limiter fired.Change
burstPoints/burstDuration, default 50 extra messages per 10 s. It uses rate-limiter-flexible'sBurstyRateLimiter. The steady rate stays atpoints/duration(10/s).src/tests/ratelimit/testlimits.shnow floods at 20/s (50 ms) rather than 99 ms.commitRateLimiting, such asblockDuration, still apply to the steady limiter.Trade-off
There is no longer a per-IP cap. One IP can open several connections and get several budgets. Opening a connection was never limited, though, and per-IP limiting was already weak against IPv6 or multiple IPs. A per-IP cap also cannot tell users behind a shared IP apart, which is the bug being fixed. If you need per-IP connection caps, set them at the reverse proxy. This keeps the original anti-abuse goal: one connection can't flood the pad.
Plugin-side fix for the WebRTC burst: ether/ep_webrtc#316 (batches ICE candidates).
Tests
src/tests/backend/specs/commitRateLimiting.tsturns the limiter on with the shipped defaults. Three of its cases fail on develop:A fourth case checks that a flood is still disconnected.
I also checked by hand with 4 headless Chromium tabs running ep_webrtc against a production-mode server: zero rate-limit events. The settings template and the docs (
doc/configuration.md,doc/privacy.md) are updated.settings.json.dockeris left as is, and the new keys fall back to the defaults.🤖 Generated with Claude Code
https://claude.ai/code/session_01TcYAoDMav4BPPE9JrMtSvw