fix(security): reject unsafe link schemes#130
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a shared URL-scheme allowlist for href values to prevent executable/local-file schemes from reaching client rendering, Link, and SSR attribute output.
Changes:
- Added
isSafeHref()(allowlist) for validating/sanitizinghrefvalues. - Enforced the policy in
Link, the client intrinsic attribute renderer, and SSR attribute rendering. - Added jsdom regression coverage for unsafe
hrefschemes acrossLink, client output, and SSR output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/common/url.ts |
Defines shared href scheme allowlist helper (isSafeHref). |
src/components/link.tsx |
Throws when Link receives an unsafe href. |
src/renderer/attributes.ts |
Omits unsafe href values when applying intrinsic props in the client renderer. |
src/ssr/attrs.ts |
Omits unsafe href values during SSR attribute rendering. |
tests/jsdom/renderer/unsafe-href.test.tsx |
Adds regression tests for unsafe href schemes across Link, client rendering, and SSR. |
Comments suppressed due to low confidence (2)
src/ssr/attrs.ts:188
- Same case-sensitivity issue exists in
renderAttrs()(string path):attrName === 'href'can be bypassed with mixed/upper-case keys (e.g. spread props containingHREF). This should be case-insensitive to match HTML behavior.
} else {
const strValue = String(value);
if (attrName === 'href' && !isSafeHref(strValue)) continue;
attrParts.push(` ${attrName}="${getEscapedAttrValue(strValue)}"`);
src/renderer/attributes.ts:361
applyScalarPropValue()has the same case-sensitivehrefcheck as the static path. This leaves a bypass via spread props withHREF/mixed casing, which will still be rendered ashreffor HTML elements. Make the check case-insensitive.
} else if (key === 'value' || key === 'checked') {
applyFormControlProp(el, key, value, tagName);
} else if (key === 'href' && !isSafeHref(String(value))) {
removeRenderedAttribute(el, key);
} else {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
smiggleworth
force-pushed
the
fix/security-unsafe-link-schemes
branch
from
July 26, 2026 17:54
f882d50 to
13e7157
Compare
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.
Closes #129
Rejects javascript, data, vbscript, file, and obfuscated executable href schemes across Link, client intrinsic attributes, and SSR output. Safe documented schemes and relative URLs remain supported.
Verification: