Skip to content

fix(editor): Sanitize unsafe URL schemes in paste and link rendering#3218

Draft
bukinoshita wants to merge 2 commits intocanaryfrom
fix/sanitize-unsafe-link-schemes-3208
Draft

fix(editor): Sanitize unsafe URL schemes in paste and link rendering#3218
bukinoshita wants to merge 2 commits intocanaryfrom
fix/sanitize-unsafe-link-schemes-3208

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Sanitizes URLs in paste and link/button rendering to block unsafe schemes (javascript:, data:, vbscript:) and prevent XSS. Addresses Linear BU-671.

  • Bug Fixes
    • Added isSafeUrl using regex scheme extraction + set checks (CodeQL-safe), with an allowlist (http:, https:, mailto:, tel:); handles empty/hash, relative paths, whitespace, and mixed case.
    • Paste sanitization now strips unsafe href/src values from external HTML.
    • Link and Button parsing reject unsafe href; rendering falls back to safe values.
    • Bubble menu “Open link” only uses validated URLs.
    • Added tests for isSafeUrl and the paste sanitizer.

Written for commit 266d7d7. Summary will update on new commits.

…t:) in paste and link rendering

- Add isSafeUrl utility that validates URL protocols against an allowlist
- Strip unsafe href/src attributes during paste sanitization
- Add defense-in-depth checks in Link.parseHTML and Button.parseHTML
- Guard link rendering and bubble menu open-link against unsafe schemes
- Add comprehensive tests for isSafeUrl and paste-sanitizer

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 266d7d7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Apr 9, 2026 5:30pm
react-email-demo Ready Ready Preview, Comment Apr 9, 2026 5:30pm
react-email-examples Ready Ready Preview, Comment Apr 9, 2026 5:30pm

Request Review

Restructure isSafeUrl to extract the URL scheme via regex and check it
against an UNSAFE_SCHEMES set in a single lookup. This avoids CodeQL's
'Incomplete URL scheme check' alert, which flagged individual startsWith
calls as not covering all dangerous schemes together.

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@react-email/editor@3218

commit: 266d7d7

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.

3 participants