[codex] Harden preview script boundaries#384
Conversation
|
Thanks for this — the layered CSP + bridge-token approach is the right shape, and catching the pre-existing One correctness issue that needs addressing before merge: the checkbox token lives in Simplest fix: mint the token once (e.g., lazily on first render) and stop rotating per-render — a 122-bit UUID per document is plenty given the CSP already blocks document scripts from reading the meta tag. Alternatives are updating the meta tag inside the DOM-replacement JS, or moving the tag into Would also be great to add a document-level test that renders twice, then invokes A couple of smaller notes: Thanks again! Generated by Claude Code |
|
Addressed the token-desync review comment in 9b03a22. The checkbox bridge token is now minted once and kept stable across DOM-only preview refreshes, and I added document-level tests covering both accepted and rejected tokenized checkbox toggles. I also added a short code comment explaining the current / CSP allowances. Validation is current on this branch. |
|
Addressed the token-desync review comment in The checkbox bridge token is now minted once and kept stable across DOM-only preview refreshes, and I added document-level tests covering both accepted and rejected tokenized checkbox toggles. I also added a short code comment explaining the current Validation is current on this branch: |
|
Thanks for turning this around so quickly — the mint-once token, the CSP caveat comment, and the document-level tests for both the accept and reject paths are exactly what was needed. Merging now. Generated by Claude Code |
What changed
This PR hardens the main app preview against document-supplied script execution.
x-macdown-checkboxbridge and keeps it stable across DOM-only preview refreshesWhy it changed
The preview currently renders Markdown into a live WebView and injects body content directly into the DOM. That makes the preview an active execution surface for attacker-controlled HTML/JS. The checkbox bridge was also callable by any preview script because it trusted every
x-macdown-checkbox://toggle/...navigation.This patch contains the first hardening slice by constraining which scripts can execute in the preview and by making the checkbox bridge non-forgeable from static document content.
Related to #security-review
Impact
Validation
xcodebuild test -workspace "MacDown 3000.xcworkspace" -scheme MacDown -destination 'platform=macOS'854tests passed,0failures