Skip to content
UI spoofing Disclosed report Intermediate CVE-2021-38509

Javascript dialog remains active in window after redirect

A JavaScript dialog shown while a basic authentication prompt is displayed remains active after the page redirects to another domain. An attacker could use this to display a persistent dialog with a spoofed title, potentially tricking the user.

Ademar Nowasky Junior Follow

Originally disclosed on Mozilla

  • Fixed in 3 months
  • Paid in 4 months
  • Disclosed after 3 months
Text
Created attachment 9229216
index.html

Javascript dialog that is shown while a basic authentication dialog is displayed remains active in the window even after redirects.

When opening a new URL through window.open(), the opener is allowed to modify the about:blank document until the target URL starts loading. For pages that require basic authentication, Firefox will display the authentication dialog while remaining at about:blank.

This behavior allows the opener to append a script to that page that will show a Javascript dialog when the basic-authentication dialog is displayed. After the authentication dialog is closed, the script can redirect the page to any other domain and the Javascript dialog will remain active in that window.

Finally, the malicious code is loaded from a data URI in an Iframe, so the Javascript dialog will show "This page says" in its title instead of the URL of the attacker's page.

Passing the credentials directly to the URL (as in https://[address removed]) shows a different dialog that also works for the attack. Perhaps there are other types of dialogs that are vulnerable to this.

Video: https://youtu.be/Sk6tAGEMH4I

POC is attached.

This is similar to Bug 1313916.

Source code:

<meta charset="UTF-8">
<a href="https://jigsaw.w3.org/HTTP/Basic/" onclick="e(href); return false;">Click here</a>
<script>
function e(url){
    var x = open(url,'','width=800,height=400'); 
    var s = document.createElement('script');
    s.src = 'data:text/plain,function checkFocus(){fetch("data:,").then(()=>{document.hasFocus()?checkFocus():(alert("Arbitrary message ๐Ÿ™‚"),location.replace("https://jigsaw.w3.org"))})}document.title="Google",checkFocus();';
    setTimeout(() => {x.document.body.appendChild(s);},100);
}
</script>

The original report as published on Mozilla's Bugzilla, by Ademar Nowasky Junior. 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 display a persistent dialog with a misleading title, potentially convincing the user that the message comes from the legitimate site.

What the attacker needed

Victim clicks a link; attacker controls opener page

How it was found

  1. Open a new window to a URL that requires basic authentication.
  2. While the authentication dialog is shown, inject a script into the about:blank page that will display a JavaScript dialog.
  3. Close the authentication dialog and redirect the page to another domain.
  4. The JavaScript dialog remains active and shows a spoofed title.

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 you open a new window, the page that opened it can briefly change its content before the real site loads. If the site asks for a username and password, a pop-up can be added that stays visible even after the window goes to a different site. This could let an attacker show a fake message that looks like it comes from the new site.

What is UI spoofing?

The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.

More by Ademar Nowasky Junior

View all

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

Clickjacking and UI spoofing

The lesson behind this report.

The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.