Skip to content
Open redirect Disclosed report Intermediate CVE-2022-22748

Security: Origin spoof in external protocol dialogs via server-side redirect to external protocol

Firefox showed the initiating page's origin in external protocol dialogs when a server-side redirect led to an external protocol, instead of the redirecting URL's origin. An attacker could spoof the origin to make a malicious external protocol launch appear to come from a trusted site.

Alesandro Ortiz Follow

Originally disclosed on Mozilla

  • Fixed in 8 months
  • Paid in 8 months
  • Disclosed after 8 months
Text
Created attachment 9215887
spoofs-calc.mp4

VULNERABILITY DETAILS
A URL responding with a server-side redirect to an external protocol can trigger an external protocol dialog with a spoofed origin. The origin is never the redirecting URL's origin. Instead, the initiating page's origin (or precursor origin if opaque) is shown in dialogs.

For example, if a page on https://www.google[.]com contains a link (<a href="...">) to https://attacker[.]tld/redirect, and a user clicks the link, the dialog will show https://www.google[.]com as the origin instead of https://attacker[.]tld .

Similarly, if a page on https://www.google[.]com navigates the current window or new window via JavaScript (window.location or window.open()) to https://attacker[.]tld/redirect, the dialog will show https://www.google[.]com as the origin.

In effect, the behavior is the same as if the page had directly used the external protocol URL (ms-calculator:) instead of the HTTPS URL (https://attacker[.]tld/redirect).

As far as I can tell, common protections such as CSP and iframe sandboxing are bypassed in most scenarios.

No user interaction is needed if a user previously checked "Always allow {origin} to open {protocol} links" and "Always use this application to open {protocol} links" for the target origin and protocol, or if allowed via enterprise policy: https://github.com/mozilla/policy-templates/blob/master/README.md#handlers

ADDITIONAL INFO
A malicious URL could be placed in search result pages, "external link" interstitial pages, user-provided URLs in content, among many other scenarios. Most websites filter input to only allow http(s) URLs (generally to avoid javascript: URLs which are blocked by browser in server-side redirects), therefore this works as an effective bypass to spoof the origin across most websites and navigation methods.

See attached video spoof-google-search.mp4 for Google Search demo with both calc and tel PoCs. Note that I only enabled this PoC to work from my IP address for a few minutes to record the video.

External protocols in server-side redirects probably should be treated similarly to javascript: URLs in server-side redirects, which are blocked by the browser as unsafe. Otherwise, the browser could render a blank page with origin set to the server-side redirect initiator, to ensure the dialog and address bar show the correct origin and the tab doesn't have another origin's content rendered.

VERSION
Firefox Version: 87.0 Stable (Build ID 20210318103112), also repros in 89.0a1 Nightly (Build ID 20210413093459 and 20210414093129)
Operating System: Windows_NT 10.0 19042

REPRODUCTION CASE
Scenario 1: Link click
1. Navigate to https://alesandroortiz.com/security/firefox/external-protocol/spoof-links.html
2. Click either of the links

Observed: External protocol dialog shown with current page origin (https://alesandroortiz[.]com)
Expected: External protocol dialog is not shown or is shown with redirecting origin (https://aogarantiza[.]com)

Scenario 2: JavaScript redirect (window.location)
1. Navigate to https://www.google.com/url?q=https%3A%2F%2Faogarantiza.com%2Ffirefox%2Fexternal-protocol%2Fcalc.php&sa=D&sntz=1&usg=AFQjCNEoF7jt2NHEpoTRgtZbbx8F6Na1Gg

Observed: Dialog shown with spoofed origin.
Expected: Dialog shown with correct origin.

Scenario 3: Page has iframe with user-controlled src to URL responding with server-side redirect
1. Navigate to https://alesandroortiz.com/security/firefox/external-protocol/spoof-iframe-sandbox-calc.html

Observed: Dialog shown with embedding page origin (https://alesandroortiz[.]com)
Expected: Dialog shown with iframe src origin (https://aogarantiza[.]com)

Scenario 4: Attacker page with refreshing iframe with client-side redirect leading to server-side redirect
1. Navigate to https://alesandroortiz.com/security/firefox/external-protocol/spoof-iframe-src-calc.html

Observed: Dialog repeatedly shown with embedding page origin (https://alesandroortiz[.]com)
Expected: Dialog repeatedly shown with iframe src origin (https://aogarantiza[.]com)

Scenario 5: Background tab is able to show dialog on different tab, combined with refreshing iframe for repeated dialogs (the latter also demonstrated in Scenario 4 PoC)
1. Navigate to https://alesandroortiz.com/security/firefox/external-protocol/spoof-calc-diff-tab.html
2. Click "Continue to Google.com" button

Observed: Dialog is shown in the currently active tab, even if the tab is on a different origin
Expected: Dialog is only shown in tab which opened the dialog and was opened by the same origin as the current page

Scenario 6: Non-security UI bug -- Page with iframe srcdoc (sandboxed)
1. Navigate to https://alesandroortiz.com/security/firefox/external-protocol/spoof-iframe-srcdoc-calc.html
2. Observe onload PoC of second iframe, then click link in first iframe

Observed: Dialog shown with checkbox, but checkbox label is blank. Checking the box doesn't do anything, but in this case the checkbox should be hidden. For reference, the origin shown is moz-nullprincipal: which is expected behvior.
Expected: Dialog shown without checkbox.

Other scenarios in PoCs below.

You can re-test any of the app protocol PoCs after checking "Always allow..." and "Always use..." to verify the app will be launched without interaction if previously allowed.

ALL PROOF OF CONCEPTS
App protocols:
https://alesandroortiz.com/security/firefox/external-protocol/spoof-links.html
https://alesandroortiz.com/security/firefox/external-protocol/spoof-iframe-sandbox-calc.html
https://alesandroortiz.com/security/firefox/external-protocol/spoof-iframe-src-calc.html
https://alesandroortiz.com/security/firefox/external-protocol/spoof-calc-diff-tab.html

App protocols, misc:
https://alesandroortiz.com/security/firefox/external-protocol/spoof-new-tab.html

Non-security UI bug with sandbox + srcdoc behavior:
https://alesandroortiz.com/security/firefox/external-protocol/spoof-iframe-srcdoc-calc.html

Google external link demo, user click (equivalent to spoof-links.html PoC):
https://www.google.com/url?q=https://aogarantiza.com/firefox/external-protocol/calc.php

Google ~open client-side redirect demo, window.location (used in iframe PoCs to spoof Google origin):
https://www.google.com/url?q=https%3A%2F%2Faogarantiza.com%2Ffirefox%2Fexternal-protocol%2Fcalc.php&sa=D&sntz=1&usg=AFQjCNEoF7jt2NHEpoTRgtZbbx8F6Na1Gg

The automatic Google redirect links were created by creating links in Google Sites: https://sites.google.com/view/aortest1/external-protocol-poc-1-firefox

Source for HTML files attached. Source for server-side redirect URLs below:
calc.php: <?php header('Location: ms-calculator:'); ?>

CREDIT INFORMATION
Reporter credit: Alesandro Ortiz <https://AlesandroOrtiz.com>

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

Likely the browser used the initiating page's origin for the external protocol dialog instead of the origin of the URL that actually returned the redirect.

Impact

An attacker could spoof the origin in external protocol dialogs, potentially tricking users into allowing malicious protocol handlers; common protections like CSP and iframe sandboxing are bypassed in most scenarios.

What the attacker needed

Victim clicks a link or visits a page; server-side redirect to external protocol; user may need to allow protocol once

How it was found

  1. Navigate to the proof-of-concept page with links.
  2. Click either link that points to a server-side redirect to an external protocol.
  3. Observe the external protocol dialog showing the current page's origin instead of the redirecting origin.

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.

When a website tries to open an app on your computer (like a calculator or phone dialler), Firefox shows a pop-up asking for permission and displays which website is asking. This report found that if the website used a redirect, Firefox showed the wrong website name, making it look like a trusted site was asking. An attacker could trick you into allowing an app to open by pretending to be a site you trust.

What is Open redirect?

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.

More by Alesandro Ortiz

View all

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

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.