Skip to content

feat(os): baseline Content Security Policy - #90

Merged
m-vawter merged 3 commits into
mainfrom
feat/baseline-csp
Oct 3, 2026
Merged

m-vawter merged 3 commits into
mainfrom
feat/baseline-csp

Conversation

@xcjs

@xcjs xcjs commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Summary

Baseline Content Security Policy for the DOMinic shell, enforced by Nitro so it applies in dev and in the built server (nuxt.config.ts only).

  • script-src 'self' 'unsafe-eval' https://esm.sh https://cdn.tailwindcss.com — 'unsafe-eval' accommodates vue3-sfc-loader (ADR 0006), which evaluates agent-authored SFCs with new Function/eval; its removal is scheduled by the sandbox/vetting work in NEXT.md.
  • connect-src 'self' https://esm.sh — 'self' covers /api/chat; provider traffic is server-side per ADR 0005, so provider hosts are intentionally absent.
  • style-src 'self' 'unsafe-inline' https://cdn.tailwindcss.com — dynamic app style injection (sfc-loader addStyle) and the Tailwind Play CDN.

Closes #81.

Done when

  • baseline CSP headers shipped with every HTML response in dev and prod
  • npm run typecheck exits 0
  • a non-author approved this PR

Scope

nuxt.config.ts only (matches the issue ## Files declaration).

@xcjs xcjs self-assigned this Oct 3, 2026
@xcjs xcjs mentioned this pull request Oct 3, 2026
1 task done
@xcjs
xcjs requested a review from Sullux October 3, 2026 00:40
@xcjs xcjs mentioned this pull request Oct 3, 2026

@m-vawter m-vawter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because this stops the app from booting. The fix is one word, below.

I ran the #91 e2e suite with this branch merged, and every test timed out waiting for the desktop (window.__dominic never appears). The browser console shows why. Nuxt's own inline scripts (three per page, including the window.__NUXT__ config) are blocked with "Executing inline script violates … script-src", and then "Cannot read properties of undefined (reading 'app')". Typecheck and build can't catch this, because it only shows up at runtime.

Verified fix: add 'unsafe-inline' to script-src. With only that change the suite passes 3/3. It matches decision D1 (the baseline CSP carries 'unsafe-inline' through Phase 0). Tightening to nonces or hashes can ride with step 1.4, when the sandbox lands.

One question, not blocking: connect-src 'self' https://esm.sh also stops agent-authored apps from calling fetch() on any CORS-enabled API directly (ADR 0009's direct-first networking), and img-src 'self' data: blocks remote images in apps. If that's intended for the baseline, a line in the PR or the ADR index would help.

@xcjs

xcjs commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

Fixed in dde6ef1: script-src now includes 'unsafe-inline' (required by Nuxt's inline boot scripts, as your e2e run showed) and the config comment documents both the D1 baseline concession (nonce/hash tightening rides with sandbox work, step 1.4) and the reviewer's non-blocking point: connect-src/img-src intentionally constrain agent-authored apps' direct fetch/remote images until the sandbox work routes app networking through approved channels. Verified npm run typecheck exit 0. Re-requesting review.

@m-vawter m-vawter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at dde6ef1. script-src now carries 'unsafe-inline', and the config comment covers both the D1 concession and the connect-src/img-src intent. Thanks for writing both down.

This branch's CI predates the E2E job, so I ran main's e2e suite with this branch merged in. It passes 2/2, and the desktop boots under the new policy. I'll update the branch from main so E2E runs in this PR's checks too, then squash-merge once they're green (NEXT.md's distributed merge).

@m-vawter
m-vawter merged commit 8128a42 into main Oct 3, 2026
4 checks passed
@m-vawter m-vawter mentioned this pull request Oct 3, 2026
2 tasks done
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.

0.3 Baseline Content Security Policy

2 participants