Skip to content

Content Security Policy of micro-application pages

Status: accepted

Context

The broker served every app page with default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'. That stopped apps that need nothing from ICS but are common: a map cannot load raster tiles (img-src), vector tiles and styles (connect-src) or start the worker of MapLibre GL (blob: worker), and pages generated by agents break on inline style attributes and <style> blocks. HTML bundles, which run on a separate origin for the same reason as apps, have allowed images from any https: host and inline styles from the start.

Decision

  • Scripts stay the app's own: script-src 'self', no CDN and no inline scripts. Libraries are bundled into public/.
  • Allowed for every app: style-src 'self' 'unsafe-inline', img-src 'self' data: blob: https:, media-src 'self' data: blob: https:, font-src 'self' data:, worker-src 'self' blob:. This is what map libraries with raster tiles need.
  • Requests the script reads (fetch, XHR, WebSocket) go to the app's own origin and to the hosts the release declares in frontend.connect (up to 20 host names, optionally *. for every subdomain, served as https://<host>; no IP addresses, ports, paths or single-label names). A plan lists added and removed hosts in app_changes (area external_host), so every way out is in the version history.
  • default-src 'none', frame-ancestors 'none', base-uri 'none' and form-action 'self' stay.

Consequences

  • An image request can carry data to any host. It carries nothing of ICS: the app runs on its own registrable domain with a host-bound session, and the same holds for HTML bundles. A script can read responses only from declared hosts.
  • Handlers still have no network; frontend.connect concerns the page only.

Options considered

  • connect-src https: for every app. Simplest for authors, but any app script could send its records anywhere without a trace in the release.
  • Admin-curated host list, like trusted CDNs. Central, but an operator would have to approve every tile provider, and the app's history would not say which app talks to which host.