Repository navigation
security: restrict ipynb sanitizer to safe image data URIs - #8326
Merged
Merged
Conversation
The /-/api/sanitize_ipynb endpoint allowed any data URI scheme, so "data:text/html" payloads passed through the sanitizer and executed as JavaScript when the rendered notebook was appended to the DOM. Reuse markup.IsSafeDataURI, which restricts data URIs to the same image MIME types accepted by the Markdown sanitizer. Refs: GHSA-3w28-36p9-w929
unknwon
added a commit
that referenced
this pull request
Jun 7, 2026
(cherry picked from commit dd1bd98)
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
The
/-/api/sanitize_ipynbendpoint sanitized notebook HTML with a bluemonday policy that allowed anydata:URI scheme. A crafteddata:text/htmlURI passed through unchanged and executed as JavaScript when the rendered notebook was appended to the DOM during.ipynbpreview.Switch to
markup.IsSafeDataURI, the same allowlist already used by the Markdown sanitizer, which restricts data URIs to common image MIME types.Refs: GHSA-3w28-36p9-w929
Test plan
moon run gogs:lintmoon run gogs:buildgo test ./internal/markup/ ./internal/app/<a href="data:text/html,<script>alert(1)</script>">x</a>and confirm the link no longer carries the data URI.