Skip to content

Harden Leaf's document delivery policy - #326

Merged
max-sixty merged 3 commits into
mainfrom
codex/harden-page-csp
Sep 6, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/harden-page-csp

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

Leaf's CSP constrained fetches but still allowed a document or same-origin package to replace the base URL, submit a form to another origin, or place an ordinary live page in an outside frame. This change adds base-uri 'none' and form-action 'none' to the canonical document policy, and ordinary HTML responses now add frame-ancestors 'none' at the delivery boundary. Historical pages receive the current policy when served. The product site's Worker applies the same framing policy to static HTML assets, while the process-scoped MCP page server omits it because the approved MCP App host is its intended parent.

The authored scaffold, examples, generated corpus, and validation reference now share that policy. Server and browser coverage exercises current and historical routes, standalone exports, website examples, and the MCP transport.

The full local nightly run also exposed stale gate coverage: the static product-site projection had dropped thread anchors, the media focus ring was unreachable from the corpus, and several coverage checks had drifted from the runtime. Those are aligned here. After merging current main, the focus-ring sweep caught the new gloss ring crossing a table edge; its two-pixel band now draws inside the gloss box.

Checks:

  • uv run pytest tests — 888 passed
  • pre-commit run --all-files
  • focused live/export CSP and product-site browser checks — 2 passed
  • complete focus-ring browser walk — 685 stops, passed
  • Worker tests and TypeScript check — 9 passed
  • complete Wrangler/container deploy dry-run — 1,919 assets

This was written by Codex on behalf of max-sixty

# Conflicts:
#	tests/test_render_controls.py
#	tests/test_render_export.py

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One gap in the framing half of the policy: the product site's own delivery path never adds the header, so the claim the new reference section makes isn't true of leaf.page itself. Detail inline.

The rest reads clean. supervised_document already rebuilt the meta from PAGE_CSP, so historical revisions inheriting today's directives is a docstring correction rather than a behaviour change, and the round-trip test that rewrites r2 back to the old policy (renaming the file so the content digest still matches) proves it at the route. base-uri/form-action reach nothing the layer uses — no <base> anywhere in the runtime or corpus, and the only <form> is the MCP App's own document, which is outside PAGE_CSP. The docs/session.js thread anchor now matches what served_state/conversation.py puts on the wire, which is what living-margin.js reads.

@max-sixty
max-sixty merged commit d20e59d into main Sep 6, 2026
13 checks passed
@max-sixty
max-sixty deleted the codex/harden-page-csp branch September 6, 2026 01:59
leaf-agent added a commit that referenced this pull request Sep 6, 2026
Main added lf-drawing and lf-conversation to the document-level class
allowlist in #326, with a comment covering both. Merging this branch
left a second copy of each, which ruff's duplicate-member check fails
on. Keep main's block and drop this branch's now-redundant entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants