fix(editor): Sanitize unsafe URL schemes in paste and link rendering#3218
Draft
bukinoshita wants to merge 2 commits intocanaryfrom
Draft
fix(editor): Sanitize unsafe URL schemes in paste and link rendering#3218bukinoshita wants to merge 2 commits intocanaryfrom
bukinoshita wants to merge 2 commits intocanaryfrom
Conversation
…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>
|
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
commit: |
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 by cubic
Sanitizes URLs in paste and link/button rendering to block unsafe schemes (
javascript:,data:,vbscript:) and prevent XSS. Addresses Linear BU-671.isSafeUrlusing regex scheme extraction + set checks (CodeQL-safe), with an allowlist (http:,https:,mailto:,tel:); handles empty/hash, relative paths, whitespace, and mixed case.href/srcvalues from external HTML.LinkandButtonparsing reject unsafehref; rendering falls back to safe values.isSafeUrland the paste sanitizer.Written for commit 266d7d7. Summary will update on new commits.