Skip to content

security: restrict ipynb sanitizer to safe image data URIs - #8326

Merged
unknwon merged 2 commits into
mainfrom
ghsa-3w28-36p9-w929
Jun 6, 2026
Merged

unknwon merged 2 commits into
mainfrom
ghsa-3w28-36p9-w929

Conversation

@unknwon

@unknwon unknwon commented Jun 6, 2026

Copy link
Copy Markdown
Member

Summary

The /-/api/sanitize_ipynb endpoint sanitized notebook HTML with a bluemonday policy that allowed any data: URI scheme. A crafted data:text/html URI passed through unchanged and executed as JavaScript when the rendered notebook was appended to the DOM during .ipynb preview.

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:lint
  • moon run gogs:build
  • go test ./internal/markup/ ./internal/app/
  • Manual: render a notebook containing <a href="data:text/html,<script>alert(1)</script>">x</a> and confirm the link no longer carries the data URI.

unknwon added 2 commits June 5, 2026 23:12
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 unknwon added this to the 0.14.3 milestone Jun 6, 2026
@unknwon
unknwon merged commit dd1bd98 into main Jun 6, 2026
8 checks passed
@unknwon
unknwon deleted the ghsa-3w28-36p9-w929 branch June 6, 2026 03:15
unknwon added a commit that referenced this pull request Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant