Harden the /iptv ?access_token= transport: redact from request logs + no-store on tokened manifests #559

Closed
opened 2026-07-22 17:32:08 +02:00 by timothy · 3 comments
Owner

Split out of the #552 security review (deferred hardening).

Problem

The /iptv/* ?access_token= credential transport has two pre-existing weaknesses. They predate #552 — Jellyfin and the M3U playlist already pass access_token in /iptv URLs — but #552 (short-lived browser tokens) makes them slightly more relevant, and the review flagged them:

  1. Token can reach request logs. Startup.cs configures UseSerilogRequestLogging with IncludeQueryInRequestPath = true and {RequestPath} in the message template. /iptv requests log at Debug (suppressed under default min-level), but the ex != null and StatusCode > 499 branches log at Error regardless of path — so a 5xx on an /iptv/...?access_token=<jwt> request writes the full token to the log under default settings. Anyone with log access can replay the (globally-scoped) token until expiry.

  2. Tokened dynamic manifests lack Cache-Control: no-store. The multi-variant playlist (IptvController.GetMultiVariantPlaylist, ~:305) and the variant playlist embed the access_token in their bodies/URLs but set no cache headers, so a browser or intermediary could cache the token-bearing manifest.

Why deferred from #552

Both are properties of the shared ?access_token= transport (all /iptv clients, not just the browser), and the fixes are cross-cutting changes to request-logging and manifest-serving behavior with their own review/test surface. #552 already bounds the exposure by making browser tokens 60-min (vs the old hardcoded 1-day GenerateToken) and clamping the configurable lifetime to 24h.

Suggested shape

  1. Redact access_token from the logged RequestPath — e.g. set IncludeQueryInRequestPath = false and enrich a scrubbed request path (query minus access_token), or a Serilog destructuring/enricher that masks it. Verify with a live 5xx on a tokened /iptv URL. Apply the same thought to any reverse-proxy access logs (ops note).
  2. Return Cache-Control: private, no-store on token-bearing dynamic /iptv manifests.

Done-when

  • A 5xx (and Debug-level) /iptv/...?access_token= request does not write the token to the log
  • Token-bearing dynamic manifests return no-store
  • Covered by a test (log scrub) and a curl assertion (header)
  • docs/decisions/api-auth-security.md updated (fold into / supersede the "deferred hardening" note under security.iptv-browser-token)
Split out of the #552 security review (deferred hardening). ## Problem The `/iptv/*` `?access_token=` credential transport has two pre-existing weaknesses. They predate #552 — Jellyfin and the M3U playlist already pass `access_token` in `/iptv` URLs — but #552 (short-lived browser tokens) makes them slightly more relevant, and the review flagged them: 1. **Token can reach request logs.** `Startup.cs` configures `UseSerilogRequestLogging` with `IncludeQueryInRequestPath = true` and `{RequestPath}` in the message template. `/iptv` requests log at Debug (suppressed under default min-level), but the `ex != null` and `StatusCode > 499` branches log at **Error** regardless of path — so a 5xx on an `/iptv/...?access_token=<jwt>` request writes the full token to the log under default settings. Anyone with log access can replay the (globally-scoped) token until expiry. 2. **Tokened dynamic manifests lack `Cache-Control: no-store`.** The multi-variant playlist (`IptvController.GetMultiVariantPlaylist`, ~:305) and the variant playlist embed the `access_token` in their bodies/URLs but set no cache headers, so a browser or intermediary could cache the token-bearing manifest. ## Why deferred from #552 Both are properties of the shared `?access_token=` transport (all `/iptv` clients, not just the browser), and the fixes are cross-cutting changes to request-logging and manifest-serving behavior with their own review/test surface. #552 already **bounds** the exposure by making browser tokens 60-min (vs the old hardcoded 1-day `GenerateToken`) and clamping the configurable lifetime to 24h. ## Suggested shape 1. Redact `access_token` from the logged `RequestPath` — e.g. set `IncludeQueryInRequestPath = false` and enrich a scrubbed request path (query minus `access_token`), or a Serilog destructuring/enricher that masks it. Verify with a live 5xx on a tokened `/iptv` URL. Apply the same thought to any reverse-proxy access logs (ops note). 2. Return `Cache-Control: private, no-store` on token-bearing dynamic `/iptv` manifests. ## Done-when - [x] A 5xx (and Debug-level) `/iptv/...?access_token=` request does not write the token to the log - [x] Token-bearing dynamic manifests return `no-store` - [x] Covered by a test (log scrub) and a curl assertion (header) - [x] `docs/decisions/api-auth-security.md` updated (fold into / supersede the "deferred hardening" note under `security.iptv-browser-token`)
timothy added the apipriority: lowsecurity labels 2026-07-22 17:32:08 +02:00
Author
Owner

🔗 Session bundle — access_token transport hardening: #421, #559

Both harden the access_token-in-URL surface (from the #376/#552 arc): #421 (M3U token not quote-safe in the url-tvg="..." attribute) and #559 (redact the /iptv ?access_token= from request logs + no-store on tokened manifests). Security-adjacent, same token transport.

When you claim any member, check this cluster for co-workable siblings and sweep the disjoint set in one session (per docs/handoffs/chicorytv-issue-queue.md → bundles).

🔗 **Session bundle — access_token transport hardening:** #421, #559 Both harden the `access_token`-in-URL surface (from the #376/#552 arc): #421 (M3U token not quote-safe in the url-tvg="..." attribute) and #559 (redact the /iptv `?access_token=` from request logs + no-store on tokened manifests). Security-adjacent, same token transport. When you claim any member, check this cluster for co-workable siblings and sweep the disjoint set in one session (per docs/handoffs/chicorytv-issue-queue.md → bundles).
timothy added the in-progress label 2026-07-23 07:59:38 +02:00
Author
Owner

Claiming this as part of the access_token transport hardening bundle (#421 + #559) in one session — both harden the access_token-in-URL surface. Working in a worktree off origin/main.

Claiming this as part of the **access_token transport hardening** bundle (#421 + #559) in one session — both harden the `access_token`-in-URL surface. Working in a worktree off `origin/main`.
Author
Owner

Closing record

Outcome: Merged in #574 (squash). (1) Serilog request log redacts access_token (IncludeQueryInRequestPath = false + RequestLogScrubber → RequestPathScrubbed = ***). (2) Cache-Control: private, no-store on channels.m3u, xmltv.xml, the .m3u8 HLS manifests, and their token-bearing 302 Locations.
Root cause: UseSerilogRequestLogging logged the full query at Error on any 5xx /iptv request → token replay from logs; token-bearing dynamic manifests set no cache headers → cache replay. Both pre-date #552 (Jellyfin/M3U already pass access_token).
Decisions/conventions changed: security.iptv-access-token-transport (shared with #421); resolves the deferred-hardening note under security.iptv-browser-token.
Reusable knowledge: Serilog appends its own RequestPath AFTER enriched props, so an enricher must use a DISTINCT name (RequestPathScrubbed) to survive. Residual: ASP.NET's Microsoft.AspNetCore.Hosting "Request starting" line also carries the raw query but is suppressed only by the "Microsoft":"Warning" appsettings override (NOT reachable via the runtime logging-settings UI — HttpLevelSwitch covers only Serilog.AspNetCore.RequestLoggingMiddleware); that override is load-bearing.
Verification: RequestLogScrubberTests + IptvControllerCacheHeaderTests; 2-round cold review; CI green; live-E2E confirmed HTTP GET /iptv/channels.m3u?mode=segmenter&access_token=*** responded 200 with the raw token absent from logs, and no-store on m3u/xmltv/m3u8.
Deferred: category-agnostic log scrub filter — only if the Microsoft:Warning override is ever relaxed (documented, no issue filed).
Docs updated: docs/decisions/api-auth-security.md.

## Closing record **Outcome:** Merged in #574 (squash). (1) Serilog request log redacts `access_token` (`IncludeQueryInRequestPath = false` + `RequestLogScrubber` → `RequestPathScrubbed` = `***`). (2) `Cache-Control: private, no-store` on `channels.m3u`, `xmltv.xml`, the `.m3u8` HLS manifests, and their token-bearing 302 Locations. **Root cause:** `UseSerilogRequestLogging` logged the full query at Error on any 5xx `/iptv` request → token replay from logs; token-bearing dynamic manifests set no cache headers → cache replay. Both pre-date #552 (Jellyfin/M3U already pass `access_token`). **Decisions/conventions changed:** `security.iptv-access-token-transport` (shared with #421); resolves the deferred-hardening note under `security.iptv-browser-token`. **Reusable knowledge:** Serilog appends its own `RequestPath` AFTER enriched props, so an enricher must use a DISTINCT name (`RequestPathScrubbed`) to survive. Residual: ASP.NET's `Microsoft.AspNetCore.Hosting` "Request starting" line also carries the raw query but is suppressed only by the `"Microsoft":"Warning"` appsettings override (NOT reachable via the runtime logging-settings UI — `HttpLevelSwitch` covers only `Serilog.AspNetCore.RequestLoggingMiddleware`); that override is load-bearing. **Verification:** `RequestLogScrubberTests` + `IptvControllerCacheHeaderTests`; 2-round cold review; CI green; live-E2E confirmed `HTTP GET /iptv/channels.m3u?mode=segmenter&access_token=*** responded 200` with the raw token absent from logs, and `no-store` on m3u/xmltv/m3u8. **Deferred:** category-agnostic log scrub filter — only if the `Microsoft:Warning` override is ever relaxed (documented, no issue filed). **Docs updated:** `docs/decisions/api-auth-security.md`.
timothy removed the in-progress label 2026-07-23 18:32:32 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#559