Repository navigation
feat(api): report the request origin in system info - #3023
Conversation
GET /api/v2/system/info gains request_origin, the scheme and host the server saw the request arrive on, derived like the OAuth iss: the transport scheme and Host, replaced by X-Forwarded-Proto and X-Forwarded-Host only from a configured trusted proxy. A client that must send credentials only to the origin it configured, such as the Roku client, compares the two before signing in. The response is now Cache-Control: private, no-cache so a shared cache never hands one origin's value to another. The origin derivation and serialization move from the OAuth handler to clientip (RequestOrigin, SerializeOrigin) so both callers share them. Authenticated v2 routes also stop redirecting a client to another origin: the v2 transcode manifest and segment relay answers a node's 3xx with 502, and the v2 plugin-content mount answers a plugin redirect that leaves the request's origin, a scheme downgrade included, with 502. It also refuses a Location with a backslash, which browsers read as a slash, and one sent under more than one spelling. Plugin response headers are kept under their canonical names, so the Location the guard checks is the one written. The frozen v1 routes keep relaying both redirects unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
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:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df92d0f942
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
41ad2a74-2aa4-4084-b3d6-29b82adbf85f
Files selected for processing: 19-
contracts/api/v2/fixtures/get_system_info_ok.jsoncontracts/api/v2/fixtures/index.jsoncontracts/api/v2/openapi.jsondocs/architecture/api-contract.mdinternal/api/handlers/playback.gointernal/api/handlers/playback_proxy_test.gointernal/api/handlers/relay_redirect.gointernal/api/router.gointernal/apiv2/fixtures_test.gointernal/apiv2/router_test.gointernal/apiv2/system.gointernal/auth/oauth_handler.gointernal/auth/oauth_handler_test.gointernal/clientip/middleware.gointernal/clientip/request_origin_test.gointernal/plugins/content.gointernal/plugins/content_test.gointernal/plugins/http_proxy.goweb/src/api/v2/schema.ts
Included review availability: This review used your included allowance. 5 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.
-
Go's url.Parse reads `///host/x` as a path on the request host, but WHATWG URL parsers skip any number of slashes and go to `host`. The same-origin guard on the v2 plugin mount passed such a Location and relayed it unchanged. Refuse it before resolution, as the guard already does for a backslash, and add the three-slash, four-slash, scheme-plus- three-slash, leading-space, and newline cases to the redirect tests. 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:
|
Problem
Related issue: N/A
Validation tasks: none
A native client can reach Silo through a different origin than the one the user configured. A reverse proxy might send it elsewhere, or a redirect might move it to another host or from HTTPS to HTTP, and the client can't tell. The Roku client follows redirects silently and re-sends the request body on a 307, so it could hand a password or token to an origin it never meant to trust. This change lets a client check which origin it actually reached before it sends credentials. It also stops authenticated
/api/v2routes from sending a client to another origin.GET /api/v2/system/infogainsrequest_origin, the scheme and host the server saw the request arrive on. A client compares it with its configured origin before signing in.Approach
request_originis derived the same way as the OAuthiss: the transport scheme andHost, replaced byX-Forwarded-ProtoandX-Forwarded-Hostonly when the request comes from a configured trusted proxy. When the forwarded scheme is ambiguous, it names the transport's scheme, so a wrong guess shows up as a mismatch, never a false match. The derivation and its canonical serialization moved from the OAuth handler toclientip.RequestOriginandclientip.SerializeOrigin, soissandrequest_origincannot drift apart. The OAuth behavior is unchanged.system/infois served withCache-Control: private, no-cache(it wasno-cache). That is the capability documents' existing posture, and it keeps a shared cache from handing one origin's value to a client of another.Locationnames the node or its front end, never this server. 304 is still relayed.Locationthat Go reads as a path but browsers read as another host: one containing a backslash (/\host, which browsers read as//host) or starting with three or more slashes (///host, where browsers skip the extra slashes). A redirect that sendsLocationunder more than one spelling is refused too, so the value checked is always the value sent. Relative and same-origin redirects pass through. Plugin response headers are now kept under their canonical names on both mounts; the response written is the same./api/v1routes keep relaying both redirects unchanged.docs/architecture/api-contract.mdrecords the new member, the cache policy, and the remaining deliberate cross-origin redirects: the opt-in media-proxy 307s on-proxydownloads and the bandwidth probe, plus the browser OAuth and Discord-link handshakes. OpenAPI, the fixtures, andweb/src/api/v2/schema.tsare regenerated.The field is additive and optional. Apple and Android clients need no change; jellycompat is unaffected because Jellyfin clients use their own system info.
Validation
make embed-stub,go build ./...,gofmt -l .,go vet ./...,make lint-changed,make lint-router-recovery, andmake test-gopass.pnpm install --frozen-lockfile,lint,format:check,build, andbudget:checkpass.make test-webfailed 3 of 6,730 tests on a heavily loaded host (GlobalSearch, WatchPage, and the PGS parser, including one 5 s timeout). All three files pass when rerun on their own, and this branch changes only one generated type inweb/.TestCommittedArtifactMatchesRouterandverify-prometheus-rules.make verify-apiv2-contractreports one non-breaking change: the optionalrequest_originproperty was added.make verify-actionlintrefused the local binary because it prints its version asv1.7.12; actionlint 1.7.12 run directly passes.make verify-shellcheckwas not run because only ShellCheck 0.9.0 is installed, and the branch changes no shell files.Location. The contract fixtures pinrequest_originand the new cache header.router.gowraps the two v2 transcode routes inRefuseRelayRedirects; removing the wrapper fails nothing. The handler test covers the refusal itself. A route-level test would need a full transcode session with stream-token claims and a node, which no router test sets up today.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/roku-request-origin/
Risks
system/inforesponses are no longer stored by shared caches.internal/proxy) is unchanged. Requests to it carry signed stream tokens, not account credentials; applying the same redirect refusal there is a possible follow-up.Checklist
AI Disclosure
Locationsent under two spellings and a backslashLocationcould pass the plugin redirect check (both fixed, with test rows); the router wiring has no test (recorded above). No other issues found.🤖 Generated with Claude Code
Note
Add
request_originto system-info and refuse off-origin relay redirectsGET /api/v2/system/infonow returns arequest_originfield derived viaclientip.RequestOrigin, and setsCache-Control: private, no-cacheso per-request origins are not served from shared caches (system.go, middleware.go)RefuseRelayRedirects; relayed 3xx responses (except 304) from the transcode node now get the transcode-unavailable response instead of forwarding the redirect (relay_redirect.go, playback.go)Locationleaves the request origin (cross-origin, downgrade, backslash, ambiguous duplicateLocationheaders) with a 502; the frozen/api/v1HTTPProxy.ServeRoutekeeps old behavior (http_proxy.go)clientip.RequestOrigin/clientip.SerializeOrigin(oauth_handler.go)Cache-Controlchanges fromno-cachetoprivate, no-cache; native API v2 transcode routes return 502 instead of relaying node redirects (304 still relayed); guarded plugin routes return 502 for off-origin or ambiguous redirectsMacroscope summarized 1abef83.