Repository navigation
feat: run apps and HTML docs on a separate content origin - #15
Conversation
Apps and HTML docs ran in an opaque-origin sandbox, where localStorage,
cookies, and history.pushState throw a SecurityError ("The operation is
insecure"). Apps that route by URL or persist state crashed.
DROP_CONTENT_ORIGIN names a second hostname served by the same deployment.
It only serves a frame host page; the viewer sends each document over
postMessage, so private drops never pass through it. Apps get a real URL per
page, Drop follows in-frame navigation, and apps that frame their own pages
are relayed. Without it, an in-memory shim keeps apps from crashing.
Subdomain hardening: Better Auth cookies use the __Host- prefix on HTTPS so a
sibling subdomain can't toss them, and cookie-carrying API writes must come
from Drop's own origin.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1132c842bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| addEventListener("message", (event) => { | ||
| const message = event.data; | ||
| if (event.source !== parent || !message || message.__drop !== true || message.type !== "document" || typeof message.html !== "string") return; | ||
| document.open(); | ||
| document.write(message.html); | ||
| document.close(); |
There was a problem hiding this comment.
Reject untrusted parents before writing preview HTML
Any third-party page can iframe the content-origin host and send a __drop/document message, because the handler only checks that the sender is the immediate parent and does not validate its origin or restrict framing. The supplied HTML is then written into an unsandboxed document on the content origin, allowing attacker-controlled scripts to run there and read or exfiltrate shared localStorage/cookies and data belonging to apps the user has visited. Bind the host handshake to the Drop origin (preferably with a nonce) or prevent the host from being framed by untrusted sites before accepting documents.
Useful? React with 👍 / 👎.
…re anchor through the zoom's own mapping comark-annotate 0.2.0, with comark-zoom and comark-annotate patched to comark-plugins main plus onmax/comark-ui#25 and #15 until a release has them: the zoom puts a screenshot's notes in a column beside it, a mark and its note light up together, and the zoom's events map copies to the page and back (copyOf/originalOf). The frame runtime uses that mapping instead of its own child-index walk. A comment on a note in the zoom draws in a layer inside the notes column, which covered it on the zoom's layer, and anchors to the note on the page. 0.2.0 renamed a screenshot's `url` to `href` and `label` to `title`, and reports the old names. Published docs keep them, so the renderer reads them as the new names; the pr-evidence skill teaches the new ones. Issues are in meta.issues now. The render cache's integrity moves to 3, since the screenshot markup changed.
Why
App and HTML drops ran in an opaque-origin sandbox. In that sandbox
localStorage,sessionStorage,document.cookie, andhistory.pushStatethrow aSecurityError("The operation is insecure" in Safari/Firefox). The Lakebed landing app crashed onhistory.replaceState.What changes
DROP_CONTENT_ORIGIN(optional): a second hostname served by the same deployment, e.g.https://drop-usercontent.vitehub.dev. It answers every path with a small frame-host page and nothing else (no API, pages, or files; non-document fetches 404). The viewer frames it at the page's own URL (/,/product/) and sends the document overpostMessage, so private drops and unsaved edits never pass through that origin's server.pushState, reloads) and switches the page selector. Apps that frame their own pages get their documents relayed up through each level. Messages to and from the frame are pinned to the content origin.__Host-drop.*, so a sibling subdomain can't overwrite them (cookie tossing). This signs everyone out once on deploy./api/*must come from Drop's own origin (Sec-Fetch-Site/Origin). Same-site subdomains would otherwise get Lax cookies on no-preflight requests. Agents use bearer tokens and aren't affected..env.example, the review docs, and the skill reference.Verification
node --test test/*/*.test.mjs: 95 pass, 3 skipped (need a live server). Newtest/content-origin/runtime.test.mjscovers host routing, the write guard, detail payloads, page/URL mapping, head injection, and the opaque shim.pnpm typecheckpasses.wrangler dev, with Chromium, WebKit, and Firefox via Playwright:localStorage+replaceStatework;localStorage.🤖 Generated with Claude Code