Skip to content
XSS Disclosed report Intermediate CVE-2017-7823

allow-same-origin capability always granted in CSP sandbox directive

A web page using the CSP sandbox directive without the allow-same-origin flag still executed script with the page's original origin, allowing an attacker to run JavaScript in the victim's origin. The reporter demonstrated this by injecting an SVG with an onload handler that triggered an alert showing the document domain.

Jun Follow

Originally disclosed on Mozilla

  • Fixed in 5 days
  • Paid in 9 days
  • Disclosed after 5 days
Text
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36

Steps to reproduce:

1. Go to https://test.shhnjk.com/allow-scripts.php?xss=%3Csvg%20onload=alert(document.domain)%3E
2. You will see alert with document.domain


Actual results:

alert with document.domain


Expected results:

Firefox should grant opaque origin to document when CSP sandbox doesn't have allow-same-origin flag. Currently, "Content-Security-Policy: sandbox allow-scripts" is enough to execute script with origin.

https://www.w3.org/TR/CSP2/#directive-sandbox
"The sandbox directive allows any resource, framed or not, to ask for the same sorts of restrictions to be applied to itself."

The original report as published on Mozilla's Bugzilla, by Jun. 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 failed to apply an opaque origin when the CSP sandbox directive lacked the allow-same-origin flag, so scripts ran with the original origin.

Impact

An attacker could execute script in the victim's origin despite the sandbox, potentially leading to cross-site scripting or data theft.

What the attacker needed

Victim visits a crafted page; page uses CSP sandbox without allow-same-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.

A website can use a security rule called CSP sandbox to make a page behave as if it is in a restricted box, similar to how a browser isolates untrusted content. One part of that rule, allow-same-origin, decides whether the page keeps its normal identity (origin). The report says that even without that part, the page still kept its identity and could run script, which defeats the purpose of the sandbox.

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 Jun

View all

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

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.