From 6652367d656de7e5f404935be04e10aa281add53 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 6 May 2016 08:28:15 +0200 Subject: [PATCH] Fix XSS issue in href attribute on area tag (#5240, #5241) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_washtml.php | 2 +- tests/Framework/Washtml.php | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 32a402cb0a1..2ae4e8daa29 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 -------------- diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php index 5938d9b8748..d03f04af4f5 100644 --- a/program/lib/Roundcube/rcube_washtml.php +++ b/program/lib/Roundcube/rcube_washtml.php @@ -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'; } /** diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php index 9515f0d7ab8..2e681791c19 100644 --- a/tests/Framework/Washtml.php +++ b/tests/Framework/Washtml.php @@ -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 = '

' + . 'Internet Explorer

' + . ''; + + $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 */