Skip to content

fix(playback): keep the account token out of transcode relay logs - #3126

Merged
Quick104 merged 1 commit into
mainfrom
fix/sec-relay-log-token
Oct 27, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/sec-relay-log-token

Conversation

@Quick104

@Quick104 Quick104 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

When a player streams a transcode that runs on a remote transcode node, the API relays each manifest and segment request to the node. Two of the relay's error logs wrote the request URL with the viewer's account access token still in it. One of them runs every time a client cancels a request, which players do routinely while seeking or stopping. The token ended up in stderr, any OTLP collector, and the operational log that admins can read in the web admin. Anyone with access to those logs could reuse a viewer's token until it expires, about 8 hours by default. An automated security scan found this, and the finding was re-verified against the code.

The relay removes the signed stream token (st) from the forwarded URL but keeps every other query parameter, including the token the web player appends because a native media element cannot send an Authorization header. The "proxy to transcode node" branch logged that URL as-is, and its error attribute also carried the full URL, since the HTTP client's *url.Error repeats it. The "read transcode node manifest" branch logged the same URL. The console log handler redacts by attribute key only, so neither value was masked.

Approach

Both branches now log the URL through logredact.SanitizeURL, which drops the query, and the proxy branch logs its error through logredact.SanitizeURLError. That matches the neighboring "transcode node unreachable" branch, which already sanitized both. No new redaction code.

The token is still forwarded to the node. The node copies the forwarded query into the segment URIs of the manifest it builds, and negotiated V3 sessions check the account owner on every segment request. A native HLS player has no other way to authenticate those requests when the URL carries no st, so dropping token from the forwarded query could break that playback. The other node-URL logs in the handlers package already go through SanitizeURL.

Validation

  • Build, gofmt, go vet, make lint-changed, make lint-router-recovery: clean.
  • go test ./internal/api/handlers/: pass.
  • make test-go: fails locally in internal/jellycompat, internal/metadata/nfo, internal/playback, internal/scanner and internal/subtitles/subsync, on filename case and encoding on macOS and on real-FFmpeg timeouts. None of those packages import internal/api/handlers.
  • A throwaway test drove both branches with ?token= through the console handler stack. Before the change the token appeared 3 times in the output; after it, 0. That test is not committed because the redaction helpers already have their own tests.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3126/

Risks

Only log output changes. These two messages no longer include the relay request's query string; the path, node and playback session ID are still logged.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: T3 Code (Claude Code)
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; no human has reviewed the diff yet
  • Adversarial review: automated security scan finding, independently re-verified against the code by a separate agent.

🤖 Generated with Claude Code

The transcode relay strips only the stream token ("st") from the URL it
forwards to the node, so a player's account "token" query stays in it.
Two error branches logged that URL as-is, and the proxy branch also logged
the HTTP client's error, whose text repeats the full URL. The proxy branch
runs on every client cancel, so access tokens reached stderr and the
operational log.

Log both URLs through logredact.SanitizeURL and the proxy error through
logredact.SanitizeURLError, as the unreachable branch already does. The
token is still forwarded: the node copies the query into segment URIs,
which native HLS players need for owner-checked V3 sessions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/S 0–49 added + deleted lines (all files); change volume, not priority. label Oct 27, 2026
@silo-kody

silo-kody Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: b6a76b9c-d7c4-45fa-b995-c3a968c19812
Commits

Reviewing files that changed from the base of the PR and between bca55f7 and 94e87b8.

Files selected for processing: 1
  • internal/api/handlers/playback.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T01:07:44.840123Z 94e87b8 PR opened
🔒 Security Review ✅ Completed 2026-10-27T01:09:08.250873Z 94e87b8 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P0 Fix/merge first: data-loss, security, or widespread breakage labels Oct 27, 2026
@Quick104
Quick104 merged commit 95640bd into main Oct 27, 2026
22 checks passed
@Quick104
Quick104 deleted the fix/sec-relay-log-token branch October 27, 2026 01:19
Quick104 added a commit that referenced this pull request Oct 27, 2026
…3137)

* fix(logredact): keep signed stream and download tokens out of logs

When the download preflight to a proxy node failed, a debug log wrote the
HTTP client's error, which repeats the probe URL with the signed download
token in its path. logredact.SanitizeURL only dropped userinfo, query and
fragment, so routing the error through it would not have helped, and the
same gap applied to every signed stream URL (/stream/direct/,
/stream/remux/, /stream/transcode/<token>/...).

Signed stream and download tokens are JWTs, so logredact now treats a
JWT-shaped path segment as a credential: SanitizeURL and
SanitizeRequestURL mask it, and the checks that decide whether a URL needs
sanitizing (SanitizeURLError's requested-URL scrub, SanitizeJSON and the
operational log's free-text URL pass) share one rule,
URLMayHoldCredential. The preflight log now uses SanitizeURLError.

The proxy's "proxy to transcode node" error log, the node-side copy of
the relay log fixed in #3126, also logged its raw URL and error, whose
query can carry the player's account token. It now uses SanitizeURL and
SanitizeURLError like the API relay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(logredact): match token path segments after unescaping

A token whose characters were percent-encoded in the path, such as a
leading %65 for e, slipped past the redaction and decodes back to a
working token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(opslog): trim a trailing exclamation mark before checking a logged URL

An exclamation mark ending a sentence was taken into the URL, so a signed
token in its last path segment no longer matched and stayed in the log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P0 Fix/merge first: data-loss, security, or widespread breakage size/S 0–49 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant