-
Notifications
You must be signed in to change notification settings - Fork 351
Network policies should be enforced asynchronously #161
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
Comments
This is already the case for XMLHttpRequest. Workers do indeed enforce some stuff early on that we could remove there easily if implementations are on board (although the data URL restriction is not a hook Fetch exposes). If this is about workers, filing an issue against whatwg/html would be more appropriate. |
I guess the question is, is this true for the entire fetch algorithm? And does fetch enable enforcing same-origin? And would simply changing workers to use fetch and not duplicate any of the security checks that fetch does cause it to not do synchronous checks? Regarding data, blink/webkit already don't do what the workers spec says. And I've not heard any plans that they will change. My recommendation has for a long time been to make fetch have an argument for "data: inherits" vs. "data: creates a unique origin". Webkit and blink use the latter policy for If you then combine the "data: creates a unique origin" with the "require same origin" policy that workers use, you get the behavior that webkit/blink has for workers. And the policy that I'd like to make gecko use for workers. |
Fetch does enable enforcing same-origin (mode is same-origin) and fetch is asynchronous (unless told not to, of course). Workers already use fetch but workers also have synchronous checks since that is how the specification was written. I think there's various other features that do the same, e.g., WebSocket although that may not be the best example. But say, EventSource. Fetch also has the data thing as the same-origin data-URL flag so we could probably use that indeed. But again, the question is whether we can change the way the worker constructors work or not. |
Changing an API from throwing to not-throwing has generally been considered safe. Gecko is planning on making this change, in part to archive consistency since currently main-thread-workers throw but workers-in-workers fire an error event. Anyhow, sounds like this is entirely a worker issue then. |
For anyone interested in following along: whatwg/html#337 |
We should make all network policies be enforced asynchronously. Including things like CSP, mixed-content-blocking and same-origin checks.
So for example
should not throw an exception from neither the
.open
call, nor the.send
call even ifuri
violates CSP policies for the page. Instead we should treat the error as a network error.There's a few reasons for this.
One example where synchronous errors are required is step 5 in:
https://html.spec.whatwg.org/multipage/workers.html#dom-worker
One problem there might simply be that workers need to integrate with the fetch spec.
The text was updated successfully, but these errors were encountered: