Repository navigation
fix(jellycompat): apply rate limits to the Jellyfin listener - #2305
Conversation
The Jellyfin listener had no request rate limiting, so POST /Users/AuthenticateByName allowed unlimited password guessing. The listener now shares the native rate-limit middleware instance: sign-in spends the per-IP login budget (the same counter as native login), authenticated and media routes run the generic limiter after auth, and anonymous artwork, avatars, web assets and public server reads stay unlimited, matching the native surfaces. 429s use the listener's error envelope with Retry-After. With rate limiting disabled the listener behaves as before.
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:
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No evidence to submit: this change has no user-visible screen or UI change. The measured before and after results are in the Validation section. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f80e3e2b1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| r.With(compatAuthEndpointRateLimit(deps.RateLimit, compatLoginRateLimitBucket)). | ||
| Post("/Users/AuthenticateByName", authHandler.HandleAuthenticateByName) |
There was a problem hiding this comment.
Throttle credential attempts by the immutable peer
When the caller's transport address falls inside clientip.trusted_proxies (the defaults include all RFC 1918 and loopback ranges), the caller can rotate X-Forwarded-For to bypass this wrapper: clientip.Middleware stores the header-derived address in clientip.FromContext, and AuthEndpointHandlerWithRejectBody uses it for both the ip: and authip: keys, so every forged address receives a fresh password-guess budget. internal/clientip/middleware.go explicitly reserves PeerFromContext for rate limiters and abuse controls (and the ABS login limiter already follows that contract), so this credential route needs an unforgeable transport-peer budget in addition to any resolved-client budget.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed the trigger for a direct peer in a trusted range, but the same resolver and clientip.FromContext keying exist on the base branch and on native login. Before this PR, Jellyfin password sign-in had no request limiter. I filed #2329 for the inherited trust/abuse boundary.
Adding the existing login budget to the raw proxy peer would make every client behind that proxy share one 20-per-minute, burst-10 allowance, including across the native and Jellyfin listeners. That needs a separate correction which preserves legitimate proxy traffic. This PR keeps the native per-client behavior; no code change was made for this comment.
AI: Codex in T3 Code, gpt-6.1-sol; independently checked by claude-opus-5-5.
Quick104
left a comment
There was a problem hiding this comment.
Reviewed 7f80e3e2b137f7b08f174fe49233fa3d3baadd13: no confirmed introduced defect after the multi-agent source review, focused tests, and one cross-provider adversarial round. The proxy-header concern is inherited from the native limiter and tracked in #2329; generic global-budget ordering is tracked in #2330. The summary comment records the remaining CI and live-client validation conditions.
AI: Codex in T3 Code, gpt-6.1-sol; read-only adversarial review by claude-opus-5-5. No code changes.
|
Reviewed head: Fit: 9/10 · Readiness: 7/10 — conditional. Sharing the existing limiter closes the unlimited Jellyfin sign-in path without duplicating counters or changing native response contracts. No introduced defect was confirmed. Readiness remains conditional on green required CI and representative Jellyfin-client validation. Review results
Verification and remaining checks The rate-limit package and Jellyfin router rate-limit tests pass. Focused native/Jellyfin middleware tests also pass with The PR's required database-pin check fails in Real Jellyfin clients were not exercised by this review. #1217 C1 and #1246 C1 are both recorded as Not run. Validate shared limits and counter contention, then sign-in, browsing/library sync, and playback with representative Jellyfin clients; normal-load safety was assessed from source, not measured in those clients. Validated features The validation helper could not refresh the board because GitHub GraphQL is rate-limited. REST fallback read 214 Validation-labeled issues across Server, Apple, and Android and found 98 passed surface/case records. Board membership and status remain unverified. No regression was found in those records.
Shared-path evidence: Validation tasks: none among the retrieved passed cases. Planned, not yet run: #1217 C1 and #1246 C1. Manual and clients Silo-Server/siloserver.org#174 already covers the shared-limit explanation in AI: Codex in T3 Code, |
Problem
Related issue: #1216
Validation tasks: none (recorded passed cases unchanged).
Planned validation: #1217 C1 and #1246 C1, both Not run.
The Jellyfin-compatible listener ignores the server's rate limits, so
POST /Users/AuthenticateByNameaccepts unlimited password guesses. Silo has no per-account lockout, and the native sign-in throttle only covers the native API. Anyone who can reach the Jellyfin port, which is often exposed for apps such as Infuse, can guess passwords as fast as the server answers. This change applies the same rate limits, with the same counters, to the Jellyfin listener.Approach
AuthenticateByNamespends theloginbudget: per IP, per IP for sign-in, then global. A sign-in attempt on either listener counts against the same budget.{"Error":"TooManyRequests",...}) withRetry-After. Native 429 responses do not change.docs/jellycompat-api.mddescribes the limits.Validation
Two API replicas with the Redis rate-limit backend and default budgets (sign-in 20 per minute, burst 10), 14 wrong-password sign-ins on one replica's Jellyfin listener:
Retry-After. The correct password was then refused for that IP on the other replica's Jellyfin listener and on native sign-in on both replicas.Unit tests cover the sign-in budget per IP, the shared counter with native sign-in, routes that stay unlimited, unauthenticated requests still answering 401, and the limiter being off.
go build,go vet,make lint-changed,make verify-route-inventory,make lint-router-recovery,make verify-local-pathsand theinternal/jellycompatandinternal/ratelimittests pass. The full CONTRIBUTING gate ran on a combined build of this branch with the other [v1] Server limits & audit logs #1216 branches. Every step passed exceptmake test-go: its failures also occur on unmodifiedmainon the macOS test machine (hardware-acceleration probes andTestAdminResourceCapabilitiesAndScope), apart from transcode timing tests that failed under heavy machine load and passed on rerun.Not run: real Jellyfin clients (Infuse, Jellyfin Web, Findroid) against the limits. The default per-IP budget is 120 requests per second with images exempt; representative real-client traffic has not been measured against it.
Independent review at
7f80e3e2b: the complete rate-limit package, Jellyfin router rate-limit tests, and focused race tests pass. Two Dolby Vision playback tests fail on both this head and a clean base checkout on the review machine. The CI database-pin failure also occurs in main run 38185031866. No live sandbox or real-client verification was repeated by this review.GitHub GraphQL rate limiting prevented a board refresh. REST validation-issue records were checked instead; no recorded passed case was found to regress. Server limits & audit logs — Server #1217 C1 and Compatibility layers (Jellyfin / Audiobookshelf) — Jellyfin compatibility #1246 C1 remain Not run.
Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2305/
Risks
Several Jellyfin clients behind one household IP now share the per-IP budget with native apps on that IP. Native apps already shared it with each other, and the defaults leave a wide margin.
Follow-ups
Checklist
AI Disclosure
/embyprefixes), client IP handling, native parity for media routes, and normal Jellyfin client load; no issues found7f80e3e2b. No introduced defect was confirmed. The documented API-key tier exception was retained; existing proxy-trust and generic-budget-order issues are tracked in [bug] A direct client in a trusted proxy range can bypass per-IP sign-in limits #2329 and [bug] Requests rejected by per-IP limits still consume the global request budget #2330.