Skip to content
XSS Write-up Advanced

CVE-2018-5175: Universal CSP strict-dynamic bypass in Firefox

Firefox's internal require.js library was accessible from any web page due to a contentaccessible flag, and when loaded it could create a script element that bypassed CSP strict-dynamic. An attacker with an HTML injection flaw could use this to execute arbitrary JavaScript.

Unknown Follow

Published on mksben.l0.cm

The original lives on mksben.l0.cm

We do not hold its text, 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 Firefox exposed its internal require.js as a web-accessible resource without applying the page's CSP to it, and require.js's data-main feature creates a script element that strict-dynamic permits.

Impact

An attacker could execute arbitrary JavaScript on a site with strict-dynamic CSP if they also had an HTML injection flaw, bypassing the CSP protection.

What the attacker needed

Target uses CSP strict-dynamic; attacker has HTML injection flaw; victim uses Firefox

How it was found

  1. Find a target page that uses CSP with strict-dynamic and has an HTML injection flaw.
  2. Inject a script element that references Firefox's internal require.js resource.
  3. Use require.js's data-main attribute to load a data: URL containing JavaScript.
  4. The data: URL executes because require.js creates a non-parser-inserted script element, which strict-dynamic allows.

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.

Content Security Policy (CSP) is a browser rule that limits which scripts can run on a page. The 'strict-dynamic' option only allows scripts that were loaded by an already-trusted script. This report shows that Firefox's own built-in require.js file could be loaded by any page and then used to load an attacker's script, getting around that rule.

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.