Apps

The site policy

Every built site carries one Content-Security-Policy. This page says what it holds, how it reaches a visitor on each host, and what it does not do. The claim is limited, and the limits below are part of it.

The claim. On a host that sends the header, the page's resources, the requests its scripts make and its form posts go only to origins the site declares. Navigation of the page itself (a link, location.href⁠) is not restricted by any policy a browser supports, so it is not restricted here. A form post is covered, by form-action⁠.

What the policy holds

One text, written by the compiler for the whole site. It starts from nothing allowed and opens each kind of resource to the site itself and to the origins the site declares:

  • default-src 'none'⁠.

  • script-src⁠: only the hashes of the scripts the site runs, and 'wasm-unsafe-eval' when a page of the site runs a WebAssembly effect. No 'self'⁠, no 'unsafe-inline'⁠, no 'strict-dynamic'⁠. Every inline script, every _culm/ file (live, navigation, islands, the GPU host, the tool script _culm/agent.js⁠), every island module and every frame document's script is listed by hash, and each _culm/ tag carries an integrity that matches. The tool script is one more hashed file; it adds no directive.

  • style-src 'unsafe-inline'⁠. See "Styles" below.

  • img-src⁠: 'self'⁠, data:⁠, either https: (see "Images") or the origins in origins.img⁠, and the asset origin when a host serves the site's files from elsewhere.

  • font-src and media-src⁠: 'self'⁠, and that asset origin.

  • frame-src⁠: the embed providers the site uses, otherwise 'none'⁠.

  • connect-src⁠: the declared backends, plus 'self' when the site has navigation: "swap" (the pages fetch each other); otherwise 'none'⁠.

  • form-action⁠: 'self' or the origin a form posts to, plus the declared backends.

  • worker-src⁠: blob: when any page of the site needs the GPU worker (the policy is one text for the whole site, so every page gets it); otherwise 'none'⁠.

  • base-uri 'none' and object-src 'none'⁠.

The header form adds frame-ancestors 'self'⁠, and

report-uri <backend>/csp-report

when a backend is declared with reports: true⁠. A <meta> cannot carry either.

The policy is written first in every page as a <meta>⁠, and for hosts that read one as a header, from the same function (⁠sitePolicy⁠, with policyHeader adding the two header-only parts). A test asserts that every page's <meta> holds the site's one policy text.

How it reaches a visitor, by host

The host goes in culm.json as "host"⁠: netlify⁠, cloudflare⁠, vercel⁠, firebase⁠, github-pages or other⁠. With no host key the build behaves as for other⁠.

  • _headers is written for every host, with the policy for every path (on github-pages too, where nothing reads it). Netlify and Cloudflare Pages read it.

  • vercel.json is written as well when the host is vercel⁠, and firebase.json when it is firebase⁠, each with the same header for every path.

  • github-pages cannot send a header. Its build reports the policy as meta-only⁠: the visitor gets the <meta> in each page and nothing else. A <meta> policy ignores frame-ancestors and report-uri⁠, so on that host nothing stops another site framing yours and no violation reports are sent.

  • other⁠, and no host at all, are treated as a host that reads _headers⁠. Culm cannot know whether yours does. If it does not, you are in the meta-only case without being told.

culm build says which of the two applies when it finishes. A host that sends its own Content-Security-Policy header in addition does not replace this one: the browser applies every policy it is sent, so the result can only be narrower.

Limits

These are stated, not tested away.

Navigation is not restricted

No policy browsers support can stop a link, a redirect or location.href = …⁠. A script that can run can send the visitor, and what it knows, elsewhere by navigating (a URL can carry data). The policy limits what the page loads and sends in the background; it does not limit where the visitor can be sent. Treat any code you let run on a page as able to do this.

Styles: 'unsafe-inline'

style-src allows inline styles because the compiler writes style attributes itself (the background of a hero, the margin of an icon, the paint of every shape). A policy with no inline style would break the pages Culm writes. Scripts stay hash-only. An injected style is therefore not stopped by this policy; an injected script is. This was a plan decision, recorded with its evidence in limits.md, not an owner ruling.

Images stay open until you declare them

With no origins key in site.json⁠, img-src keeps https:⁠: a remote image keeps working, and so does a script that makes an image request to any https address (an image request is a way to send a short message out). Once origins.img is declared, only those origins are listed (and the poster origin of each embed provider the site uses), and the build refuses a remote image outside them with a POLICY_VIOLATION⁠. Declare origins.img for any site that holds sign-in. An agent cannot declare it: setOrigins is refused by the default guard (see mcp.md).

The policy is per build

The hashes are the build's. A page from another build has hashes this document's policy does not list. So when you redeploy while a visitor has a tab open, the in-place navigation script compares the policy of the page it fetched with the one it holds, finds them different, and does a full page load instead of a swap. Nothing breaks; the visitor gets an ordinary page load. The same rule means a swap can never add a script the current policy does not allow.

What is checked in a browser, and where

Every claim above that depends on browser behaviour was measured in Chromium only (a driver on the repository's own DevTools code, with no playwright). Safari and Firefox have not been run on the hash-only script-src with integrity⁠, on import() against that policy, or on policy inheritance by srcdoc frames. Until someone does, treat those as Chromium results. This is an open item for the owner and is also listed in limits.md.

What the policy does not cover

  • It does not stop a script that is allowed to run from doing what scripts do within the page: reading the page, its storage and its form fields, and sending what it reads to a declared origin. That is why an island from a package runs in a sandboxed frame by default (see islands.md).

  • It does not stop WebRTC, which has no directive. It is open from a framed island: measured in Chromium with the test driver's two flags dropped, and not run in Safari or Firefox. The test driver launches Chromium with two flags that hide it (see islands.md and limits.md).

  • It is not a replacement for a backend that checks the key. The page is public; see live-data.md.

What a person does

  • Set host in culm.json⁠.

  • Declare origins.img once the site has sign-in.

  • Deploy _headers (and vercel.json or firebase.json⁠) with the site, and look at the response header of a deployed page. A <meta> in the page is not proof that the header is sent.

  • Redeploy knowing that open tabs will load in full once.

Previous

Live data

Edit this page on GitHub