Skip to content
XSS Disclosed report Intermediate CVE-2022-26384

Sandboxed iFrame XSS - javascript URI's run with target _blank

A sandboxed iframe without allow-scripts could still execute JavaScript via a javascript: URI when the link had target="_blank". An attacker could run script in the iframe's domain, bypassing the sandbox.

Ed McManus Follow

Originally disclosed on Mozilla

  • Fixed in 2 months
  • Paid in 3 months
  • Disclosed after 2 months
Text
(Thank you Firefox developers for all your hard work! The world needs Firefox.)

I believe the following is an XSS vulnerability present in the current release channel. By specifying target="blank" you can execute javascript in the domain of a sandboxed iframe, even though allow-scripts is not specified.

This behavior is blocked by Edge, Chrome, and Safari. Demo: https://emcmanus.github.io/xss.html

Expected result:
* Sandboxed iframes should not execute JS unless `allow-scripts` is specified
* Firefox should block the `javascript:` uri
* Firefox behavior should match other browsers

Actual result:
* Javascript runs in the current domain, even though `allow-scripts` is not specified
* Edge, Safari and Chrome block this behavior
* It does not matter whether you use src or srcdoc

I believe a related bug was patched in Firefox 79: https://www.mozilla.org/en-US/security/advisories/mfsa2020-30/#CVE-2020-15653

Here is the source of the demo:
'''html
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv='content-type' content='text/html; charset=UTF-8'>
  </head>
  <body>
    <iframe sandbox="allow-same-origin allow-popups" srcdoc="<a href=&quot;javascript:alert(document.domain)&quot; target=&quot;_blank&quot;>click me</a>"></iframe>
  </body>
</html>
'''

The original report as published on Mozilla's Bugzilla, by Ed McManus. 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 execute script in the domain of a sandboxed iframe, bypassing the sandbox; other browsers block this behaviour.

What the attacker needed

Victim uses Firefox; victim clicks a link inside a sandboxed iframe

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 sandboxed iframe is a web page inside another page that is supposed to be restricted, for example not allowed to run scripts. The report shows that in Firefox, a link inside such an iframe could still run JavaScript if it opened in a new tab, which breaks the restriction.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from Mozilla

View all

The newest disclosed reports for this program.

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.