UXSS: Origin confusion when reloading isolated data:text/html URL
A data:text/html page reached by redirect from an attacker site could reload itself and end up running in the origin of the site that linked to the attacker, rather than a blank origin. An attacker could therefore run script in the victim site's context and read its domain and, by implication, its data.
Originally disclosed on Mozilla
- Fixed in 4 days
- Paid in 19 days
- Disclosed after 4 days
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170323105023
Steps to reproduce:
- Assume http://target/ has a link to http://evil/ and a victim user clicks the link.
<a href=http://evil>link</a>
- http://evil/ redirects to data:text/html URL with Location header.
Location: data:text/html,<script>d=document.domain;if(d){alert(d)}else{location.reload()}</script>
- The page's JavaScript executes location.reload() because its origin is blank.
Actual results:
The reloaded data:text/html page runs in the context of http://target.
So, in the example above, a popup saying "target" shows up.
The test redirector is at http://ttera.lolipop.jp/.
The attack was confirmed to work on the latest version (v52.0.2 on Windows7 / MacOS 10).
Expected results:
The reloaded page should run in a blank isolated origin.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the browser kept the origin of the initiating document when reloading an isolated data: URL instead of resetting it to a blank origin.
Impact
Script from the data: URL could run in the context of the linking site, letting an attacker read that site's domain and potentially its data; the report confirms this on Firefox 52 on Windows and macOS.
What the attacker needed
Victim clicks a link on the target site; attacker controls a site that can redirect; Firefox 52 affected
The fix
The browser should be fixed so a reloaded data: URL keeps a blank, isolated origin rather than inheriting the linking page's origin.
How it was found
- The victim clicks a link on the target site that points to the attacker's site.
- The attacker's site responds with a redirect to a data:text/html URL containing script.
- The script checks document.domain; since it is blank, it calls location.reload().
- After the reload the script runs with the target site's origin and reads its domain.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Browsers give each website its own 'origin', a label that decides which pages may read each other's data. A data: page is normally treated as having no origin, so it should not be able to touch any site. Here, after the page reloaded itself, the browser wrongly gave it the origin of the site the user came from, so the attacker's script could act as that site.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.