Skip to content

Commit

Permalink
Fix bug where it was possible to bypass href URI check with data:appl…
Browse files Browse the repository at this point in the history
…ication/xhtml+xml URIs (roundcube#6896)
  • Loading branch information
alecpl committed Aug 27, 2019
1 parent 554a20f commit 2348899
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ RELEASE 1.3.10
- Fix bug in converting multi-page Tiff images to Jpeg (#6824)
- Fix wrong messages order after returning to a multi-folder search result (#6836)
- Fix PHP 7.4 deprecation: implode() wrong parameter order (#6866)
- Fix security issue where it was possible to bypass the position:fixed CSS check in received messages (#6898)
- Fix bug where it was possible to bypass the position:fixed CSS check in received messages (#6898)
- Fix bug where some strict remote URIs in url() style were unintentionally blocked (#6899)
- Fix security issue where it was possible to bypass the CSS jail in HTML messages using :root pseudo-class (#6897)
- Fix bug where it was possible to bypass the CSS jail in HTML messages using :root pseudo-class (#6897)
- Fix bug where it was possible to bypass href URI check with data:application/xhtml+xml URIs (#6896)

RELEASE 1.3.9
-------------
Expand Down
2 changes: 1 addition & 1 deletion program/lib/Roundcube/rcube_washtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private function wash_attribs($node)
$out = $this->wash_uri($value, true);
}
else if ($this->is_link_attribute($node->nodeName, $key)) {
if (!preg_match('!^(javascript|vbscript|data:text)!i', $value)
if (!preg_match('!^(javascript|vbscript|data:)!i', $value)
&& preg_match('!^([a-z][a-z0-9.+-]+:|//|#).+!i', $value)
) {
$out = $value;
Expand Down
10 changes: 6 additions & 4 deletions tests/Framework/Washtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
/**
* Test the elimination of some XSS vulnerabilities
*/
function test_html_xss3()
function test_html_xss()
{
// #1488850
$html = '<p><a href="data:text/html,&lt;script&gt;alert(document.cookie)&lt;/script&gt;">Firefox</a>'
$html = '<a href="data:text/html,&lt;script&gt;alert(document.cookie)&lt;/script&gt;">Firefox</a>'
.'<a href="vbscript:alert(document.cookie)">Internet Explorer</a></p>'
.'<p><A href="data:text/html,&lt;script&gt;alert(document.cookie)&lt;/script&gt;">Firefox</a>'
.'<A HREF="vbscript:alert(document.cookie)">Internet Explorer</a></p>';
.'<A href="data:text/html,&lt;script&gt;alert(document.cookie)&lt;/script&gt;">Firefox</a>'
.'<A HREF="vbscript:alert(document.cookie)">Internet Explorer</a>'
.'<a href="data:application/xhtml+xml;base64,PGh0bW">CLICK ME</a>'; // #6896

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

$this->assertNotRegExp('/data:text/', $washed, "Remove data:text/html links");
$this->assertNotRegExp('/vbscript:/', $washed, "Remove vbscript: links");
$this->assertNotRegExp('/data:application/', $washed, "Remove data:application links");
}

/**
Expand Down

0 comments on commit 2348899

Please sign in to comment.