Bug 27405 - [XSSAuditor] URL encoded ampersand can be used to bypass XSSAuditor
Summary: [XSSAuditor] URL encoded ampersand can be used to bypass XSSAuditor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://webblaze.org/dbates/xsstest.ph...
Keywords: XSSAuditor
Depends on:
Blocks:
 
Reported: 2009-07-17 22:52 PDT by Daniel Bates
Modified: 2009-07-17 23:20 PDT (History)
2 users (show)

See Also:


Attachments
Patch with tests (4.91 KB, patch)
2009-07-17 22:56 PDT, Daniel Bates
abarth: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2009-07-17 22:52:46 PDT
When decoding HTML entities (XSSAuditor::decodeHTMLEntities), the ampersand is removed and the supposed entity is consumed. If the entity turns out to be invalid, such as an unknown named entity, then a null-character is inserted into the decoded result, which creates a discrepancy between the script code and the HTTP parameters.

Consider:

Inline Event Handler:
http://webblaze.org/dbates/xsstest.php?q=%3Ca%20href='http://www.webblaze.org'%20onclick='alert(/%26XSS/)'%3EClick%3C/a%3E

JavaScript Link:
http://webblaze.org/dbates/xsstest.php?q=%3Ca%20href=javascript:alert(/%26XSS/)%3EClick%3C/a%3E
Comment 1 Daniel Bates 2009-07-17 22:56:28 PDT
Created attachment 33007 [details]
Patch with tests
Comment 2 Adam Barth 2009-07-17 23:12:18 PDT
Comment on attachment 33007 [details]
Patch with tests

Yes.
Comment 3 Adam Barth 2009-07-17 23:20:25 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	LayoutTests/ChangeLog
	A	LayoutTests/http/tests/security/xssAuditor/javascript-link-ampersand-expected.txt
	A	LayoutTests/http/tests/security/xssAuditor/javascript-link-ampersand.html
	A	LayoutTests/http/tests/security/xssAuditor/link-onclick-ampersand-expected.txt
	A	LayoutTests/http/tests/security/xssAuditor/link-onclick-ampersand.html
	M	WebCore/ChangeLog
	M	WebCore/page/XSSAuditor.cpp
Committed r46086
	M	WebCore/ChangeLog
	M	WebCore/page/XSSAuditor.cpp
	A	LayoutTests/http/tests/security/xssAuditor/link-onclick-ampersand-expected.txt
	A	LayoutTests/http/tests/security/xssAuditor/link-onclick-ampersand.html
	A	LayoutTests/http/tests/security/xssAuditor/javascript-link-ampersand-expected.txt
	A	LayoutTests/http/tests/security/xssAuditor/javascript-link-ampersand.html
	M	LayoutTests/ChangeLog
r46086 = 209a4aa2f77640ff10c4bb3e541c94cc9ee1a53d (trunk)
No changes between current HEAD and refs/remotes/trunk
Resetting to the latest refs/remotes/trunk
http://trac.webkit.org/changeset/46086