Skip to content

encodeURI the href to prevent XSS attacks via ending the quote and adding arbitrary scripts in onmouseover/onclick#2

Open
mrooney wants to merge 1 commit intocowboy:masterfrom
mrooney:master
Open

encodeURI the href to prevent XSS attacks via ending the quote and adding arbitrary scripts in onmouseover/onclick#2
mrooney wants to merge 1 commit intocowboy:masterfrom
mrooney:master

Conversation

@mrooney
Copy link

@mrooney mrooney commented Jun 11, 2011

Without this fix, a link such as:

http://xss.com/"onmouseover=alert('XSS');//

is a vulnerability.

I don't know how to minify the code so it would need a regen of the minified code, but this addresses the issue AFAIK.

…ding arbitrary scripts in onmouseover/onclick
@jbaudanza
Copy link

The problem with this is that non-malicious links will already be properly URI encoded. Calling encodeURI will double encode them. Perhaps something like this would be more appropriate:

if (href) {
  href = href.replace('"', '%22');
}

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.

2 participants