Skip to content

Commit

Permalink
Fix XSS issue in href attribute on area tag (#5240, #5241)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed May 6, 2016
1 parent 4921c21 commit 6652367
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -13,6 +13,7 @@ CHANGELOG Roundcube Webmail
- Fix bug where contact search menu fields where always unchecked in Larry skin
- Fix autoloading of 'html' class
- Fix bug where Encrypt button appears when switching editor to HTML (#5235)
- Fix XSS issue in href attribute on area tag (#5240)

RELEASE 1.2-rc
--------------
Expand Down
2 changes: 1 addition & 1 deletion program/lib/Roundcube/rcube_washtml.php
Expand Up @@ -370,7 +370,7 @@ private function wash_uri($uri, $blocked_source = false)
*/
private function is_link_attribute($tag, $attr)
{
return $tag == 'a' && $attr == 'href';
return ($tag == 'a' || $tag == 'area') && $attr == 'href';
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/Framework/Washtml.php
Expand Up @@ -37,6 +37,23 @@ function test_href()
$this->assertRegExp('|href="http://test.com">|', $washed, "Link href with newlines (#1488940)");
}

/**
* Test XSS in area's href (#5240)
*/
function test_href_area()
{
$html = '<p><area href="data:text/html,&lt;script&gt;alert(document.cookie)&lt;/script&gt;">'
. '<area href="vbscript:alert(document.cookie)">Internet Explorer</p>'
. '<area href="javascript:alert(document.domain)" shape=default>';

$washer = new rcube_washtml;
$washed = $washer->wash($html);

$this->assertNotRegExp('/data:text/', $washed, "data:text/html in area href");
$this->assertNotRegExp('/vbscript:/', $washed, "vbscript: in area href");
$this->assertNotRegExp('/javascript:/', $washed, "javascript: in area href");
}

/**
* Test handling HTML comments
*/
Expand Down

0 comments on commit 6652367

Please sign in to comment.