Repository navigation
feat(os): baseline Content Security Policy - #90
Conversation
m-vawter
left a comment
There was a problem hiding this comment.
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.
|
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
left a comment
There was a problem hiding this comment.
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).
Summary
Baseline Content Security Policy for the DOMinic shell, enforced by Nitro so it applies in dev and in the built server (
nuxt.config.tsonly).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 withnew 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-loaderaddStyle) and the Tailwind Play CDN.Closes #81.
Done when
npm run typecheckexits 0Scope
nuxt.config.tsonly (matches the issue## Filesdeclaration).