Passive script execution on about:reader via SVG animations (affects: Firefox, NoScript, CSP; impact: spoofing, phishing)
Originally disclosed on Mozilla
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 2 months
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0
Build ID: 20150629114848
Steps to reproduce:
Firefox offers a special mode for websites supposedly containing articles and text-heavy content that is called the "Reader View" (RV). This RV mode removes any potentially disturbing content from a website and attempts to show only the relevant details such as article headlines, article images and article body.
RV removes the ability to execute scripts (similarly to the RV offered by MS's Edge Browser). It does so by imposing a white-list on HTML content and stripping all that is not considered harmless. this includes script elements, JavaScript URIs, event handlers and more.
The RV is being deployed from a special scope, about:reader. A URL of a website opened in RV will be "about:reader?url=`escape(%website-url%)`". While the URL is deployed from the about:reader scheme, the address bar hides that scheme prefix and shows the original page URL.
My tests have shown, that this white-list is too permissive and allows for elements to pass, even though they can execute JavaScript. Here is the full test case I was using (PHP file - for CSP headers' sake):
<?php
header('Content-Security-Policy: default-src \'self\' ');
?><html>
<head>
</head>
<body>
<h1>Some Article</h1>
<article>
<h2>Some headline</h2>
<p>
<svg xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href>
<circle r="999"></circle>
<animate attributeName="xlink:href" from="javascript:alert(location)" to></animate>
</a>
</svg>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</p>
<p>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</p>
</article>
</body>
</html>
Once we load this URL from any web-origin, let's say http://example.com/test.php, the Firefox browser will show a small icon in the address bar, allowing a user to change into the RV. Once the RV is loaded, the page is shown with the customized minimal markup.
Now, the interesting part is, that a certain dangerous part of the HTML from our test case above is not being removed:
<svg xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href>
<circle r="999"></circle>
<animate attributeName="xlink:href" from="javascript:alert(location)" to></animate>
</a>
</svg>
What is shown with this test-case is a large black box (a clip of the SVG circle). Clicking this box will trigger an alert window, executing from about:reader.
Note that this happens despite CSP headers being used on the original page.
Further note that for example NoScript needs to white-list about:reader for the RV to be used at all. Once that is the case, NoScript does not prevent the script execution any much longer. This is not optimal and might require changes in both FF and NoScript to function as expected (e.g. allowing NoScript to apply the domain-trust to pages even when loaded in RV).
I was thinking about possible exploitation of this seemingly unwanted behaviour. And I think it can be exploited. let's assume the following scenario:
* An attacker injects the malicious SVG on a website
* The website uses CSP, users of modern browsers are not affected by the injection
* A user now decides to use RV and watches the injected page
* All of a sudden, the payload does work despite CSP
* Naturally, we have no true XSS here but the attacker can still do a lot
> Use document.write to eliminate all UI elements of RV
> Fill the page with arbitrary other content, like a forged login form / other phishing frenzy
The core problem here is, that, even though the page in RV is deployed from about:reader, the user cannot distinguish between RV being active or not. The attacker can influence the entirety of HTML and write whatever into the page body, while the address bar is still showing the original URL without the about:reader prefix. Despite the domain using CSP, the attacker can phish with JavaScript and exfiltrate any data the user emits. And NoScript doesn't seem to help here.
To fix the issue, I'd recommend several things:
* Fix the white-list and eliminate SVG's animate and set
* Provide a better domain-based distinction for NoScript to work as expected
* Optimize the info shown in the address bar to avoid spoofing attacks
* Don't lose security headers on the way. CSP in regular mode should also work in RV
Actual results:
see above
Expected results:
see above
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity security bug in Reader Mode. Mozilla made it public on 12 September 2015 as CVE-2015-4518.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.