XSS on internal: privileged origin through reader mode
Brave iOS leaked a secret key (uuidKey) via the Referer header from a reader-mode loading page, and a session restore handler failed to validate URLs, allowing a javascript: URL to run on the privileged internal://local origin. An attacker could combine these to execute script on the internal origin.
Originally disclosed on HackerOne
- Disclosed after 18 months
Summary:
Brave iOS has two weaknesses described below. By combining them, XSS can be achieved on the privileged origin internal://local.
- Exposure of uuidKey through REFERER header
Reader mode in Brave has two HTML templates, Reader.html and ReaderViewLoading.html. The former template defines <meta name="referrer" content="never"> header for preventing referrer leakage, but the latter template does not. Therefore, by opening an external page through ReaderViewLoading.html, the uuidKey contained in the Reader mode page URL is leaked.
- XSS in SessionRestoreHandler
SessionRestoreHandler is used to restore a previously used tab, but it does not validate an URL to be restored. Therefore, if a javascript: URL is provided, the code is executed on the internal: domain.
Note that the first vulnerability is not reproduced on iOS 15 because WKWebView's referrer policy has been changed to hostname only. However, according to Apple's report in June 2021, more than 90% of users were using iOS 14.
Products affected:
- Brave iOS 1.32.3 and higher (include the latest Nightly) on iOS 14.x and below
Steps To Reproduce:
- Visit https://csrf.jp/brave/reader_uuid_leakage.php
- Open the page in Reader mode
- Long tap a hyperlink in the page and choose "Open in New Private Tab"
- Wait for several seconds and tap "Load original page"
- uuidKey in the reader mode URL is stolen through REFERER header
- Click an exploit URL in the page, then XSS is triggered on
internal://local
Supporting Material/References:
- xss_on_internal_origin_through_reader_mode.mov: video of the attack against the vulnerabilities
- reader_uuid_leakage.php: server-side exploit code
Impact
- Attacker can elevate privileges to
internal:origin
Attachments
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 template omitted a referrer policy, and the session restore handler did not validate the URL scheme before loading it.
Impact
An attacker could elevate privileges to the internal: origin, but the first vulnerability is not reproduced on iOS 15 due to a referrer policy change.
What the attacker needed
Brave iOS on iOS 14.x or below; Victim opens a crafted page in Reader mode; Victim interacts with links and buttons
How it was found
- Visit the provided test page.
- Open the page in Reader mode.
- Long tap a hyperlink and choose 'Open in New Private Tab'.
- Wait and tap 'Load original page'.
- The uuidKey is stolen through the Referer header.
- Click an exploit URL in the page to trigger XSS on internal://local.
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 secret key in a web address was accidentally sent to other websites when a page was opened in reader mode. Separately, a feature that restores tabs did not check what address it was restoring, so a malicious address could run code in a trusted part of the app. Together, an attacker could run their own code in a place that normally has extra privileges.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.