Skip to content

Conversation

alexcjohnson
Copy link
Collaborator

Fixes an XSS vulnerability in links defined with the special popup attribute. See the added test case for three variants that were previously able to exploit it.

The fix here constructs the onclick handler in a safer way: it re-extracts href and target from the element attributes, and it restricts the characters allowed in the popup (strWindowFeatures) attribute since we know there's only so much that can be used there.

cc @etpinard @scjody - this bug came in with #1783 which was included in v1.28.0

@etpinard etpinard added status: reviewable bug something broken labels Jul 17, 2017
dummyAnchor.href = href;
if(PROTOCOLS.indexOf(dummyAnchor.protocol) !== -1) {
nodeSpec.href = href;
nodeSpec.href = encodeURI(href);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I couldn't identify any vulnerability due to not calling encodeURI here - quotes and other special characters embedded in href still can't break you out of the href attribute (while constructing the onclick string or otherwise) to where you can cause more damage - but it makes strange items look more url-like.

Copy link

@scjody scjody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 LGTM

@alexcjohnson alexcjohnson merged commit e3eba8a into master Jul 18, 2017
@alexcjohnson alexcjohnson deleted the popup-fix branch July 18, 2017 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants