Skip to content
XSS Disclosed report Advanced

Arbitrary JS execution on ReaderView by abusing wrong HTML replacement order

In Firefox for iOS ReaderView, the page's own HTML was inserted into the template before the JSON+LD placeholder, so a page containing the placeholder text could have its JSON+LD data spliced into an attribute and execute script. An attacker could run script in the ReaderView origin and steal data from other sites, such as a Bugzilla API key.

Muneaki Nishimura Follow

Originally disclosed on Mozilla

  • Fixed in 14 days
  • Paid in 14 days
  • Disclosed after 14 days

Created attachment 9586200 fxios-reader-jsonld-xss3.html

Steps to Reproduce:

  1. Visit https://csrf.jp/2026/fxios-reader-jsonld-xss3.html
  2. Push ⚡️ button in address bar
  3. UXSS is fired and an alert dialog is shown in ReaderView domain

Root Cause: My further investigation revealed that similar but different attack vectors to Bug 2036573 still exist. The HTML escaping implemented as a countermeasure for Bug 2036573 is effective and that provides enough protection against certain types of UXSS attacks. However, there was another weakness in the order of HTML replacement in the following code. https://github.com/mozilla-mobile/firefox-ios/blob/f1bbf0923d836e9789cb9436b8ea73c3c77bd325/BrowserKit/Sources/WebEngine/WKWebview/Scripts/ReaderMode/ReaderModeUtils.swift#L27

In this code, the %READER-CONTENT% placeholder, which contains the HTML of the original page, is substituted into the ReaderView HTML template, followed by the substitution of %READER-JSONLD%. Therefore, if the original page contains the text %READER-JSONLD%, it will be replaced with the JSON+LD data extracted from the original page's header tag. The fix for Bug 2036573 escapes malicious HTML tags in the JSON+LD, but it doesn't escape double quotes “ because it must be kept due to JSON syntax.

As a result, if the original page's content contains the text <img src="/test.png?%READER-JSONLD%"> and the page JSON+LD contains {"onload=alert(document.location);&# x2F;&#x2F;“: ...}”} }, these will be concatenated in the HTML template, resulting in an XSS payload: <img src="/test.png?{"onload=alert(document.location);&#x2F;&#x2F;“”>.

This UXSS is triggered on the ReaderView's origin. The potential impact of this UXSS is as described in the comments for the previous Bug. An attacker could steal data from any other site (such as the victim's Bugzilla API key).

Expected Behavior: Since the original page's HTML can contain other placeholder strings, the %READER-CONTENT% substitution should be performed after all others. Additionally, in order to prevent such UXSS attacks, a Content Security Policy (CSP) that blocks inline script execution was previously implemented. However, it seems this commit has disabled that CSP. It would be desirable to re-enable the CSP policy. For example, a similar feature in the Brave browser uses more strict CSP.

The original report as published on Mozilla's Bugzilla, by Muneaki Nishimura. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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

The %READER-CONTENT% placeholder was substituted before %READER-JSONLD%, so page content containing the JSON+LD placeholder got the JSON+LD data spliced into it, and the earlier escaping did not cover double quotes needed for JSON syntax.

Impact

Script runs in the ReaderView origin, so an attacker could steal data from any other site, such as the victim's Bugzilla API key; the text notes a CSP that blocked inline script was previously in place but appears to have been disabled.

What the attacker needed

Firefox for iOS; victim opens attacker page; victim taps ReaderView button

The fix

The %READER-CONTENT% substitution should be performed after all other placeholders, and the inline-script-blocking CSP should be re-enabled.

How it was found

  1. Open the attacker's page in Firefox for iOS.
  2. Tap the ReaderView button in the address bar.
  3. The injected script runs in the ReaderView origin and shows an alert.

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.

ReaderView is a stripped-down reading mode built from a template. The app fills in placeholders in that template, and it filled in the page content before the page's structured data. A page could therefore smuggle the placeholder text into its own content and have attacker-controlled data land inside an HTML attribute, which the browser then runs as script.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Muneaki Nishimura

View all

74 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.