XSS in the loading page of reading view
The loading page used by Firefox for iOS's Reader View inserted a URL parameter into the page without proper sanitisation, so an app could supply a javascript: URL. When that URL was shared into Firefox through the system share sheet, the script ran inside the reader view and could read the page's domain.
Originally disclosed on Mozilla
- Fixed in 16 months
- Paid in 10 days
- Disclosed after 16 months
Created attachment 8687148
XSS on Firefox iOS.pdf
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.58 Safari/537.36
Steps to reproduce:
The parameter %ORIGINAL-URL%" in ReaderViewLoading.html is not properly sanitized so it allows any application to set arbitrary URL.
https://github.com/mozilla/firefox-ios/blob/master/Client/Frontend/Reader/ReaderViewLoading.html#L45
It leads to inject cross application scripting attack by sending javascript: URL through UIActivityViewController.
The PoC is below.
ViewController.swift
--------------------------------------------------------------------------------
import UIKit
class ViewController: UIViewController {
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(false)
let textToShare = "PoC of Cross Application Scripting"
if let myWebsite = NSURL(string: "javascript:alert(document.domain)")
{
let objectsToShare = [textToShare, myWebsite]
let activityVC = UIActivityViewController(activityItems:
objectsToShare, applicationActivities: nil)
self.presentViewController(activityVC, animated: true,
completion: nil)
}
}
}
--------------------------------------------------------------------------------
Actual results:
The injected javascript URL is executed and an alert dialog with document.domain is shown on the read view like the attached PDF.
Expected results:
javascipt: URL should be ignored by reader view.
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 reader loading page substituted the supplied URL into the page without validating its scheme, so a javascript: URL was treated as a real link and executed.
Impact
An attacker-controlled app on the same device could run script inside Firefox's reader view, though the report only demonstrates an alert showing the domain rather than any data theft.
What the attacker needed
Malicious app installed on the device; user picks Firefox in the share sheet
The fix
The reader view should ignore javascript: URLs and only accept properly validated web URLs.
How it was found
- Build a small iOS app that shares a javascript: URL together with some text.
- Present the system share sheet from that app.
- Choose Firefox as the share target so the URL is passed to the reader loading page.
- Observe the script running in the reader view and showing the document 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.
A web page can contain a special kind of link that starts with 'javascript:' instead of 'http:'. If a page puts such a link into itself without checking it, the browser runs the code in that link as if the page had written it. Here, another app on the phone could hand Firefox a link like that through the share menu, and Firefox's reader loading page ran it.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.