-
Notifications
You must be signed in to change notification settings - Fork 78
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
Minimal specification of 'wasm-unsafe-eval' source directive #293
Conversation
Also mention newWebAssembly.Module()
Why may?
What's the migration story for sites already using wasm-eval? |
Also, why no unsafe prefix? |
A few thoughts:
|
If it didn't disallow WebAssembly, WebAssembly would be introducing a hole in an otherwise "secure" system, no? |
@annevk Fyi, WebAssembly/content-security-policy#1 discusses ways to enable WebAssembly without introducing CSP bypasses. |
@mikesamuel I had seen that, but I figured that any insecure outcome would not be accepted anyway. Basically, anything that involves networking or executing code needs to be guarded by CSP, which I think aligns with your and @eholk's understanding. |
@annevk Great. Yeah, I think eholk and I are on the same page. |
For your first two bullets, my reason for that was that so far WebKit and Chromium have made different calls on whether That said, I agree that having the same behavior is better. I probably didn't state my last paragraph well. The plan is that when using As far as why we want 'wasm-eval', one use case would be to enable client-side generation of a Wasm module that could then be instantiated and run. Developers may want to allow this without buying into all of |
@annevk -
I see |
Will there be a separate PR for that? Since it doesn't go through Fetch it's not actually guarded by CSP automatically and you can create synthetic |
I thought part of the point of the Fetch API and As far as having another PR, I'd say yes, if it's needed. It may be that all the desired behaviors fall out of the rest of the Web APIs naturally (I'm not intimately familiar with Fetch and CSP just yet to say for sure). |
@eholk you cannot fake the URL of a |
eholk@ I think Response is currently spec'ed in a way that would make it forgeable, but the past assumption has been that we could taint track Response objects to correct this. Separating out wasm-eval vs how streaming is handled seems to make sense, unless folks want insist, as:
Other folks here, does mikesamuel's description capture the common consensus on how to think about CSP's threat model? |
Apologies for the wall of text and the likely typos here and there: ===CSP Thread model=== Regarding the CSP threat model you will probably not get a general consensus. I have only came in contact with it about half a year ago so my opinion might have less weight than some people that have been there on the first draft but this is what I think and I am open to corrections and additions: CSP was initially designed to give authors control over what will be loaded onto their document. Because the mechanism by which CSP does this is usually request/response blocking (but it's not limited to requests see It seems that we are now at a point were people's expectation of CSP is that it's a catch-all mechanism that has as a goal to give you control over every aspect of a document's content AND communication. === This is even more of a personal opinion then the previous paragraphs but I believe the purpose of ===patch feedback=== Regarding this patch specifically:
You also would need some hook into another spec to actually enforce this. I'm not sure how this would look like for WebAssembly but you can look at the https://w3c.github.io/webappsec-csp/#integrations section for example as how the fetch/html spec calls functions in CSP to determine if an action should be blocked. If WebAssembly already relies on https://tc39.github.io/ecma262/#sec-hostensurecancompilestrings then we already have a hook for |
@flagxor I think we should resolve the |
FWIW it seems reasonable to me to do this in two steps:
BTW the spec for causing all the WebAssembly.* methods to throw will need to be in the WebAssembly spec, but it should call out to the CSP spec to determine whether or not to throw. See for example:
You'll use something different than HostEnsureCanCompileStrings/EnsureCSPDoesNotBlockStringCompilation; probably HostEnsureCanCompileWebAssembly(callerRealm, calleeRealm) for now, and maybe add a Response parameter for step 2. But this kind of architecture makes sense to me, instead of trying to put normative requirements on Wasm implementations from a non-wasm spec. The section you're editing in this PR is meant to just be a statement of facts about normative requirements enforced elsewhere in the platform; by itself it doesn't impose any requirements. |
What is the status of this PR? Due to the rising popularity of WebAssembly we're seeing applications which want to use WASM but are otherwise free from eval()-like code; under the status quo such applications would need to add Having something like the proposed |
See WebAssembly/content-security-policy#15 for your bikeshed, which roughly matches mine. |
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206}
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206}
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206}
… wasm-eval, a=testonly Automatic update from web-platform-tests [CSP] Added new policy violation source: wasm-eval This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206} -- wpt-commits: 6ccfe6fafab233ee6063b7bfeabb107ad847a205 wpt-pr: 31041
… wasm-eval, a=testonly Automatic update from web-platform-tests [CSP] Added new policy violation source: wasm-eval This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206} -- wpt-commits: 6ccfe6fafab233ee6063b7bfeabb107ad847a205 wpt-pr: 31041
Thanks. This is now fully tested in WPT. I believe it is fine to merge now. |
Thanks!
(This is me jumping up and down saying "Finally!")
Francis
…On Sun, Oct 17, 2021 at 11:15 PM Antonio Sartori ***@***.***> wrote:
Merged #293 <#293> into main.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#293 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQAXUG7B4BDGPCI5FG5BCTUHO3QRANCNFSM4EREHWSA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
Francis McCabe
SWE
|
Nice work @fgmccabe! |
Is the current status of this proposal that |
Yes to the first part of your question. |
How to enable it via feature flags? Cannot find it in |
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206}
I am not certain. However, I believe that |
RE #14: For Chrome/Edge 96, you must use chrome://flags to enable experimental web platform features. For Chrome/Edge 97 (going to stable the first week of January), the feature is enabled by default. Commit 1562a148... initially landed in 97.0.4675.0 |
For anyone trying this in a Chrome extension with Chrome 97+: you need to set |
why is script-src: 'self' not sufficient for wasm? |
This extends the suite of policy violation sources to include a WebAssembly specific source: wasm-eval. This has also been reflected in the PR (w3c/webappsec-csp#293 (review)) against the CSP spec. Added test for proper security violation event of the right form. Bug: 948834 Change-Id: I0b76fd725136b7ddda92e629f147f5ba77c50ffb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3197842 Commit-Queue: Francis McCabe <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Antonio Sartori <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: David Tseng <[email protected]> Cr-Commit-Position: refs/heads/main@{#931206} NOKEYCHECK=True GitOrigin-RevId: d476b181f81d3ab5926ae76cd051bdc989a692a8
This adds the
'wasm-eval'
source as an allowed option for thescript-source
directive.This is a minimal specification that allows WebAssembly with CSP without requiring
'unsafe-eval'
(although'unsafe-eval'
effectively impllies'wasm-eval'
to maintain current behavior).Implementations are required to gate
WebAssembly.instantiate
, and may choose to gatenew WebAssembly.Module
andWebAssembly.compile
. This is done to support the existing behavior among browsers.Note that this does not address
WebAssembly.compileStreaming
andWebAssembly.instantiateStreaming
. The plan is to spec the behavior around these APIs at a later time.Preview | Diff