Harden preview script CSP#409
Open
yusufm wants to merge 1 commit into
Open
Conversation
schuyler
requested changes
Jun 22, 2026
schuyler
left a comment
Owner
There was a problem hiding this comment.
Thanks for the PR, @yusufm!
Issues
- MathJax/preview network access: Tightening
connect-srcfromhttp: https:to'none'blocks all XHR/fetch from the preview, so it's worth confirming MathJax rendering and the other bundled preview libraries still work, since the prior policy granted that access explicitly.
Suggestions
- Nonce robustness: The nonce is injected into the script attribute without escaping — safe today since it's an NSUUID hex string, but a small assertion or escape would keep it sound if the generator ever changes.
- Pin the nonce contract in tests: A test asserting the CSP
nonce-…value equals the nonce on the emitted renderer scripts (and that it differs across renders) would lock in the core security property. - Changelog: A
### Securityentry under[Unreleased]would record that document-suppliedfile://preview scripts are now blocked.
Generated by Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Related to security review finding: Preview CSP allows local script execution.