Skip to content
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

Consider restricting SharedArrayBuffer to same-origin usage #4920

Closed
annevk opened this issue Sep 19, 2019 · 14 comments
Closed

Consider restricting SharedArrayBuffer to same-origin usage #4920

annevk opened this issue Sep 19, 2019 · 14 comments
Labels

Comments

@annevk
Copy link
Member

annevk commented Sep 19, 2019

Currently SharedArrayBuffer is limited to an agent cluster, but can be cross-origin (though same-site and same-scheme) within that agent cluster. We should consider restricting it further so it cannot be used cross-site, so that SharedArrayBuffer does not become the new document.domain.

cc @whatwg/security

@wanderview
Copy link
Member

@dtapuska I thought you told me we did not support cross-document SharedArrayBuffer until recently (m78, etc). Is that true? Of course, @domenic tells me the WPT tests for this pass in M76. I'm just wondering if we can assume low usage due to lack of implementation.

@dtapuska
Copy link
Contributor

Because of two different code paths postMessage (MessageChannel and Window are different). It was supported on Window but not on MessageChannel I believe. Check out this WPT test link

@annevk
Copy link
Member Author

annevk commented Sep 23, 2019

This also affects the Wasm Web API: https://webassembly.github.io/spec/web-api/#serialization.

cc @littledan

@annevk
Copy link
Member Author

annevk commented Sep 24, 2019

I think it would be ideal to fix this as part of #4732 as doing this at a later stage makes rolling this out a much larger compatibility concern. Also, the sooner Chrome can roll this out the better. Is there someone investigating this? (Remember that if SharedArrayBuffer/WebAssembly.Module remains same-site deprecating/removing document.domain does not help with the goal of origin-per-process.)

@domenic
Copy link
Member

domenic commented Sep 25, 2019

I think we could do it independently (and earlier). I take it Mozilla is interested; I suspect Chrome is but it'd be best to get some confirmation. @dtapuska, can you take the lead here?

@annevk
Copy link
Member Author

annevk commented Sep 25, 2019

We would implement this to effectively make less things depend on PSL, yes. (If document.domain is used this does not shrink the boundary, but it at least would require that to be used.)

annevk added a commit that referenced this issue Sep 27, 2019
Useful for WebAssembly.Module and RTCCertificate. SharedArrayBuffer can reuse the underlying infrastructure.

Fixes #4939. Helps with #4920.
@dtapuska
Copy link
Contributor

dtapuska commented Oct 1, 2019

What is the timeline? I can add a use counter and see how many SharedArrayBuffers get transfered in SameSite vs SameOrigin cases.

@annevk
Copy link
Member Author

annevk commented Oct 2, 2019

That'd be great. Not sure about a timeline, but the longer we leave this the way it is the more likely it is we cannot change it.

@dtapuska
Copy link
Contributor

dtapuska commented Oct 3, 2019

Hmm, this is a little more complicated. Chrome doesn't serialize the origin for message ports because origin is only used in CrossDocumentMessaging

@littledan
Copy link
Contributor

@annevk I'm not sure how this affects the Wasm/Web API. Could you clarify? cc @Ms2ger

@annevk
Copy link
Member Author

annevk commented Oct 8, 2019

@littledan WebAssembly.Module has an agent cluster restriction similar to SharedArrayBuffer. Agent clusters are keyed on sites due to document.domain. It'd be good if new features are keyed on origin, despite that.

annevk added a commit that referenced this issue Oct 25, 2019
Useful for WebAssembly.Module and RTCCertificate. SharedArrayBuffer can reuse the underlying infrastructure.

Fixes #4939. Helps with #4920.
@annevk
Copy link
Member Author

annevk commented Nov 14, 2019

@dtapuska @mikewest any more thoughts here? Perhaps this could be done as Chrome transitions to COOP+COEP? Firefox could maybe also require this out of the gate given that we currently don't support it at all.

@wanderview
Copy link
Member

I don't think we've had time to add a use counter for this. It requires a bit more code than we first thought.

That being said, I think @domenic is leaning towards an explicit opt-in for origin isolation for other reasons, so making SAB same-origin may now be orthogonal to that effort. It may still be worth doing on its own, though.

aarongable pushed a commit to chromium/chromium that referenced this issue Nov 26, 2019
Add 3 use counters to track the following usages
1) Different Agent Clusters
2) Same Agent Clusters
3) Same Origin

Adds counters for whatwg/html#4920

Change-Id: Ia9aeb1afb1f355790c5dfb549f1e2459d95d98ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925218
Commit-Queue: Dave Tapuska <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: Ben Kelly <[email protected]>
Cr-Commit-Position: refs/heads/master@{#719379}
@annevk
Copy link
Member Author

annevk commented Dec 5, 2019

I think this is only worth doing if we make the document.domain setter return early at the same time, as proposed in #5122. Otherwise it's a half-measure. So duplicating this into that.

(Also, my comments about WebAssembly.Module above were wrong, it's agent cluster restriction is largely unrelated to the restrictions for SharedArrayBuffer.)

@annevk annevk closed this as completed Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants