servo: Missing CSP checks for most JS evaluation entrypoints
Our script-related CSP checks currently only fire for eval() and other dynamic JS execution tools, according to the SpiderMonkey documentation.
We need some explicit CSP checks in code that evaluates JS scripts:, <script module>`, event listener attributes, javascript: URLs):
<script>: https://github.com/servo/servo/blob/a0730d7154e183a9b2d9a9282061e6c67d87a263/components/script/dom/htmlscriptelement.rs#L1061<script module>: https://github.com/servo/servo/blob/a0730d7154e183a9b2d9a9282061e6c67d87a263/components/script/script_module.rs#L456- event listener attributes: https://github.com/servo/servo/blob/a0730d7154e183a9b2d9a9282061e6c67d87a263/components/script/dom/eventtarget.rs#L568
- javascript: URLs: https://github.com/servo/servo/blob/a0730d7154e183a9b2d9a9282061e6c67d87a263/components/script/script_thread.rs#L3342
Tested by https://github.com/servo/servo/tree/main/tests/wpt/tests/content-security-policy/script-src .
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 21 (21 by maintainers)
Commits related to this issue
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Add CSP and Trusted Types for tracking For https://github.com/servo/servo/issues/36258 and https://github.com/servo/servo/issues/36437 Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.gith... — committed to TimvdLippe/internal-wpt-dashboard by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers This also ensures that document now reports all violations and we set the correct directive. Part of #36437 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Check CSP for inline event handlers (#36510) This also ensures that document now reports all violations and we set the correct directive. With these changes, all `script-src-attr-elem` WPT tests pas... — committed to servo/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
- Support CSP report-only header This turned out to be a full rabbit hole. The new header is parsed in the new `parse_csp_list_from_metadata` which sets `disposition` to `report. I was testing this wi... — committed to TimvdLippe/servo by TimvdLippe 2 years ago
All right, since both Trusted Types and CSP have very similar testing requirements, things are a bit mixed.
new Workerto handle the correct headers and introduces a new methodGlobalScope::parse_csp_list_from_metadatacsp-report-onlyheader to fix reporting CSP and Trusted Types testsI think I can tackle these while working on the Trusted Types integration for these attributes.
We currently pass 133 out of 147 tests in script-src. Unfortunately the remaining tests either rely on
SharedWorker, or I don’t really know how to tackle them. As an example, https://wpt.fyi/results/content-security-policy/script-src/javascript-window-open-blocked.html?product=servo I don’t understand why that would be failing, given the rest already handlesjavascript:in a straightforward manner.Assuming that, can you unassign me from this issue or close it as resolved? If you do have any more pointers, do let me know.
I have come to realise after yesterday’s debugging session that to me the iframe machinery are a big mystery. I don’t understand yet why they are different and why they don’t use the other network code I have come to touch. Do you mind doing another debugging session like you did with
FetchTaskTargetto figure out the missing spots? If we can hook up the policy container, then I think I can continue from there to implement the rest of the feature.