#197 S3+S5 [HIGH]: unauthenticated GETs leak private media samples, env vars, logs, settings, FS paths #282

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

From the #197 cold API security review. Phase 1 hard gate.

Finding (HIGH):

  • S3: unauth GET api/troubleshoot/playback/sample/{mediaItemId} extracts a 30s sample (all streams) of any indexed media item into a downloadable zip; playback.m3u8 starts FFmpeg; /archive builds a zip. Media disclosure + resource abuse on safe verbs. (TroubleshootController.cs:318, ArchiveMediaSampleHandler.cs:31.)
  • S5: unauth GET /api/troubleshoot/info dumps env vars matching ETV_/DOTNET_/ASPNETCORE_/ELASTICSEARCH*/PROVIDER (may include secrets); /api/logs (media paths, IPs); /api/settings/* (all 7); local-library filesystem paths. (GetTroubleshootingInfoHandler.cs:171, LogsController.cs:20, SettingsController.cs.)

Fix (Phase-1 #3): a [RequiresApiKey] attribute (mirror of SkipApiKeyAuthorizationAttribute) making the same filter enforce X-Api-Key on GET too, applied to troubleshoot/*, logs, settings/*, local-library FS-path GETs, maintenance/*. SPA client sends the key on all methods; catalog reads stay open at app level (behind proxy). Extend ApiControllerSecurityTests to assert the tier reflectively. Optional Api:RequireKeyForReads global flag. Refs #197.

From the #197 cold API security review. **Phase 1 hard gate.** **Finding (HIGH):** - **S3:** unauth **GET** `api/troubleshoot/playback/sample/{mediaItemId}` extracts a 30s sample (all streams) of any indexed media item into a downloadable zip; `playback.m3u8` starts FFmpeg; `/archive` builds a zip. Media disclosure + resource abuse on safe verbs. (`TroubleshootController.cs:318`, `ArchiveMediaSampleHandler.cs:31`.) - **S5:** unauth **GET** `/api/troubleshoot/info` dumps env vars matching `ETV_/DOTNET_/ASPNETCORE_/ELASTICSEARCH*/PROVIDER` (may include secrets); `/api/logs` (media paths, IPs); `/api/settings/*` (all 7); local-library filesystem paths. (`GetTroubleshootingInfoHandler.cs:171`, `LogsController.cs:20`, `SettingsController.cs`.) **Fix (Phase-1 #3):** a `[RequiresApiKey]` attribute (mirror of `SkipApiKeyAuthorizationAttribute`) making the same filter enforce `X-Api-Key` on GET too, applied to `troubleshoot/*`, `logs`, `settings/*`, local-library FS-path GETs, `maintenance/*`. SPA client sends the key on all methods; catalog reads stay open at app level (behind proxy). Extend `ApiControllerSecurityTests` to assert the tier reflectively. Optional `Api:RequireKeyForReads` global flag. Refs #197.
timothy added the priority: highreviewsecurity labels 2026-07-11 23:20:38 +02:00
Author
Owner

Bundling — Bundle A "auth posture" (single session / one PR): #280 + #281 + #282 + #284 + #285. This one ([RequiresApiKey] read-tier) and #280 (fail-closed) both rewrite ApiKeyAuthorizationFilter and share the same SPA change — "send the key on all methods, not just writes" (web/src/api/client.ts) — so they're really one unit; #281/#284/#285 ride the same filter + Startup.cs + ApiControllerSecurityTests surface. 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.** This one (`[RequiresApiKey]` read-tier) and #280 (fail-closed) both rewrite `ApiKeyAuthorizationFilter` and share the same SPA change — "send the key on all methods, not just writes" (`web/src/api/client.ts`) — so they're really one unit; #281/#284/#285 ride the same filter + `Startup.cs` + `ApiControllerSecurityTests` surface. 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:41 +02:00
Author
Owner

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

Done (S3/S5 sensitive-read tier). Reads under /api are gated when Api:RequireKeyForReads (default true, owner decision) OR the endpoint carries the new [RequiresApiKey] marker (mirror of [SkipApiKeyAuthorization]), applied to Troubleshoot/Logs/Settings/Maintenance so the sensitive tier stays gated even if an operator opens reads. OPTIONS preflight is exempt. ApiControllerSecurityTests asserts the tier reflectively.

The cold review confirmed no other /api GET discloses a credential without [RequiresApiKey] (the remote-connection GET returns only hasApiKey: bool).

Files: ErsatzTV/Filters/RequiresApiKeyAttribute.cs (new), ApiKeyAuthorizationFilter.cs, the four controllers, ApiControllerSecurityTests.cs. SPA sends the key on GET too. Live E2E: GET /api/settings/ffmpeg no-key → 401.

Docs: api-conventions §9.

## Closed — PR #292 (merged FF to main `ee6be81c`) **Done (S3/S5 sensitive-read tier).** Reads under `/api` are gated when `Api:RequireKeyForReads` (default **true**, owner decision) OR the endpoint carries the new `[RequiresApiKey]` marker (mirror of `[SkipApiKeyAuthorization]`), applied to `Troubleshoot`/`Logs`/`Settings`/`Maintenance` so the sensitive tier stays gated even if an operator opens reads. `OPTIONS` preflight is exempt. `ApiControllerSecurityTests` asserts the tier reflectively. The cold review confirmed no other `/api` GET discloses a credential without `[RequiresApiKey]` (the remote-connection GET returns only `hasApiKey: bool`). **Files**: `ErsatzTV/Filters/RequiresApiKeyAttribute.cs` (new), `ApiKeyAuthorizationFilter.cs`, the four controllers, `ApiControllerSecurityTests.cs`. SPA sends the key on GET too. Live E2E: `GET /api/settings/ffmpeg` no-key → 401. **Docs**: api-conventions §9.
timothy removed the in-progress label 2026-07-12 00:36:10 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#282