Skip to content

fix(redirect): Validate redirect destination URL schemes#45

Merged
karim-semmoud merged 3 commits into
mainfrom
fix/redirect-url-validation
Jun 1, 2026
Merged

fix(redirect): Validate redirect destination URL schemes#45
karim-semmoud merged 3 commits into
mainfrom
fix/redirect-url-validation

Conversation

@karim-semmoud

Copy link
Copy Markdown
Member

Summary

Adds URL scheme validation to the shared redirect helper used by menu, select, listbox, combobox, and tree-view hooks.

If server-rendered data-to / data-value (or a fallback) is user-controlled or tampered with, destinations like javascript:... or //evil.example could trigger script execution or open redirects via window.location.href, window.open, or LiveView patch / navigate.

Changes

assets/lib/redirect.ts
New exported isAllowedRedirectDestination():
Allowed: relative paths (/items, ./x, ?page=2), http:, https:
Blocked: javascript:, data:, vbscript:, protocol-relative //..., and other schemes
readDomItemRedirect() returns null for disallowed destinations (including fallback strings)
performRedirect() returns false without navigating when the destination is disallowed
assets/test/lib/redirect.test.ts
Scheme allowlist unit tests
Regression tests for blocked javascript: and // URLs in DOM parsing and redirect execution

Affected components

Any hook that calls performRedirect / readDomItemRedirect from assets/lib/redirect.ts:

Menu
Select
Listbox
Combobox
Tree view

Reject javascript, data, and protocol-relative URLs in readDomItemRedirect
and performRedirect while allowing relative paths and http(s) links.
@karim-semmoud karim-semmoud self-assigned this Jun 1, 2026
@karim-semmoud karim-semmoud merged commit eab3f5b into main Jun 1, 2026
14 checks passed
@karim-semmoud karim-semmoud deleted the fix/redirect-url-validation branch June 1, 2026 14:19
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