docs(wasm): say what csp the rendered output needs - #718
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b34e1e483d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
andiwand
force-pushed
the
docs/wasm-csp
branch
from
August 20, 2026 12:29
5a0d01b to
a759864
Compare
"Self-contained" is true of the markup but not of what a page may load: a frame inherits the embedding page's policy, so the embedder's CSP governs the rendered document, and nothing said what that has to allow. The failures are quiet — under `font-src 'self'` a pdf's `data:` fonts are blocked, and because they carry the code points the text is painted with, every glyph comes out as a replacement box instead of falling back to a system face. Measured across an odt, ods, docx and pdf rendered through the package: `font-src data:`, `img-src data:`, `style-src 'unsafe-inline'` (blocks and, more to the point, hundreds of `style` attributes, which a nonce cannot cover) and `script-src 'unsafe-inline'`. Nothing is fetched from another origin. Closes #710 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XDs5aK3ZGSZsEvqUUwBBXU
Recommending it without qualification was one-sided: it permits `javascript:` urls too, and a document may carry one — odrcore filters a pdf link action down to an allowlist of navigable schemes, but an odt or docx hyperlink is only attribute-escaped. In a `blob:` frame, which is same-origin with the embedder by design, such a link runs with the embedder's origin. The section now says so, and gives the way out for untrusted input: `sandbox="allow-scripts"` without `allow-same-origin`, which keeps the renderer's own scripts working inside the frame and gives up the `contentWindow.odr` API. It also records why hashes or a nonce are not an option here — `embed_shipped_resources`, which would leave no inline script at all, is not bound in the wasm build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XDs5aK3ZGSZsEvqUUwBBXU
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015d5RcmsA777vwXiuafjx6k
andiwand
force-pushed
the
docs/wasm-csp
branch
from
August 20, 2026 12:33
a759864 to
e4e6976
Compare
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.
🤖 Generated with Claude Code
Closes #710.
wasm/README.mdsaid the rendered html is self-contained and can go straight into ablob:iframe. That is true of the markup, but not of what the page is allowed to load: a frame inherits the embedding page's Content-Security-Policy, so the embedder's policy governs the rendered document — and nothing said what it has to allow.The failures are quiet. Under
font-src 'self'a pdf'sdata:fonts are all blocked, and because a pdf's text is painted with the code points its embedded subset defines, the glyphs do not fall back to a system face — every one comes out as a replacement box. Office formats embed images rather than fonts, which makes it easy to conclude the embed works.Measured, not assumed
Rendered an odt, ods, docx, odp, csv, a standalone image and a pdf through the package and counted what the output carries:
@font-face(data:)<img src="data:"><style>style=attributes<script>about.odtstyle-various-1.docxcomment.odsstyle-various-1.odpstyle-various-1.pdffantastic-landscape.jpgWhich confirms the issue's table, and adds two things it did not name:
style-srccannot be narrowed to a nonce or a hash — most of the styling isstyleattributes, and only'unsafe-inline'(or'unsafe-hashes') covers those.media-srcpointing at wherever the resource was written.Also: nothing is fetched from another origin, so no host ever has to be allow-listed — worth stating, since that is the property the library is meant to have.
The new section gives a working policy, says which part of the output each directive is for, and calls out that a blocked inline script is silent (the layout is css, so the document still looks right while search, editing and the spreadsheet behaviour simply do not run). The
blob:iframe paragraph in Use now points at it.Docs only — no code changes. Independent of #709, which covers the
script-srcthe module itself needs at load time and touches a different part of the file.