Fix protocol validation with proper security checks for extension URLs#113
Open
Fix protocol validation with proper security checks for extension URLs#113
Conversation
Replace weak .startsWith("http") validation with proper URL constructor
and protocol checking. Only allow http:// and https:// protocols,
rejecting dangerous protocols (javascript:, data:, file:, etc.).
Failed extensions are logged but don't block other extensions from loading.
Co-authored-by: Claude <noreply@anthropic.com>
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.
Description
This PR fixes critical security vulnerabilities in extension URL protocol validation by replacing weak string prefix checks with proper URL validation and protocol enforcement.
Related Issue
Addresses security issues in URL handling where weak validation could allow dangerous protocols to slip through.
Motivation and Context
Problem: The previous implementation used
.startsWith("http")validation which is insufficient because:httpx://,httpsomething://,http-evil://Solution: Implemented proper security-focused URL validation:
isValidHttpUrl()utility using URL constructor with protocol checkinghttp://andhttps://protocolsChanges Made
New Files
packages/uix-host/src/utils/url-validation.ts- Centralized URL validation utilitypackages/uix-host/src/utils/url-validation.test.ts- Comprehensive test coverage (11 tests)Modified Files
packages/uix-host/src/host.ts- Added proper URL validation inloadOneGuest()before Port creationpackages/uix-host/src/index.ts- ExportedisValidHttpUrlas public APIpackages/uix-host-react/src/components/GuestUIFrame.tsx- Added URL validation with error handlingpackages/uix-host-react/src/components/ExtensibleWrapper/UrlExtensionProvider.ts- Removed duplicate validation, imports from @adobe/uix-hostHow Has This Been Tested?
Security Improvements
.startsWith("http")check allowed bypass attemptshttp:orhttps:protocol validationTypes of changes
Checklist:
Note: Formatting/linting changes are intentionally excluded from this PR and will be handled separately.