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.
- Fixed in 18 days
- Paid in 38 days
- Disclosed after 18 days
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.
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
- Enable the strict-dynamic preference in the browser if it is not already on.
- Open a data URL whose page sets a CSP with a nonce and 'strict-dynamic'.
- Include a marquee element carrying an inline start event handler.
- 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.