Universal CSP strict-dynamic bypass via require.js of browser resource
A Firefox internal resource URL serving a bundled require.js could be loaded by any web page, and because it is a browser resource it bypassed the page's strict CSP. An attacker could use it to run script on a site that relies on strict-dynamic, defeating the protection.
Originally disclosed on Mozilla
- Fixed in 27 days
- Paid in 2 months
- Disclosed after 27 days
Created attachment 8944629
csp_bypass_require.html
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Build ID: 20180122220231
Steps to reproduce:
The URLs located in `resource://devtools-client-jsonview/.*` bypass CSP. ( maybe intentionally )
A `require.js` file is in the this directory and it can be used for CSP strict-dynamic bypass against any websites.
Steps to reproduce:
1. Go to attached PoC( csp_bypass_require.html ). This page has strict CSP rules:
<meta http-equiv="Content-Security-Policy" content="default-src 'none';script-src 'nonce-random' 'strict-dynamic'">
2. However, you can see `alert(1)`. It is executed from the following code:
<script data-main='data:,alert(1)'></script>
<script src="resource://devtools-client-jsonview/lib/require.js"></script>
Actual results:
CSP strict-dynamic is bypassed via browser resources.
Expected results:
CSP strict-dynamic should not be bypassed via browser resources.
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 treated its own resource:// scripts as trusted for CSP purposes, so a page could load a bundled loader script and have it execute attacker-supplied code.
What the attacker needed
Victim uses Firefox; attacker can get script onto the page
How it was found
- Open the proof-of-concept page that sets a strict CSP with a nonce and strict-dynamic.
- Observe that the page still executes script despite the policy.
- The script comes from a data-main attribute plus the browser's bundled require.js resource.
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 a website sets to tell the browser which scripts it may run. The 'strict-dynamic' setting is meant to stop attackers injecting their own scripts. This report shows that a script file shipped inside the Firefox browser itself could be loaded by a page and used to run attacker code, so the rule was not enforced as intended.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.