carlos / platform Public

_headers: allow Content-Security-Policy, X-Content-Type-Options, Referrer-Policy, X-DNS-Prefetch-Control Feature Request open

On branch headers-security-allowlist

Equipo publishes every devbox preview with a _headers file so the preview can't be framed by other sites, can't load third-party content and leaks nothing through Referer. carlos devbox share refuses it:

line 3: header "Content-Security-Policy" is not supported yet

(internal/edge/headers.go:186; the static-headers spec, section 3.2, asks the next asker to file a discussion — this is that.) The file Equipo writes (internal/runner/thin/preview_security.go):

/*
  Content-Security-Policy: default-src 'none'; connect-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; media-src 'self'; form-action 'none'; frame-src 'none'; base-uri 'none'; object-src 'none'; frame-ancestors https://equipo.example
  X-Content-Type-Options: nosniff
  Referrer-Policy: no-referrer
  X-DNS-Prefetch-Control: off

Effect: every Equipo preview fails, on staging and production, unless the person agrees to publish it without the security headers.

Ask: add these four to headerChecks:

| Header | Value accepted | | --- | --- | | Content-Security-Policy | one or more policies; each a ;-separated list of directives, a directive a name ([a-z0-9-]) and source tokens | | X-Content-Type-Options | nosniff only | | Referrer-Policy | a comma-separated list of the eight standard policies | | X-DNS-Prefetch-Control | on or off |

Each value is the same for every visitor on a path, so they don't change what the shared cache may store (spec 4.4). The edge already sends all four on its own demo pages (demo_response.go).

I'm building this on branch static-security-headers and will post it here for review.

Branch headers-security-allowlist (1814c4e5) adds the four names to headerChecks with value checks (CSP directive names per CSP3 2.2.1, trailing ; and ,-separated policies allowed; nosniff; the eight referrer policies, fallback lists allowed; on/off). Tests: parse cases, plus Equipo's exact file served through Edge.ServeHTTP (GET and HEAD). Spec 3.2 and the anti-goals list updated. Astra: READY, no P1/P2; P3s were the spec wording (fixed) and wider 304/range/compression coverage for these four (follow-up).

Note: branch static-security-headers (e8831f81, 2026-11-19, another session) did this too and more: a 503 when a security header can't be applied, and the headers on custom error pages. It changes serveTree (census ruling needed per spec 8), was never merged, and its CI is red. This one is the narrow change; the fail-closed part can follow on its own if wanted.

The docs/site/cli.md table rows are in copy review; they'll land on this branch before merge.

Merged to main as 343a339. Release ask: please include it in the next CARLOS release (after v0.41.0). Equipo's devbox previews on staging and production can't apply their security headers until both the edge and the runner box's carlos run a release with it; Equipo now reports that plainly and offers publishing without headers meanwhile. Once the release is out, Equipo will update the runner's carlos and run a real preview to prove it, then close this.

Follow-up merged as 4bcb7e1: the four page-policy headers now also go on a site's own _redirects 404 page, so a preview can't be framed or load third-party content at a missing URL. Branch static-security-headers' fail-closed 503 was assessed and dropped (ship already refuses unusable lines; a 503 on version skew would take the whole site down). Not released.