Add Cross-Origin-Resource-Policy baseline header #341

Merged
timothy merged 1 commits from codex/330-corp into main 2026-07-13 21:33:15 +02:00
Owner

Fixes #330

Summary

  • send Cross-Origin-Resource-Policy: same-origin from SecurityHeadersMiddleware on every response
  • keep the existing CSP-only exemption for /docs and /openapi; CORP remains present there
  • cover API, artwork, IPTV, docs, and OpenAPI representative paths
  • record the global browser-embedding posture in docs/decisions.md

Compatibility reasoning

The WHATWG Fetch CORP algorithm and Chromium's CORP tests confirm that CORP applies to opaque/no-cors browser loads, not successful CORS-mode requests. The configured Api:CorsAllowedOrigins machine-client path therefore remains usable. Native/server-side clients such as Kodi, Dispatcharr, Jellyfin's backend, curl, and .NET do not enforce CORP.

The deliberate behavior change is that a browser may no longer embed ErsatzTV artwork/media directly from a different scheme, host, or port. The supported SPA path is same-origin.

The separate Kodi image failures were diagnosed as unstable/unreachable XMLTV URLs, not CORP. Findings are on timothy/server-management#501; local code hardening is tracked by #340.

Verification

  • focused SecurityHeadersMiddlewareTests: 9/9 passed
  • TZ=UTC dotnet restore ErsatzTV.sln -v minimal
  • TZ=UTC dotnet build ErsatzTV.sln --no-restore -v minimal — 0 warnings, 0 errors
  • TZ=UTC dotnet test ErsatzTV.sln --no-build -v minimal
  • pre-push: generated API drift check, ESLint, TypeScript typecheck, and Vite production build

Live-E2E is not required: this changes no mutating handler or SPA behavior.

Fixes #330 ## Summary - send `Cross-Origin-Resource-Policy: same-origin` from `SecurityHeadersMiddleware` on every response - keep the existing CSP-only exemption for `/docs` and `/openapi`; CORP remains present there - cover API, artwork, IPTV, docs, and OpenAPI representative paths - record the global browser-embedding posture in `docs/decisions.md` ## Compatibility reasoning The WHATWG Fetch CORP algorithm and Chromium's CORP tests confirm that CORP applies to opaque/`no-cors` browser loads, not successful CORS-mode requests. The configured `Api:CorsAllowedOrigins` machine-client path therefore remains usable. Native/server-side clients such as Kodi, Dispatcharr, Jellyfin's backend, curl, and .NET do not enforce CORP. The deliberate behavior change is that a browser may no longer embed ErsatzTV artwork/media directly from a different scheme, host, or port. The supported SPA path is same-origin. The separate Kodi image failures were diagnosed as unstable/unreachable XMLTV URLs, not CORP. Findings are on `timothy/server-management#501`; local code hardening is tracked by #340. ## Verification - focused `SecurityHeadersMiddlewareTests`: 9/9 passed - `TZ=UTC dotnet restore ErsatzTV.sln -v minimal` - `TZ=UTC dotnet build ErsatzTV.sln --no-restore -v minimal` — 0 warnings, 0 errors - `TZ=UTC dotnet test ErsatzTV.sln --no-build -v minimal` - pre-push: generated API drift check, ESLint, TypeScript typecheck, and Vite production build Live-E2E is not required: this changes no mutating handler or SPA behavior.
timothy added 1 commit 2026-07-13 21:26:13 +02:00
fix: add cross-origin resource policy header
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 7s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 7s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 19s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m29s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m15s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 5m26s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (push) Has been skipped
Build ErsatzTV Image / decisions.md append-only (push) Has been skipped
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / Build & test (.NET) (push) Failing after 7s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Successful in 3m44s
Build ErsatzTV Image / Build & push image (amd64) (push) Has been skipped
2609b4ce59
Fixes #330

Co-Authored-By: Codex <noreply@openai.com>
Author
Owner

Cold independent security review completed with no findings.

  • confirmed the unconditional middleware placement covers API, artwork, IPTV, static, streaming, error, docs, and OpenAPI responses
  • confirmed Fetch/CORP semantics preserve successful configured CORS-mode requests and do not affect native/server-side clients
  • confirmed the CSP-only exception does not suppress CORP on /docs or /openapi
  • focused middleware suite passed 9/9

Review-verdict: MERGEABLE @ 2609b4ce59

Cold independent security review completed with no findings. - confirmed the unconditional middleware placement covers API, artwork, IPTV, static, streaming, error, docs, and OpenAPI responses - confirmed Fetch/CORP semantics preserve successful configured CORS-mode requests and do not affect native/server-side clients - confirmed the CSP-only exception does not suppress CORP on `/docs` or `/openapi` - focused middleware suite passed 9/9 Review-verdict: MERGEABLE @ 2609b4ce593eeaf7203fb50c78feec030638984f
timothy merged commit 2609b4ce59 into main 2026-07-13 21:33:15 +02:00
timothy deleted branch codex/330-corp 2026-07-13 21:33:15 +02:00
Sign in to join this conversation.