Content-Security-Policy Bypass with data: URL opened in a new tab
Firefox allowed JavaScript in a data: URL opened in a new tab to execute even when the originating page had a Content-Security-Policy that should block script execution. An attacker could use this to steal cookies or perform other malicious actions.
Originally disclosed on Mozilla
- Fixed in 5 months
- Paid in 6 months
- Disclosed after 5 months
Created attachment 8859873
testcase.html
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:53.0) Gecko/20100101 Firefox/53.0
Build ID: 20170413192749
Steps to reproduce:
The Content-Security-Policy can be bypassed using a data: URL opened in a new tab.
Content-Security-Policy doesn't allow javascript execution code on the webpage which uses this security, but in Firefox, if a data: URL is loaded in a new tab, the javascript code contained into this data URL is executed and it can steal the cookie of the website (and others malicious actions).
example:
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-eval'">
<a href=" data:text/html;html,<script>alert(document.cookie);</script>">Open Me in a new tab</a>
Actual results:
The Content-Security-Policy can be bypassed if a data URL is opened into a new tab.
Expected results:
In Mozilla Firefox, if a Webpage uses the Content-Security-Policy security, javascript code shouldn't be executed with a data: URL opened in a new tab.
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 did not apply the originating page's CSP to a data: URL opened in a new tab, allowing script execution.
Impact
An attacker could steal cookies or perform other malicious actions by tricking a user into opening a data: URL in a new tab from a page with a CSP.
What the attacker needed
Victim clicks a link; page uses CSP; Firefox browser
How it was found
- Create a page with a CSP that blocks scripts.
- Add a link that opens a data: URL containing JavaScript in a new tab.
- Click the link to open the data: URL in a new tab.
- Observe that the JavaScript executes despite the CSP.
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 Content-Security-Policy (CSP) is a rule that tells the browser which scripts are allowed to run on a page. This report says that in Firefox, if a link opens a special kind of page called a data: URL in a new tab, the browser ignores the CSP and runs any script inside it. That means an attacker could trick someone into clicking a link and then steal their cookies.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.