Skip to content

Rely on arocapi's sandbox headers instead of Caddy's CSP #58

Closed

Description

@johnf

Parent

#52

What to build

arocapi 5 now sends its own Content-Security-Policy (sandbox) and nosniff on delivered crate files, deliberately leaving audio and video out because Chrome won't play media opened directly under a CSP. Caddy's own, weaker sandbox CSP on everything under /api/* duplicates that and puts a CSP back on media. Drop Caddy's CSP on /api/* and rely on arocapi's headers; Caddy's global security headers stay. Rewrite ldacapi's ADR 0002 context to state the decision as it now stands: arocapi sandboxes delivered bytes but not media, which still justifies the separate admin origin. Add a one-line comment saying why CORS is registered only in the /api scope (to keep CORS headers off /oauth and /admin), so nobody moves it to the root as arocapi's docs suggest.

Ships on the one #52 branch and PR, as its own commit. See #52 for the decisions behind it.

Acceptance criteria

  • Before removing Caddy's CSP, confirm arocapi's CSP and nosniff reach the client through Caddy
  • Caddy no longer sets a CSP on /api/*
  • Manual check recorded in the PR: on a deploy, a crate's HTML file is sandboxed by arocapi's header, and an audio file opened directly plays in Chrome
  • ADR 0002's context reflects arocapi's sandboxing and the media exemption
  • The CORS registration has a terse comment saying why it is scoped to /api

Blocked by

None (can start immediately)

Activity

  1. johnf commented on Nov 4, 2026

    @johnf
    CollaboratorAuthor

    Implemented in #63. A local caddy:2 run with the new Caddyfile in front of a stub passed arocapi's CSP and nosniff through unchanged, with no CSP on audio. Still open: the check on a real deploy (HTML sandboxed, audio opened directly plays in Chrome).

  2. johnf commented on Nov 4, 2026

    @johnf
    CollaboratorAuthor

    Checked on a local deploy rather than the production host. The setup:

    Headers through Caddy:

    • HTML: content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox (a single CSP, none added by Caddy), plus x-content-type-options: nosniff.
    • Audio: nosniff, and no CSP.

    In Chrome:

    • HTML: the page's script was blocked ("Blocked script execution … because the document's frame is sandboxed and the 'allow-scripts' permission is not set"), and the page's origin was null.
    • Audio: opened directly, it played in Chrome's media player with no error (readyState 4, currentTime 1.36 s of 2 s).

    All acceptance criteria met.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions