what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Drupal 8.0.x-dev Cross Site Scripting

Drupal 8.0.x-dev Cross Site Scripting
Posted Feb 20, 2016
Authored by Rafay Baloch

Drupal version 8.0.x-dev suffers from a cross site scripting vulnerability on IE8 and older versions.

tags | exploit, xss
SHA-256 | 6033651a038afbdd206da94672f053201eacaf29cd9cdb3888fc615957ea8087

Drupal 8.0.x-dev Cross Site Scripting

Change Mirror Download
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

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close