Repository navigation
Serve the file builtin:code opens as text on its raw route, not as HTML or SVG - #1609
Open
dormouse-bot wants to merge 1 commit into
Open
dormouse-bot wants to merge 1 commit into
dormouse-bot wants to merge 1 commit into
Conversation
…ML or SVG Under builtin:code the opened file's retained raw grant (file/<name>) took fileViewerFormat's MIME, so an HTML or SVG source streamed as text/html or image/svg+xml under EDITOR_CSP, which allows inline scripts and same-origin requests. It now takes the handler's format (text/plain), matching security-local.md S151: source text is never executable markup.
Deploying mouseterm with
|
| Latest commit: |
6fe1d10
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ee556f3e.mouseterm.pages.dev |
| Branch Preview URL: | https://nightly-code-editor-raw-gran.mouseterm.pages.dev |
This branch has not been deployed
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.
When
builtin:codeopens an HTML or SVG file, the viewer serves its source on the editor page's JSONsourceroute. It also keeps a raw grant on the file atfile/<name>. That raw route took its MIME type fromfileViewerFormatrather than from the handler, so the raw grant sent the file astext/htmlorimage/svg+xmlunderEDITOR_CSP, which allows inline scripts and same-originconnect-src. This PR makes the opened file take the handler's format (text/plainforbuiltin:code). The raw grant stays, but it can no longer serve markup that runs. This brings the code in line with S151, which says "source text is JSON data, never executable markup".Trigger. The editor page never loads
file/<name>: Monaco readssource. So reaching the bad response takes a navigation to that URL inside the Tool's frame. A user editing the URL would do it; nothing in the shipped UI does. If that file's script ran, it would share the editor's origin, so its save POSTs would pass the Origin check.builtin:fileis unchanged, because its handler format isfileViewerFormatitself.Fix.
registeruses the handler'sformatfor the opened file. Referenced assets still usefileViewerFormat.Verification. The
builtin:code opens Markdown, HTML, and SVG as sourcetest now asserts that the raw route answerstext/plain. It fails onmainand passes with the fix.pnpm testindor-tools-builtinandlib/src/host/file-viewer-proxy.test.tspass.