CSP check is done against the text at the time of preparing but evaluation uses different text if updated after preparation
Categories
(Core :: DOM: Security, defect, P3)
Tracking
()
People
(Reporter: hiroshige, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: sec-low, Whiteboard: [domsecurity-backlog2])
Steps to reproduce:
Originally reported in https://github.com/whatwg/html/issues/7882.
WPT: https://github.com/web-platform-tests/wpt/pull/33903
- Load a page with a CSP policy that allows the hash of the original script text at Step 1 but forbids the hash of the updated script text at Step 3.
- Add an inline script
<script>...original text...</script>
to DOM. This triggers #prepare-a-script. - Update the text content of the script element.
- Execute the script.
(This can be done e.g. by adding stylesheets that block immediate evaluation of inline scripts.)
This is related to https://bugzilla.mozilla.org/show_bug.cgi?id=1651092, but not only the updated text was evaluated, but also the CSP check was inconsistent (done against the original text).
Actual results:
The updated script text was evaluated.
This indicates that the CSP check was done against the original text at the time of #prepare-a-script but evaluation was done using the updated text.
Expected results:
According to the spec, both the CSP check and evaluation should uses the text at the time of #prepare-a-script (source text
in https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script).
So the original text should be evaluated.
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Security' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•3 years ago
|
Description
•