Skip to content
XSS Write-up Advanced

CVE-2016-4758: UXSS in Safari's showModalDialog

Safari's showModalDialog resolved a relative JavaScript navigation inside the modal dialog against the parent window's base URL instead of the dialog's own URL. An attacker could set a javascript: URL as the parent page's base tag so that a victim clicking a link in the dialog ran script in the target site's origin, leaking data.

Unknown Follow

Published on mksben.l0.cm

Shortly after Liverpool winger Mohamed Salah scored his 100th goal in the English Premier League, Salah's attacking team-mate Sadio Mane was able to build on his success in the Premier League. A similar level has come as he netted for Liverpool with his 100th appearance in all competitions in his league win over…

Unknown, on mksben.l0.cm

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a permissions/ownership mistake in how WebKit handled the location variable, causing relative JavaScript navigations in a modal dialog to be resolved against the parent window's base URL rather than the dialog's document.

Impact

Visiting a maliciously crafted website could leak sensitive data by running script in the target page's origin; the bug affected desktop Safari only, since Mobile Safari lacks showModalDialog, and it was fixed in Safari 10.

What the attacker needed

Desktop Safari before version 10; victim visits attacker page; victim clicks a button in the dialog; target page uses relative JS navigation after load

The fix

It was fixed in Safari 10 by adding ownership checks around the handling of the location variable.

How it was found

  1. Open an attacker page that calls showModalDialog on a target page which navigates to a relative URL via JavaScript after load.
  2. In the modal dialog, click the button that triggers the relative JavaScript navigation.
  3. Observe that Safari resolves the navigation against the parent page's base URL instead of the dialog's URL.
  4. Set a javascript: URL in the parent page's base tag so the mis-resolved navigation executes script in the target 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 write-up has not been written yet. The Original tab links to the source.

A web page can tell the browser to open another page in a small pop-up window called a modal dialog. Normally, if that inner page uses a relative link, the browser should resolve it against the inner page's own address. Safari instead used the outer page's address, so the attacker could make the inner page load a script from the attacker's site while still being treated as the victim site. That let the attacker run code as if it belonged to the victim site, which is called cross-site scripting.

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 Unknown

View all

32 more disclosed reports, best first.

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.