Drupal version 8.0.x-dev suffers from a cross site scripting vulnerability on IE8 and older versions.
6033651a038afbdd206da94672f053201eacaf29cd9cdb3888fc615957ea8087
DOM Based XSS with ` character on IE8 and older versions
IMPORTANT: this issue has been cleared for public discussion and resolution by the Drupal Security Team based on the low evidence of vulnerable browsers still existing.
Problem/Motivation
filter_xss does not filter out the accent grave ` character. This opens up an m-XSS (mutation-XSS) vector in some versions of IE7/8, which treats ` as a delimiter character, and we can escape out of a valid attribute, since it does not put double quotes when it's returned via innerHTML property.
This is rated "Critical" because it's XSS that can easily be triggered by a non-privileged user.
Proof of concept:
<html>
<head>
</head>
<div id="a"><input value="``onmouseover=alert(1)"></div>
<div id="b"></div>
<script>b.innerHTML=a.innerHTML</script>
</html>
Attacker's Input:
``onmouseover=alert(1)
Vulnerable Browser’s Output:
<div id="a"><input value=``onmouseover=alert(1)></div>
Patched Browser’s Output:
<div id="a"><input value="``onmouseover=alert(1)"></div>
Damien Tournoud was able to find that Drupal core’s autocomplete.js is a place where this vulnerability could be exploited, in anything that builds HTML autocomplete snippets (Entity Reference, for example):
$(this.ariaLive).html($(this.selected).html());
This bug was confirmed by grendzy on IE8 version 8.0.7601.17514 (windows 7) in December of 2013. According to Wikipedia, this is the latest stable release of IE8.
However, Pere Orga (June 2015) was unable to reproduce it in IE 8.0.6001.18702 (xp) (though could in IE 7.0.5730.13 (xp)). He was testing with browserstack, which for some reason only offers IE 8.0.6001.19600 on Windows 7 (this version should only be available in XP given the "6001" part of the version number).
Mario Heiderich, the author of http://www.slideshare.net/x00mario/the-innerhtml-apocalypse, claims on slide 28 that a patch is out for IE 8, but this hasn’t been able to be confirmed by the Drupal security team.
Proposed resolution
pwolanin notes that the paper at https://cure53.de/fp170.pdf seems to suggest a couple server-side and one client-side fix in section 5. David_Rothstein also noted that "Dealing with it in JavaScript seems like a good backup (maybe for situations where text is filtered without calling filter_xss(), like https://www.drupal.org/project/wysiwyg_filter?). But I think we need to fix it server-side in filter_xss() also."
A client-side fix is available by grendzy. While not a fix for direct calls to .innerHTML, it works by overriding jQuery.html() with a version that replaces ` with "`" for IE 8, and should meet most of core/contrib’s use cases. Note however that this direction still needs work; it was tested and found not to fix the issue. (It also has a stray console.log() but that’s pretty minor.)
A server-side fix is available by pwolanin, based on the HTMLPurifier library. This works by adding a new _filter_xss_ie8_fix_attr_value(&$string) function (called from _filter_xss_attributes()) that triggers IE8 to quote properly in the presence of a ` character. This was tested and found to work.
Remaining tasks
Need someone to test in actual IE 8 / Windows 7 to see if bug has in fact been patched.
get the client-side version working, add tests for the server-side version, back port both to D6.
API changes
Possibly, depending on the route taken. See "Proposed resolution."
Original report by Rafay Baloch
Rafay Baloch posted Dec 2 to security:
While testing your XSS filter function i found that, you are not filtering out the accent grave which has known problems with IE8.
https://api.drupal.org/api/drupal/modules%21filter%21filter.module/funct...
The issue occurs inside of internet explorer only because treats accent grave ` as a delimiter character, and we can escape out of a valid attribute inside of an un-patched IE 8, since it does not put double quotes around our vector when it's returned via innerHTML property.
=============
Proof of concept
=============
Here is the POC that came by slightly modifying the following example at html5sec.org#59.
The POC was tested in Internet explorer version 8:
<html>
<head>
</head>
<div id="a"><input value="``onmouseover=alert(1)"></div>
<div id="b"></div>
<script>b.innerHTML=a.innerHTML</script>
</html>
Attacker's Input:
``onmouseover=alert(1)
Vulnerable Browsers Output:
<div id="a"><input value=``onmouseover=alert(1)></div>
Patched Browsers Output:
<div id="a"><input value="``onmouseover=alert(1)"></div>
When the above POC is tested inside of an unpatched Internet explorer 8, it was noticed that IE 8 does not places quotes around it when it's rendered by innerHTML property. However, When placed in a patched version of internet explorer, it places double quotes around when the string is returned back to the user, hence stopping the attack.
===
Fix
===
Currently, I am not aware of any other solutions then stripping out the accent grave character, encoding doesn't seems to solve the problem here.
==========
References
==========
http://html5sec.org/#59
http://www.slideshare.net/x00mario/the-innerhtml-apocalypse
https://cure53.de/fp170.pdf
--
Warm Regards,
Rafay Baloch
http://rafayhackingarticles.net
http://techlotips.com