Fix stored XSS via event handlers in user profile description#974
Open
az10b wants to merge 1 commit intoLinkStackOrg:mainfrom
Open
Fix stored XSS via event handlers in user profile description#974az10b wants to merge 1 commit intoLinkStackOrg:mainfrom
az10b wants to merge 1 commit intoLinkStackOrg:mainfrom
Conversation
strip_tags() allows <a> tags but does not remove HTML attributes,
allowing event handlers like onmouseover to pass through. The
description is rendered unescaped via {!! !!} in linkinfo.blade.php,
enabling stored XSS.
Add regex filters using word boundary matching to strip all on* event
handler attributes (both quoted and unquoted values) from the sanitized
description before saving to the database.
a6e636f to
9718b86
Compare
Author
|
Note: This PR uses regex-based stripping of $config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'a[href],p,strong,i,ul,ol,li,blockquote,h2,h3,h4');
$purifier = new \HTMLPurifier($config);
$pageDescription = $purifier->purify($request->pageDescription);This would replace the entire |
Author
|
I realize this explanation might not be that clear here is the full write up of the issue. https://github.com/az10b/security-advisories/blob/main/stored_xss_linkstack.md |
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
strip_tags()inUserController::editPage()allows<a>tags but does not strip HTML attributes, allowing JavaScript event handlers (e.g.onmouseover,onfocus,onclick) to pass through{!! !!}inlinkinfo.blade.php, enabling stored XSSon*event handler attributes (both quoted and unquoted values) before saving to the databaseSteps to reproduce
/studio/page(bypassing CKEditor) withpageDescriptionset to:/info/{link_id}— hovering the link triggers the JavaScriptTest plan
onmouseoverpayload is stripped after the fix<a>,<p>,<strong>, etc.) still workhrefattributes on<a>tags are preserved