Skip to content

Commit 08de250

Browse files
committed
Fix Information Disclosure vulnerability in the HTML style sanitizer
reported by somerandomdev
1 parent bfa0326 commit 08de250

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fix bug where an mbox export file could include inconsistent message delimiters (#9879)
1212
- Fix parsing of inline styles that aren't well-formatted (#9948)
1313
- Fix Cross-Site-Scripting vulnerability via SVG's animate tag
14+
- Fix Information Disclosure vulnerability in the HTML style sanitizer
1415

1516
## Release 1.6.11
1617

program/lib/Roundcube/rcube_utils.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ public static function sanitize_css_block($styles, $url_callback = null)
559559
$value .= ' url(' . $url . ')';
560560
}
561561
}
562+
} elseif (preg_match('/;.*/', $val)) {
563+
// Invalid or evil content, ignore
564+
continue;
562565
} else {
563566
// whitelist ?
564567
$value .= ' ' . $val;

tests/Framework/Utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ function test_mod_css_styles_xss()
291291
$mod = rcube_utils::mod_css_styles($style, 'rcmbody', true);
292292
$this->assertSame("#rcmbody { content: ''; color: red; }", $mod);
293293

294-
$style = "body { content: '< page: ;/style>< page: ;img src onerror=\"alert(\'hello\');\">'; color: red; }";
294+
$style = "body { content: '< page: ;/style>< page: ;img src onerror=\"alert(\\'hello\\');\">'; color: red; }";
295295
$mod = rcube_utils::mod_css_styles($style, 'rcmbody', true);
296-
$this->assertSame("#rcmbody { content: '< page: ;/style>< page: ;img src onerror=\"alert('hello');\">'; color: red; }", $mod);
296+
$this->assertSame("#rcmbody { color: red; }", $mod);
297297

298298
// Removing page: property
299299
$style = "body { page: test; color: red }";

tests/Framework/Washtml.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ function test_style_wash_xss()
312312
$washed = $washer->wash($html);
313313

314314
$this->assertTrue(strpos($washed, $exp) !== false, "Style quotes XSS issue (#1490227)");
315+
316+
$html = '<div style=\'content: "\0026quot;; background: url(//http.cat/418); content:""; width: 100%; height: 100%;\'>test</div>';
317+
318+
$washer = new \rcube_washtml();
319+
$washed = $washer->wash($html);
320+
321+
$this->assertTrue(strpos($washed, '<div x-washed="style">test</div>') !== false);
315322
}
316323

317324
/**

0 commit comments

Comments
 (0)