Repository navigation
fix(ratelimit): share request allowance across account credentials - #2719
Conversation
Co-authored-by: Codex <[email protected]>
Co-authored-by: Codex <[email protected]>
Co-authored-by: Codex <[email protected]>
Co-authored-by: Codex <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
The The rate-limit label and description changed in Web admin task #1218 C1, and the Jellyfin authenticated browse/play path in #1246 C1 now spends the account budget. Both tasks are currently Suggested line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
The rate-limit row was renamed to "Per address and account", but the admin settings search still listed it as "Per client address", a label the page no longer shows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
Review of ec1bacb6a. The account budget does what the PR says: in a live run, rotating X-Forwarded-For across two sessions, an API key and device headers went from 24/24 admitted on main to 5/24, both with one process and with two processes sharing Redis, and a second account kept its own allowance. Identity selection holds up: I found no path that charges the account twice, charges it before authentication, or takes the account from anything but a validated credential. Two findings below; one needs a maintainer decision.
Other notes, not diff-line findings:
- Issue scope. #2364 already caps forwarded-header rotation on sign-in with the per-connection
authpeer:budget, which is the scenario #2329 describes. This PR covers authenticated routes, a step beyond that. Closing #2329 on merge is still right because it is resolved, but the PR body should say #2364 fixed the sign-in case. I'm updating the body. - Validation tasks. The passed #1196 cases test authorization outcomes far below any throttle, so they don't change. #1217 C1, #1218 C1 and #1246 C1 are affected but not yet run, so the line should be
unblocks #1217 C1; unblocks #1218 C1; unblocks #1246 C1. I'm updating the body. - Redis outage (low). With Redis unreachable, each limiter check waits about 2 s before failing open. The extra account check raises an authenticated request from about 6.3 s on
mainto about 8.4 s here. The slow fail-open predates this PR and is filed as #2749. - Apple notification display route (low, pre-existing). Its pre-auth limiter spends the global budget for requests that then fail authentication, so the new docs sentence about rejected requests not consuming global capacity does not hold on that route. Filed as #2750; the fix should follow this PR.
- Success headers (low, disclosed). A successful API-key response still reports the key tier in
X-RateLimit-*, so an integration pacing itself on those headers can hit an account 429 it did not see coming. The Risks section already names this.
Reviewed with a multi-agent pass at high effort and a read-only cross-provider round (Codex, gpt-6.1-sol). The live checks ran on base and head binaries against a throwaway database. AI-generated review (Claude Code in T3 Code, claude-opus-5-5).
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summaryFit: 7/10 · Readiness: 7/10 — conditional (assuming CI is green) Reviewed head: Addressed
Open
Pre-existing defects found during review, both filed separately and outside this PR's scope:
Verification
Validated features. #1196 C1/C2 and #1197 C1/C2 are passed and unaffected: they check authorization results at request rates far below any budget. #1217 C1, #1218 C1 and #1246 C1 reach the changed behavior but have no recorded result, so the line is User manual. Silo-Server/siloserver.org#257 covers the settings label, defaults and the API key tier note. Nothing more is needed from this review. Apple and Android. No API shape changes. If the account budget stays shared with integrations (option 3 in the inline finding), Android should retry 429 media loads using Fit 7. Bounding what one account can take, independent of proxy headers, suits a server that runs behind proxies and across nodes. It works on both the memory and Redis backends. What holds the score down: it adds a new throttle to every authenticated request, including media, and couples it to the per-address settings, so tuning one silently tunes the other. Readiness 7. The code is correct and tested, and I found no wrong-account, double-charge or pre-auth path. The open condition is the budget-size decision above, together with the Android 429 behavior it exposes. Reviewed with a multi-agent pass at high effort and a read-only cross-provider round (Codex, |
|
The settings search label change lacks evidence for the current head. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
7 cases examined; most severe classification: major change.
The three major-change cases are currently Validation tasks: changes #1217 C1; changes #1218 C1; changes #1246 C1 Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
One login often spans several networks, and each address is already held to one per-address budget. Sizing the shared account allowance at the same budget let one busy address or integration spend the whole account and refuse playback on the account's other networks. Four address budgets (480/s, 24000/min, burst 480 at the defaults) keep any single address to a quarter of its account while still bounding a client that rotates forwarding headers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The linked evidence predates the latest visible changes:
Suggested fix: No diff — update the evidence page with results and captures from the current head. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
The three cases listed in
Suggested fix: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Review summary for
|
* docs: explain the shared account request allowance * docs: size the shared account allowance at four address budgets Silo-Server/silo-server#2719 sized the account allowance at four times the per-address settings. Correct the defaults, explain the four-times size, and give the API key rate limit its own section. --------- Co-authored-by: Quick104 <[email protected]> Co-authored-by: zZebrahz <[email protected]>
Problem
An authenticated client whose transport peer is trusted for forwarding headers can rotate its reported address to get a fresh source allowance. This adds one stable account allowance, shared across household profiles, sessions, devices and API keys, so those changes cannot reset the account quota.
#2364 already caps this rotation on sign-in endpoints with a per-connection budget, which resolves the sign-in case #2329 describes. This change covers authenticated routes, where rotation still reset the per-address allowance.
Closes #2329
Related issue: N/A
Validation tasks: unblocks #1217 C1; unblocks #1218 C1; unblocks #1246 C1
Approach
The account allowance is four times the per-IP budget: 480 requests/second, 24000/minute and burst 480 at the defaults (120, 6000, 120). One login often spans several networks, and each address is already held to one per-IP budget, so a single busy address or integration can spend at most a quarter of its account. The per-IP settings still control both; there is no new setting. Existing source, API-key and global budgets remain. Narrower denials run before the global check. Separate accounts behind one proxy retain separate account allowances while still sharing applicable source and global controls.
Native v1/v2 and Jellyfin credentials charge the login account. The Jellyfin adapter carries only a rate-limit identity, without adding native authorization claims or key-tier enforcement. Credentialless address-only stream grants retain source/global protection without charging an inferred owner. Pre-authentication display-token and public lookup protection remains in place. Admin copy, admin settings search and developer docs explain the shared allowance.
Validation
bd7300e9d), the device was refused from 60 s (122/180 admitted). At four budgets (fb356e878) the device kept 180/180; the integration was refused from 75 s by its own address budget only. One session rotatingX-Forwarded-Foron 300 back-to-back requests: 25 admitted before, 101 after, so rotation stays bounded. Focusedinternal/ratelimitandinternal/jellycompattests pass, including the Redis account test against a real Redis with two middleware instances.Retry-After, so no response-schema change is needed. Android media loads treat 429 as final (MediaLoadRetryPolicy), so a refused segment or range request ends playback instead of waiting; Apple media handling was not checked. No physical client or real playback test was performed.mainand head binaries against a throwaway database (memory backend, and two processes sharing Redis): rotating headers across two sessions, an API key and device headers went from 24/24 to 5/24 admitted, and a second account kept its allowance. At the defaults, four devices on separate addresses at about 5 requests/second each for 20 seconds were all admitted. With limits scaled to 20/second and 600/minute and an API key running near its tier rate, the server refused about a third of another address's requests on the same account after about 60 seconds;mainrefused none. Whole-board validation access was unavailable; the listed cases were inspected directly.Evidence
The current page compares
bd7300e9d(account at one per-IP budget) with headfb356e878(four budgets): the wire results above and desktop and phone captures of the admin rate-limit row, whose description now says the account budget is four times larger. Runtime revision metadata was unavailable; the sandbox source files matched the branch by hash. Earlier versions of the page, comparing base365e3d436with implementationda300507d, remain in its version list.Evidence: https://evidence.siloserver.org/r/silo-server/issue-2329/
Risks
An account can still be throttled when four addresses' worth of traffic arrives at once, and a client rotating forwarding headers gets up to four per-IP budgets. Raising a key tier does not raise the account allowance; raising the per-IP settings does. Successful native API-key headers still describe the key budget and can overstate the account's remaining capacity. Memory counters remain per process; Redis retains its existing fail-open behavior. Proxy trust defaults are unchanged. No migration is required.
User manual: Silo-Server/siloserver.org#257. The tested docs branch is prepared; its draft PR is blocked because the current evidence publisher rejects the repository name
siloserver.org.Checklist
AI Disclosure
gpt-6.1-sol(xhigh),claude-opus-5-5(high).ec1bacb6a. The post-PR Claude review ofec1bacb6acompleted with no verified defects and nothing posted. A later Claude Code (claude-opus-5-5) review ofec1bacb6a, with a read-only Codex (gpt-6.1-sol) round, posted one fixed finding (admin search label,bd7300e9d) and one open product decision on the account budget's size. The maintainer chose four per-IP budgets after a Claude Code (claude-opus-5-5) survey of server routes and Apple, Android and web request patterns; that change isfb356e878.Note
Add shared per-account rate-limit budget for authenticated requests
ratelimit.WithAccountso non-native listeners (Jellyfin compat sessions and admin API keys) can attach an account identity without granting native authorization claims (account.go).PlaySessionIdis present; address-only static-stream grants do not (auth.go).Macroscope summarized fb356e8.