Closed Bug 1863788 (CVE-2024-26282) Opened 2 years ago Closed 2 years ago

Potential UXSS through <link rel=canonical> on Firefox for iOS

Categories

(Firefox for iOS :: General, defect)

defect

Tracking

()

VERIFIED FIXED
Tracking Status
fxios 123 ---

People

(Reporter: sdna.muneaki.nishimura, Assigned: lmarceau, NeedInfo)

References

()

Details

(Keywords: csectype-sop, reporter-external, sec-moderate, Whiteboard: [reporter-external] [client-bounty-form] [verif?])

Attachments

(3 files)

When the current URL starts with /amp, Firefox for iOS recognizes an URL indicated by <liink rel=canonical> as the current page URL.
https://github.com/mozilla-mobile/firefox-ios/blob/e8a99cadf78ecb15db98609a702704480fbc4182/Client/Frontend/UserContent/UserScripts/MainFrame/AtDocumentEnd/MetadataHelper.js#L21

Also, when the page is bookmarked, the URL specified in the <link rel=canonical> is added instead of the current URL.
https://github.com/mozilla-mobile/firefox-ios/blob/7b798d538aedb8e17040c049fcc7715fcfb47e38/Client/Frontend/Browser/BrowserViewController/BrowserViewController%2BKeyCommands.swift#L45

Then, Firefox doesn't validate given canonical URL, so any scheme URL can be added to the bookmark.

Thus, if an attacker specifies a javascript: scheme URL, it's possible to execute JavaScript on any site opened at the time by opening the bookmarked page. These is a potential for UXSS.

Flags: sec-bounty?
Group: firefox-core-security → mobile-core-security
Component: Security → General
Product: Firefox → Firefox for iOS

It seems that this bug could be resolved by validating the <link rel=canonical> URL scheme in the following code.
https://github.com/mozilla-mobile/firefox-ios/blob/8821dca58c62cc6c2485f9fce82606f926b0c0cb/Client/Frontend/UserContent/UserScripts/MainFrame/AtDocumentEnd/MetadataHelper.js#L25

An example of the validation code is below.

try {
  const canonicalUrl = new URL(canonicalHref, location);
  if (canonicalUrl.protocol.match(/^https?:$/)) {
    metadata.url = canonicalHref;
  }
} catch(error) {
}

need to re-rate this: the malicious page can't force the victim to create the bookmark nor use the bookmark. The consequences for the user if they do so might be severe, but this issue is more of a "booby-trap" that will only hit a fraction of the people it's aimed at.

The severity field is not set for this bug.
:jeevans, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jeevans)
Attached file GitHub Pull Request
Assignee: nobody → lmarceau
Group: mobile-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

Laurie: will this fix be in v123 ? Please set the version field as appropriate

Flags: needinfo?(lmarceau)
Flags: sec-bounty? → sec-bounty+
Flags: needinfo?(lmarceau)

Verified as fixed on v123 (38400) with iPhone 15 Pro (17.1.2).

Please note that I did the following steps:

  • Opened Firefox
  • Accessed csrf.jp/uxss.php
  • Added the csrf.jp/uxss.php as a bookmark.
  • Accessed bookmark sections and opened csrf.jp/uxss.php
    The loading bar page was just displayed again (like a refresh) but there was no internal://local uxss prompt displayed anymore.

Muneaki Nishimura if you can please confirm that this is the behavior we want to see I would appreciate it.

Status: RESOLVED → VERIFIED
Flags: needinfo?(sdna.muneaki.nishimura)

Thanks for your confirmation. When you check your bookmarks and that URL is https://csrf.jp/amp/uxss.php, this is the expected behavior. I have also confirmed that it is fixed in the master branch.

Flags: needinfo?(sdna.muneaki.nishimura)
Alias: CVE-2024-26282
Attached file advisory.txt
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: