New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 767195 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac , Fuchsia
Pri: 2
Type: Bug-Security



Sign in to add a comment

Dedicated worker does not inherit creator’s policy.

Reported by s.h.h.n....@gmail.com, Sep 20 2017

Issue description

UserAgent: 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:
 

Comment 1 by palmer@chromium.org, Sep 20 2017

Cc: kinuko@chromium.org lgar...@chromium.org a...@google.com mkwst@chromium.org
Components: 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)
Hmm, this seems tricky; I'm not sure what the right behavior is. The worker, worker.js, does obey the policy, right? The fact that it's implemented in terms of `importScripts` is tangential? I'll defer to the Worker and CSP experts.

Comment 2 by a...@google.com, Sep 20 2017

I'm having trouble accessing the PoC, can you paste/attach the relevant code? Thanks!
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!");

Comment 4 by a...@google.com, 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

Comment 5 by palmer@chromium.org, Sep 20 2017

Status: WontFix (was: Assigned)
#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.

Comment 6 by mkwst@chromium.org, 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`.
Project Member

Comment 7 by sheriffbot@chromium.org, Dec 28 2017

Labels: -Restrict-View-SecurityTeam allpublic
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