Skip to content
XSS Disclosed report Intermediate

CSP bypass with DOM events and 'strict-dynamic'

A page protected by a Content Security Policy using 'strict-dynamic' still executed inline JavaScript attached to a DOM event handler on a marquee element. An attacker who could inject such markup into a protected page could run script despite the policy.

Andrew Follow

Originally disclosed on Mozilla

  • Fixed in 18 days
  • Paid in 38 days
  • Disclosed after 18 days
Text
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20161110030211

Steps to reproduce:

  - Enable 'strict-dynamic' if needed ("security.csp.enableStrictDynamic")
  - Open the following URL: data:text/html,<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-123' 'strict-dynamic'"><marquee onstart="alert('test')"></marquee>


Actual results:

JavaScript code "alert('test')" will be executed due to 'strict-dynamic



Expected results:

_inline_ javascript code not executed.

The original report as published on Mozilla's Bugzilla, by Andrew. 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's 'strict-dynamic' handling wrongly allowed inline event handler attributes on certain elements instead of blocking them.

What the attacker needed

Attacker can inject markup into a CSP page; browser honours strict-dynamic

How it was found

  1. Enable the strict-dynamic preference in the browser if it is not already on.
  2. Open a data URL whose page sets a CSP with a nonce and 'strict-dynamic'.
  3. Include a marquee element carrying an inline start event handler.
  4. Observe that the handler's script runs.

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 is a rule set a website sends to the browser saying which scripts may run, to limit damage if someone injects code. 'strict-dynamic' is a mode meant to trust scripts loaded by already-trusted scripts and block inline ones. Here the browser still ran an inline event handler, so the protection failed.

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 Andrew

View all

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