Skip to content

Give the desktop setup window a strict Content Security Policy - #2143

Merged
davidmckayv merged 2 commits into
mainfrom
fix/desktop-strict-csp
Nov 24, 2026
Merged

davidmckayv merged 2 commits into
mainfrom
fix/desktop-strict-csp

Conversation

@jpr5

@jpr5 jpr5 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What this changes

Add a strict Content Security Policy to the bundled desktop setup page (defense-in-depth). desktop/src-tauri/tauri.conf.json had app.security.csp: null, so the page Tauri serves from ../dist ran with no policy.

default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:;
font-src 'self' data:; connect-src 'self' ipc: http://ipc.localhost; frame-src https://calendly.com;
object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none'

Each source comes from what the page loads:

  • script-src / style-src 'self': the Vite build has no inline scripts or styles (React style props go through CSSOM, which CSP allows). Tauri adds hashes for its own scripts when it serves the page.
  • img-src data: https:: the brand marks are inlined SVG data URIs (marks.ts), and the move to OpenBot Cloud shows each app's iconUrl from the app directory.
  • font-src data:: Inter is bundled. Vite emits it as files, but a build that inlines a small font as a data URI still draws.
  • connect-src: the page makes no fetch/WebSocket calls. Everything goes through invoke, so only Tauri IPC is allowed (ipc: on macOS/Linux, http://ipc.localhost on Windows).
  • frame-src: only OpenBot for Business's booking calendar (BOOKING_CALENDAR_ORIGIN).

Dev (devUrl) is unaffected. Tauri desktop loads the dev server directly. Navigations to the running OpenBot app are external URLs, which this policy doesn't cover.

Where it runs

Desktop app only: no server state, replicas, serialisation, fan-out, listeners or schedules.

Boundary and audit

No change to the gateway, refusals or client trust.

API and database

  • This changes nothing under api/, no app's requests, no database change and no release-policy.json.

Changelog

No deployment behaves differently: this only changes the policy the desktop app serves its own setup page with.

Proof

Tests are in desktop/src/setupLayout.browser.test.ts. One test asserts the configured policy (it runs in the normal suite). Two run in a real headless Chromium (CI job app (real browser, desktop setup window)): they serve the window with the policy header from tauri.conf.json and record every securitypolicyviolation.

Red (before, csp: null):

$ OPENBOT_APP_BROWSER=1 bun test src/setupLayout.browser.test.ts -t "Content Security Policy"
error: tauri.conf.json serves the window with no Content Security Policy (app.security.csp is null)
(fail) the bundled window's Content Security Policy > loads only the window's own files, its images, the IPC and the booking calendar
(fail) the window under its Content Security Policy > the first screen and OpenBot for Business's booking calendar draw with nothing refused
(fail) the window under its Content Security Policy > a script put into the page is refused
 0 pass
 3 fail

Green (after):

$ OPENBOT_APP_BROWSER=1 bun test src/setupLayout.browser.test.ts -t "Content Security Policy"
 3 pass
 0 fail
 11 expect() calls

The browser test catches real breakage. With font-src 'self' alone, the harness build reported 7 font-src data violations, which is why data: is allowed. With frame-src 'none', the booking calendar never loads and the test fails.

Also run locally:

  • biome format and lint: clean
  • bun run typecheck: clean
  • bun run build: passes
  • cargo check in src-tauri: passes
  • bun test desktop/src: 556 pass, 0 fail
  • The full setupLayout.browser.test.ts: 170 pass, 1 fail. The failure is "with scrollbars that take room, as Windows draws them…". It also fails on unchanged main on macOS, so it is not related to this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4kRRs8251kXTRWNeNywkH

The bundled setup page was served with no Content Security Policy. It now
loads scripts and styles only from its own files, images from its own files,
data URIs and https (an app's icon on the move to OpenBot Cloud), reaches the
shell only over Tauri's IPC, and frames only the OpenBot for Business booking
calendar. Nothing inline or evaluated runs, and nothing can frame the window.

The setup window's real-browser tests serve the page with that policy and
check that the first screen and the booking calendar draw with nothing
refused, and that a script put into the page is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4kRRs8251kXTRWNeNywkH
@davidmckayv
davidmckayv merged commit d06cd33 into main Nov 24, 2026
47 checks passed
@davidmckayv
davidmckayv deleted the fix/desktop-strict-csp branch November 24, 2026 19:56
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.

2 participants