-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify worker-src goals #146
Comments
BTW, if we agree with the above conclusion, then deprecating |
Another thing to consider is whether |
See #31. |
@hillbrad can correct my memory, but I believe that we broke That said, I think I agree with the underlying criticism of both this and #31 that splitting workers away from With regard to service workers, I agree that they're uniquely dangerous, but I think they're uniquely dangerous to the origin, and not to the particular page. Within the context of a single page, treating them like any other worker seems reasonable. The server should, however, have the ability to deny its resources the ability to be used as a service worker. CSP currently does this via |
Wow, that surprises me! I can see why that's the case for Shared Workers and Service Workers, but I agree with https://lists.w3.org/Archives/Public/public-web-security/2011Nov/0027.html regarding regular workers. (Maybe too late.) I would expect scripts-src by default to apply to JS modules and Also, the principle of least astonishment would lean towards all kinds of workers being restricted to the page's CSP policy, |
I would not be terribly sad if we changed the behavior for dedicated workers (@hillbrad, @dveditz, @devd, @ckerschb, @johnwilander, @teddink etc. WDYT?).
I would not be terribly sad if we moved
You say "the page", but which page do you mean? Isn't it odd for a {Service,Shared} Worker to have different behavior based on which of an origin's pages you visit first? I agree that it's something that developers have to think about, and it would be nice to relieve them of that burden, but I'm not sure that pushing a policy down to the shared resource makes sense on its own. |
Yes. It is weird that {Service, Shared} Workers aren't restricted by connect-src, and it would be weird if they were restricted by different connect-src from different pages. This is why I think |
I like the idea of having workers subject to
|
We discussed this on the webappsec call yesterday: folks seemed generally ok with moving workers to
|
Working on this in https://crbug.com/662930 Filed https://bugzilla.mozilla.org/show_bug.cgi?id=1320924, https://bugzilla.mozilla.org/show_bug.cgi?id=1320931, https://bugs.webkit.org/show_bug.cgi?id=165136, and https://bugs.webkit.org/show_bug.cgi?id=165137. @teddink: is there somewhere I ought to file bugs against Edge? |
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ and let @travisleithead know about it so you get VIP treatment. |
Based on the discussion in #146, this patch makes two substantive changes: 1. 'worker-src' now defers to 'script-src', not 'child-src'. 2. Dedicated workers now always inherit their policy from the context that created the worker. Hopefully this makes more sense, and we won't change it again in a month.
Good discussion at w3c/webappsec-csp#146 suggests that we might want to modify `worker-src` before shipping it. So let's work that out first. BUG=666664 Review-Url: https://codereview.chromium.org/2503213005 Cr-Commit-Position: refs/heads/master@{#433152} (cherry picked from commit 8071e0f) Review URL: https://codereview.chromium.org/2541443003 . Cr-Commit-Position: refs/branch-heads/2924@{#151} Cr-Branched-From: 3a87aec-refs/heads/master@{#433059}
@mikewest wrote in https://groups.google.com/a/chromium.org/d/msg/blink-dev/npKDoKVOUAs/vQtbrZ2VBAAJ:
Here's my understanding of Mike's example: The page author wants to execute a worker, which they would host on https://super-fast-and-speedy.cdn.net/all-my-script/ if HTML allowed that. But, HTML doesn't allow that, so it has to use a worker hosted on In the quoted text above, Mike proposes to solve that by having a See also whatwg/html#1243 (comment), where Mike wrote:
Like I said in the first comment in this issue, I think we should continue to work towards a world where Workers and <script> and JS6 modules are treated as uniformly as possible. I'll comment later on service workers and shared workers, but I wanted to throw this out ASAP to learn why it wouldn't work. |
Regarding workers, shared workers, and service workers, and whether the one directive or separate directives should apply to them, I think we should approach this issue as follows: First, let's stop using the names “{,shared, service} workers," because the common part of the name, “worker,” biases us towards treating them all the same. Let's instead use the names A, B, and C, respectively. Using the new names, there's nothing about A, B, and C that look similar and so I'd expect us to have a-src, b-src, and c-src in CSP. Now, let's construct an argument that A, B, and C are so similar that there's no purpose of distinguishing between them as far as CSP is concerned. Whether we succeed or fail at constructing such an argument would help us make a decision about which directives are needed to control A, B, and C. |
In addition, https://html.spec.whatwg.org/multipage/workers.html#module-worker-example, which describes using a JS6 module as a worker without the same-origin restriction, basically doing what I suggested in making JS6 modules and workers more uniform. |
Rereading this thread, I think you are making a few suggestions, @briansmith:
Is that a more or less accurate summary of your thinking? Assuming that it is, and that I haven't just set up strawmen: I agree with much of what you're claiming, but I have some concerns with the model you're proposing. Splitting out the discussion on slightly different axes, let's talk about inheritance and control: Inheritance:
Control: As I suggested above, I consider service workers uniquely dangerous, but they're dangerous to the origin, not the page. If an origin wishes to prevent service workers from being loaded, doing so on a response-by-response basis seems unlikely to be effective. A more pervasive solution is necessary, and since the ship has sailed on opt-in solutions like MIME type requirements, servers ought to take advantage of the opt-out mechanisms provided, like the I think shared workers have similar properties from a page's perspective: they have a distinct policy (assuming you accept my argument above), they have a distinct lifetime, and they're generally used for different purposes as in-page script. Given that, I think it makes sense to control both via I'm less dogmatic about |
@briansmith: Ping. :) It would be helpful to get opinions from other interested folks as well: @hillbrad, @dveditz, @devd, @ckerschb, @johnwilander, @teddink. |
FWIW by way of context. Part of the original impetus for worker-src was
that we as a group anticipated cross-origin workers were on the horizon as
a lightweight way to do mashups, like an iframe without the overhead of a
DOM. I was also hopeful for a future in which even same-origin workers
could have meaningfully less privilege than the creating page with
sandboxing, and thus might be allowed a *less* restrictive policy, and the
more trusted page could then act as a reference monitor and input sanitizer
for a very small and well-defined postMessage interface. Dangers of
predicting the future - you're usually wrong.
I tend to agree with @mikewest here. But I don't have better ideas for a
non-confusing directive name for from where to allow shared/service workers.
…On Tue, Dec 6, 2016 at 11:07 AM Mike West ***@***.***> wrote:
@briansmith <https://github.com/briansmith>: Ping. :)
It would be helpful to get opinions from other interested folks as well:
@hillbrad <https://github.com/hillbrad>, @dveditz
<https://github.com/dveditz>, @devd <https://github.com/devd>, @ckerschb
<https://github.com/ckerschb>, @johnwilander
<https://github.com/johnwilander>, @teddink <https://github.com/teddink>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#146 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACFbcPrZoJB54yLpu0R6T1Iwgqxbh9VRks5rFbJygaJpZM4KwhNR>
.
|
We have cross-origin workers with module workers, but they're CORS-same-origin. Less privileged workers would be dedicated/shared workers with an opaque origin. Those can be created with a data URL and maybe at some point through a sandbox setting. Would those nevertheless inherit policy? |
data: workers would inherit policy because there is no way to deliver them
with their own policy. Sandboxed workers wouldn't a-priori have to, but
the current proposal would say that they do.
…On Wed, Dec 7, 2016 at 8:36 AM Anne van Kesteren ***@***.***> wrote:
We have cross-origin workers with module workers, but they're
CORS-same-origin.
Less privileged workers would be dedicated/shared workers with an opaque
origin. Those can be created with a data URL and maybe at some point
through a sandbox setting. Would those nevertheless inherit policy?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#146 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACFbcMustb1fn-jyRMJbymjHVqPdLGAmks5rFuB-gaJpZM4KwhNR>
.
|
There are three scenarios here:
If we're talking about the first of these, it seems reasonable to treat them like scripts, and ensure that they execute with the same policy as the document that created them. If we're talking about the second, then it's not clear to me what we'd want to do: I can see good arguments for treating them like shared/service workers and giving them their own policy, but it's also reasonable to give the loading context some control to ensure confinement properties. For the last, I think inheriting a policy would make sense, but it might be a good scenario for @briansmith's suggestion to give the embedding context an option. All that said, I think I'd prefer to err on the side of simplicity with the model that's currently in the spec. I don't think the second option discussed above is something anyone is looking into doing, and I'm not sure that there's much value in building it in addition to something like foreign fetch (if for no other reason than the complexity of auditing existing implementations that all implicitly assume that dedicated workers are always same-origin with their owners). |
@briansmith: ping. :) |
@mikewest Thanks for adding this to Chrome. I added this to my CSP today using Chrome V58 seems to work fine now. I would like to ask a question about worker-src though. I added it as this: But wanted to ask what is better / correct usage?
Thanks. |
@briansmith: Ping! I'm planning on just closing this out with what's currently in the spec. If you disagree with that enough to argue about it more, great! If not, also great! |
Excellent! Glad we agree. cough Closing this out in 455ffe5. |
I don't know what to say beyond what I already wrote and I don't anticipate participating in this more. I am sorry to leave you hanging. |
Based on the discussion in w3c/webappsec-csp#146, we're deprecating 'child-src' and moving 'worker-src' onto 'script-src'. Intent to Ship: https://groups.google.com/a/chromium.org/d/msg/blink-dev/npKDoKVOUAs/ogtlIFmLBAAJ BUG=662930,694525 Review-Url: https://codereview.chromium.org/2533313002 Cr-Commit-Position: refs/heads/master@{#458026}
Based on the discussion in w3c/webappsec-csp#146, we're deprecating 'child-src' and moving 'worker-src' onto 'script-src'. Intent to Ship: https://groups.google.com/a/chromium.org/d/msg/blink-dev/npKDoKVOUAs/ogtlIFmLBAAJ BUG=662930,694525 Review-Url: https://codereview.chromium.org/2533313002 Cr-Commit-Position: refs/heads/master@{#458026}
Based on the discussion in w3c/webappsec-csp#146, we're dropping the distinct policy for dedicated workers; they will now always inherit the policy of their responsible document (just like every other script executing in that page's context). Intent to Ship: https://groups.google.com/a/chromium.org/d/msg/blink-dev/npKDoKVOUAs/ogtlIFmLBAAJ BUG=662930 Review-Url: https://codereview.chromium.org/2540983003 Cr-Commit-Position: refs/heads/master@{#458039}
Sorry to comment on this old issue, but I want to provide some implementer feedback.
Workers are not the same as <script> tags. Workers create a completely new global. Script elements and modules do not do this. Things like copying CSP from one global to another are weird exceptions which make it harder to get things right in the implementation. It would be much cleaner if every global got policy information from the load that created the global. So for a remote worker script load it would come from its own CSP header and for local URLs (blob:. etc) it would come from the global that created the URL. |
To reduce GetDocument() usage. As w3c/webappsec-csp#146 has already been closed and the Blink implemetation has been changed, this UseCounter is no longer needed. Bug: 878274 Change-Id: Icb55058d369b29992436229a9b971bc6f0b8f2a6 Reviewed-on: https://chromium-review.googlesource.com/c/1192303 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Cr-Commit-Position: refs/heads/master@{#614762}
Based on the discussion in w3c/webappsec-csp#146, this patch makes two substantive changes: 1. 'worker-src' now defers to 'script-src', not 'child-src'. 2. Dedicated workers now always inherit their policy from the context that created the worker. Hopefully this makes more sense, and we won't change it again in a month.
IIUC, JS6 module
import
is equivalent to injecting a<script type=module>
which should already be handled byscript-src
.It seems to me that web workers are very much like JS6 modules. So, why isn't
<script src>
used to control web workers too? What is additionally threatening about web workers that make them deserving of special treatment compared to other kinds of script? IMO, the threading issue for web workers is not a significant issue w.r.t. security and so I see no reason to treat them differently than JS6 modules.Off the top of my head, I can't identify a clear problem that would warrant shared workers getting special treatment compared to other scripts either. Do shared workers actually enable any functionality that a script can't accomplish without them? If not, it seems there's no point in treating shared workers differently from JS6 modules either.
OTOH, despite the similarity in naming, Service Workers seem quite different from web workers and shared workers. I believe Service Workers fundamentally do provide powerful functionality that can't be accomplished another way, though I could be convinced otherwise. In fact, when considering the footgun aspect, Service Workers are potentially much more dangerous than regular script. This makes me think that, regardless of whether
script-src
should affect Service Workers (#31), it makes sense to have a separate directive that allows one to block Service Workers from origins where other scripts are allowed. However, I wouldn't want to block web workers or shared workers or JS6 modules too.This makes me think that
script-src
should control JS6 modules, web workers, and shared workers. Maybe it should also affect service workers (#31). But, there should be a separate directive for controlling service workers, separate from the directive used for web workers, shared workers, and JS6 modules. And, it seems to me that a directive separate fromscript-src
isn't needed for web workers, shared workers, and JS6 modules.The text was updated successfully, but these errors were encountered: