Skip to content

Ship a Content-Security-Policy on the viewer (#117) - #119

Draft
shellen wants to merge 1 commit into
mainfrom
csp-hardening
Draft

Ship a Content-Security-Policy on the viewer (#117)#119
shellen wants to merge 1 commit into
mainfrom
csp-hardening

Conversation

@shellen

@shellen shellen commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Fixes #117. Adds the CSP layer behind DOMPurify:

  • Viewer HTML response carries a policy: script-src 'self' 'unsafe-inline' (all libs are inlined by embed-viewer.ts — no remote scripts by design), img-src/media-src/connect-src open for arbitrary article assets + HLS + kroki/Bluesky APIs, frame-src limited to YouTube embeds, object-src 'none', worker-src blob: for hls.js.
  • tauri.conf.json csp: null → minimal policy for the tauri-served placeholder page (real app windows load http://127.0.0.1:{port}, which now sends the header itself).

Verified in Chromium against the real viewer: article with 10 remote images renders, zero CSP violations. YouTube embed + podcast playback should be re-checked in the pre-release smoke test (on the checklist).

Honest scope note: 'unsafe-inline' for scripts is required by the inline-handler architecture, so this CSP mainly blocks remote-script loading, plugins, and foreign frames — meaningful, not bulletproof.

Draft — hold for the next release train; do not merge or deploy this week.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AdXEsWQTadb9qbTQjLkMqn

Second layer behind DOMPurify for untrusted article HTML. Fixes #117:

- The viewer HTML response now carries a CSP: scripts/styles self+inline
  (everything is inlined by embed-viewer.ts), images/media/connect open
  for arbitrary article assets and HLS streams, frames limited to
  YouTube embeds, object-src none
- tauri.conf.json csp covers the tauri-served placeholder page (app
  windows load the HTTP server, which sends the header itself)

Verified against the real viewer in Chromium: article with 10 remote
images renders with zero CSP violations. Source-shape tests lock in
the load-bearing directives.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AdXEsWQTadb9qbTQjLkMqn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardening: set a real CSP in tauri.conf.json instead of null

2 participants