security: keep local-library filesystem paths authenticated when reads are open #334

Closed
opened 2026-07-13 19:21:33 +02:00 by timothy · 2 comments
Owner

Finding

The final #197 source audit found a regression in the documented sensitive-read tier.

GET /api/v1/libraries/local/{id} returns LocalLibraryPathResponseModel.Path values containing real server filesystem paths, but the action does not carry [RequiresAuthentication]. Under the default Api:RequireKeyForReads=true posture it is protected. If an operator deliberately enables anonymous catalog reads with Api:RequireKeyForReads=false, this detail endpoint becomes anonymous too, contrary to docs/api-conventions.md §9 and the original #282 scope.

This is non-blocking for remote exposure while the default remains enabled, but the opt-out is not safe for non-catalog data until fixed.

Done-when

  • GET /api/v1/libraries/local/{id} still requires a valid machine key or authenticated session when Api:RequireKeyForReads=false.
  • Ordinary catalog reads that do not disclose filesystem paths retain their intended opt-out behavior.
  • A regression test proves the action is in the sensitive-read tier.
  • API/security documentation names the local-library detail endpoint in that tier.
  • Adversarial review passed.

Refs #197, #282.

## Finding The final #197 source audit found a regression in the documented sensitive-read tier. `GET /api/v1/libraries/local/{id}` returns `LocalLibraryPathResponseModel.Path` values containing real server filesystem paths, but the action does not carry `[RequiresAuthentication]`. Under the default `Api:RequireKeyForReads=true` posture it is protected. If an operator deliberately enables anonymous catalog reads with `Api:RequireKeyForReads=false`, this detail endpoint becomes anonymous too, contrary to `docs/api-conventions.md` §9 and the original #282 scope. This is non-blocking for remote exposure while the default remains enabled, but the opt-out is not safe for non-catalog data until fixed. ## Done-when - [x] `GET /api/v1/libraries/local/{id}` still requires a valid machine key or authenticated session when `Api:RequireKeyForReads=false`. - [x] Ordinary catalog reads that do not disclose filesystem paths retain their intended opt-out behavior. - [x] A regression test proves the action is in the sensitive-read tier. - [x] API/security documentation names the local-library detail endpoint in that tier. - [x] Adversarial review passed. Refs #197, #282.
timothy added the priority: mediumsecurity labels 2026-07-13 19:21:33 +02:00
timothy added the in-progress label 2026-07-16 18:36:09 +02:00
Author
Owner

Claiming this after the higher-ranked automatic pickups were explicitly parked. The intended fix is narrow: put the local-library detail GET into the existing sensitive-read tier, add a regression assertion that ordinary catalog opt-out behavior remains unchanged, and update the API security documentation. I’ll keep the change isolated and obtain the required security review before merge.

Claiming this after the higher-ranked automatic pickups were explicitly parked. The intended fix is narrow: put the local-library detail GET into the existing sensitive-read tier, add a regression assertion that ordinary catalog opt-out behavior remains unchanged, and update the API security documentation. I’ll keep the change isolated and obtain the required security review before merge.
Author
Owner

Done

What was done: Added [RequiresAuthentication] to GET /api/v1/libraries/local/{id} while leaving the ordinary local-library list in the catalog-read opt-out tier. Added effective controller-plus-action metadata regression coverage. Merged in PR #371 (72d47ef0).

Root cause: The detail action relied only on the global read-auth setting and omitted the sensitive-read marker, so Api:RequireKeyForReads=false also opened responses containing real server filesystem paths.

Files changed: ErsatzTV/Controllers/Api/LocalLibrariesController.cs, ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs, docs/api-conventions.md.

Verification: Full solution restore/build/test passed with 0 failures; focused authorization/security tests passed 23/23; OpenAPI regeneration and generated API types were unchanged; pre-push API check, lint, typecheck, and web build passed; all eight CI statuses passed or were correctly skipped. Cold security review and follow-up re-review were clean.

Deferred: None.

Follow-up issues: None.

Docs updated: docs/api-conventions.md now names local-library detail in the sensitive-read tier and preserves the list opt-out boundary.

## Done **What was done**: Added `[RequiresAuthentication]` to `GET /api/v1/libraries/local/{id}` while leaving the ordinary local-library list in the catalog-read opt-out tier. Added effective controller-plus-action metadata regression coverage. Merged in PR #371 (`72d47ef0`). **Root cause**: The detail action relied only on the global read-auth setting and omitted the sensitive-read marker, so `Api:RequireKeyForReads=false` also opened responses containing real server filesystem paths. **Files changed**: `ErsatzTV/Controllers/Api/LocalLibrariesController.cs`, `ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs`, `docs/api-conventions.md`. **Verification**: Full solution restore/build/test passed with 0 failures; focused authorization/security tests passed 23/23; OpenAPI regeneration and generated API types were unchanged; pre-push API check, lint, typecheck, and web build passed; all eight CI statuses passed or were correctly skipped. Cold security review and follow-up re-review were clean. **Deferred**: None. **Follow-up issues**: None. **Docs updated**: `docs/api-conventions.md` now names local-library detail in the sensitive-read tier and preserves the list opt-out boundary.
timothy removed the in-progress label 2026-07-16 19:17:25 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#334