Restrict component links to http and https URLs - #402
Merged
Conversation
The status page wrote a component link into the anchor exactly as stored, and the API accepted any string for it, so a value such as javascript:alert(1) reached the href. Validate the field as url:http,https on create and update, matching the rule the Filament form already applies, and render the anchor through a formattedLink accessor that returns nothing for a link stored earlier with another scheme.
jbrooksuk
approved these changes
Jul 31, 2026
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.
What
A component
linkis written into the status page anchor as it was stored (resources/views/components/component.blade.php:11), and the API accepts any string for it ('link' => ['string'],src/Data/Requests/Component/CreateComponentRequestData.php:30and the update equivalent). A value such asjavascript:alert(1)therefore ends up inhref, where Blade escaping does not help, because the value is a syntactically valid attribute; only the scheme is the problem.Why
The Filament form already restricts the field with
->url()(src/Filament/Resources/Components/ComponentResource.php:60), so the same expectation is missing on the API and MCP paths that share the request data. Those paths are authorised by thecomponents.managetoken ability, so any holder of a component-managing token can store the value, and every visitor of the status page then receives the anchor.How
linkis validated asurl:http,httpson create and update, which matches what the form has always allowed and is stricter than a bareurlrule (Laravel's default protocol list covers about 250 schemes).Component::formattedLink()returns the link only when it is an http or https URL, and the status page anchor uses that accessor. Values stored before this change stay in the database and render as plain component names instead of links, which is the same shape asformattedDescription()for the Markdown fix in23adbb88.linkattribute, since an API consumer is not an HTML context, and the column is not rewritten by a migration.Behaviour change
A component whose link is not an http or https URL loses its anchor on the status page, and updating such a component through the API now fails validation until the link is corrected or cleared.
Testing
PHP 8.3.30 in a container, dependencies from
composer update, assets fromnpm ciandnpm run build, workbench prepared withcomposer build.composer test:unit: 954 passed, 2 todos, 0 failed.composer test:lint(Pint): PASS.vendor/bin/phpstan analyse: no errors.tests/Feature/Api/ComponentTest.phpcovers the rejectedjavascript:link and an accepted https link;tests/Feature/StatusPage/StatusPageTest.phpcovers a storedjavascript:link rendering without an anchor and an https link still rendering one. The two negative cases fail onmainat78b41c4, the two positive ones pass on both sides.References
GHSA-8jf8-9272-94v7 (reported privately, in triage)