#197 S7+S10 [MED]: mutating GETs, spoofable ForwardedHeaders, scanner exemption, unpaged all-items #285

Closed
opened 2026-07-11 23:21:08 +02:00 by timothy · 2 comments
Owner

From the #197 cold API security review. Phase 1 residue (lower severity, same gate).

Findings:

  • S7: GET /api/maintenance/gc performs garbage collection via a safe verb (crawler/prefetch-triggerable); troubleshoot playback/archive GETs leave temp files. (MaintenanceController.cs:15.)
  • S10: ForwardedHeaders.All with KnownIPNetworks/KnownProxies cleared (Startup.cs:164) → any peer can spoof X-Forwarded-* (log integrity + Request.Scheme/Host used in URL construction); ScannerController [SkipApiKeyAuthorization] relies on a guessable active-GUID as its sole secret (ScannerController.cs:12); /api/search/all-items returns every matching id unpaged (SearchController.cs).

Fix (Phase-1 #6): gc→POST; populate ForwardedHeaders trust from config (loopback default), operator sets the proxy network; ScannerController loopback-only check; page/cap search/all-items. nosniff/X-Frame-Options/Referrer-Policy + constant-time compare + the 2 playout clamps already landed in PR #279; CSP/HSTS deferred to the design. Refs #197.

From the #197 cold API security review. **Phase 1 residue (lower severity, same gate).** **Findings:** - **S7:** `GET /api/maintenance/gc` performs garbage collection via a safe verb (crawler/prefetch-triggerable); troubleshoot playback/archive GETs leave temp files. (`MaintenanceController.cs:15`.) - **S10:** `ForwardedHeaders.All` with `KnownIPNetworks`/`KnownProxies` cleared (`Startup.cs:164`) → any peer can spoof `X-Forwarded-*` (log integrity + `Request.Scheme/Host` used in URL construction); `ScannerController [SkipApiKeyAuthorization]` relies on a guessable active-GUID as its sole secret (`ScannerController.cs:12`); `/api/search/all-items` returns every matching id unpaged (`SearchController.cs`). **Fix (Phase-1 #6):** `gc`→POST; populate `ForwardedHeaders` trust from config (loopback default), operator sets the proxy network; `ScannerController` loopback-only check; page/cap `search/all-items`. `nosniff`/`X-Frame-Options`/`Referrer-Policy` + constant-time compare + the 2 playout clamps already landed in **PR #279**; CSP/HSTS deferred to the design. Refs #197.
timothy added the priority: mediumreviewsecurity labels 2026-07-11 23:21:08 +02:00
Author
Owner

Bundling — Bundle A "auth posture" (single session / one PR): #280 + #281 + #282 + #284 + #285. These residue items (gc→POST, ForwardedHeaders trust, ScannerController loopback, search/all-items paging) are small Startup.cs/controller edits in the same security pass — bundle to avoid a separate Startup-touching PR (could split off if Bundle A gets large). Parallel-safe against Bundle B (#283) and #289. Phase-1 gate. See #197 roadmap.

**Bundling — Bundle A "auth posture" (single session / one PR): #280 + #281 + #282 + #284 + #285.** These residue items (gc→POST, ForwardedHeaders trust, ScannerController loopback, search/all-items paging) are small `Startup.cs`/controller edits in the same security pass — bundle to avoid a separate Startup-touching PR (could split off if Bundle A gets large). Parallel-safe against Bundle B (#283) and #289. Phase-1 gate. See #197 roadmap.
timothy added the in-progress label 2026-07-11 23:46:47 +02:00
Author
Owner

Closed — PR #292 (merged FF to main ee6be81c)

Done (S7/S10 residue).

  • gc GET→POST (MaintenanceController) — crawler/prefetch-triggerable GC on a safe verb; spec + endpoint-index regenerated. No SPA caller. Now key-gated as a mutation.
  • ForwardedHeaders trust is configurable via ForwardedHeaders:KnownProxies / KnownNetworks (semicolon lists). Deliberate deviation: unconfigured preserves the current trust-all behavior but logs a warning — flipping the default to loopback-only would break reverse-proxy Request.Scheme/Host detection and thus M3U/XMLTV absolute URLs, so the operator must name their proxy network. Recorded in decisions.md.
  • ScannerController gains [LocalhostOnly] — the scanner always calls back over http://localhost:{UiPort}/api/scan/... (CallLibraryScannerHandler.cs:25). It interlocks with restricting ForwardedHeaders trust (else the loopback check is XFF-spoofable — documented residual, accepted by review as defense-in-depth since the {scanId:guid} + IsActive checks remain).

Deferred: search/all-items DoS-paging — it feeds the SPA "add all to collection/playlist" flow and needs coordinated pagination; the unauth exposure is already closed by read-gating (#282), so the residual is DoS-hardening only. Tracking under #197 Phase-3 / a follow-up.

Files: MaintenanceController.cs, Startup.cs, ScannerController.cs, LocalhostOnlyAttribute.cs (new), regenerated v1.json/endpoint-index.md.

## Closed — PR #292 (merged FF to main `ee6be81c`) **Done (S7/S10 residue).** - `gc` **GET→POST** (`MaintenanceController`) — crawler/prefetch-triggerable GC on a safe verb; spec + endpoint-index regenerated. No SPA caller. Now key-gated as a mutation. - `ForwardedHeaders` trust is **configurable** via `ForwardedHeaders:KnownProxies` / `KnownNetworks` (semicolon lists). **Deliberate deviation**: unconfigured *preserves* the current trust-all behavior but logs a warning — flipping the default to loopback-only would break reverse-proxy `Request.Scheme/Host` detection and thus M3U/XMLTV absolute URLs, so the operator must name their proxy network. Recorded in decisions.md. - `ScannerController` gains `[LocalhostOnly]` — the scanner always calls back over `http://localhost:{UiPort}/api/scan/...` (`CallLibraryScannerHandler.cs:25`). It interlocks with restricting ForwardedHeaders trust (else the loopback check is XFF-spoofable — documented residual, accepted by review as defense-in-depth since the `{scanId:guid}` + `IsActive` checks remain). **Deferred**: `search/all-items` DoS-paging — it feeds the SPA "add all to collection/playlist" flow and needs coordinated pagination; the **unauth exposure is already closed by read-gating** (#282), so the residual is DoS-hardening only. Tracking under #197 Phase-3 / a follow-up. **Files**: `MaintenanceController.cs`, `Startup.cs`, `ScannerController.cs`, `LocalhostOnlyAttribute.cs` (new), regenerated `v1.json`/`endpoint-index.md`.
timothy removed the in-progress label 2026-07-12 00:36:14 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#285