The Wayback Machine - https://web.archive.org/web/20210318122510/https://github.com/WebAssembly/content-security-policy/issues/7
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

No way to use WebAssembly on Chrome without 'unsafe-eval' #7

Open
hackcasual opened this issue Feb 7, 2018 · 29 comments
Open

No way to use WebAssembly on Chrome without 'unsafe-eval' #7

hackcasual opened this issue Feb 7, 2018 · 29 comments

Comments

@hackcasual
Copy link

@hackcasual hackcasual commented Feb 7, 2018

To give a bit of background, I am a software engineer at Tableau, on our online data visualization tool. We have been targeting WebAssembly for improving visualization interactivity. As part of our security efforts, we have been working on being able to support a restrictive CSP.

Currently chrome disables compileStreaming/instantiateStreaming with CSP on and not allowing 'unsafe-eval'. Other implementations (FF/Safari/Edge) at least allow the streaming versions of the compile/instantiate commands. The 8/8/2017 meeting notes seems to indicate that Chrome is following the original straw proposal. Chrome has implemented 'wasm-eval', but restricted it to apps/extensions.

Either treating the Response object as an origin according to the given CSP or adopting 'wasm-eval' would allow us to move forward.

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Feb 8, 2018

I've put together a quick example here: https://s3.amazonaws.com/webassembly-chrome-csp/csp_test.html

@mikesamuel
Copy link

@mikesamuel mikesamuel commented Feb 8, 2018

I think the goal was for user-agents to become consistent in how they interpret unsafe-eval and wasm-eval directives. Issue #1 discussed how not to, and issue #2 touches on how to, but I'm not sure if consensus has been reached.

@eholk
Copy link
Collaborator

@eholk eholk commented Feb 13, 2018

Right now Chrome restricts 'wasm-eval' to web apps because it's not part of the CSP standard. I'm going to try to put together a PR this week to move along the process of making 'wasm-eval' standard, at which point it should be pretty straightforward for Chrome to expose 'wasm-eval' to the web.

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Feb 13, 2018

Awesome.

@eholk
Copy link
Collaborator

@eholk eholk commented Feb 16, 2018

Out of curiosity, I just tried running your test case on Safari and got:

[Error] TypeError: WebAssembly.instantiateStreaming is not a function. (In 'WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)', 'WebAssembly.instantiateStreaming' is undefined)
	Global Code (csp_test.js:3)

Does that match what you see? Based on the table on the Wasm CSP Proposal, Safari should not allow instantiate or instantiateStreaming without 'unsafe-eval'.

@jfbastien
Copy link
Member

@jfbastien jfbastien commented Feb 16, 2018

Safari currently doesn't implement streaming.

@eholk
Copy link
Collaborator

@eholk eholk commented Feb 16, 2018

I just submitted the PR for 'wasm-eval': w3c/webappsec-csp#293

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Aug 21, 2018

Has there been any movement on this? Looks like the PR has been open for over 4 months now.

@binji
Copy link
Member

@binji binji commented Aug 22, 2018

The CSP proposal stalled out as @eholk has moved on to another team. However, @titzer is starting to help out now.

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Aug 24, 2018

Awesome, thanks for pushing this forward.

@twilco
Copy link

@twilco twilco commented Sep 10, 2018

So just for the sake of clarity, the end goal here will be to create a CSP that allows WASM without allowing unsafe-eval of everything? I'm also looking at incorporating WebAssembly into my application and ran into this issue, so was hoping unsafe-eval wasn't the only way out.

Also, unrelated question: why do I not receive this warning on Firefox?

@titzer
Copy link

@titzer titzer commented Sep 17, 2018

@twilco Yes, the proposed wasm-eval (or maybe unsafe-wasm-eval) would be a separate directive that enables WASM code generation independent of JavaScript's eval.

@titzer
Copy link

@titzer titzer commented Oct 29, 2018

There's a PR #17 to rename the directive. However, for Chrome apps that use extension URLs, we'll likely keep the old directive for some transition time.

@uBlock-user
Copy link

@uBlock-user uBlock-user commented Nov 19, 2018

So has wasm-unsafe-eval been implemented in chrome and in which version ?

@titzer
Copy link

@titzer titzer commented Nov 23, 2018

Hi, we've only implemented wasm-eval (preliminary name) in Chrome for extension URLs. The new name wasm-unsafe-eval (and applying to all URLs) has not yet been implemented. Given that this proposal seems to be (slowly) iterating to a decent state, I think we can begin implementation soon.

@gorhill
Copy link

@gorhill gorhill commented Nov 23, 2018

Either treating the Response object as an origin according to the given CSP

I wish to be able to use WebAssembly from my extension -- this is already the case for the Firefox version of the extension.

However, I do not plan to use wasm-unsafe-eval if/when it becomes available, as this goes against the spirit of not executing remote code.

What is the reason Chromium can't allow loading of wasm modules from same-origin Response objects? This would solve the issue of loading/executing only same-origin wasm code (i.e. the extension's packaged files) without having to resort to relaxing the default CSP in the manifest.

@feross
Copy link

@feross feross commented Apr 2, 2019

I opened a bug on the Chromium bug tracker for implementing wasm-unsafe-eval: https://bugs.chromium.org/p/chromium/issues/detail?id=948834&can=1&q=wasm-eval Please star it if you're interested in following updates.

@robyoder
Copy link

@robyoder robyoder commented May 9, 2019

@kendraspock
Copy link

@kendraspock kendraspock commented Sep 17, 2019

Hi there - @hackcasual - I am running into this error when attempting to embed Google Street View in a dashboard in Tableau Online. I am new to coding and am curious if this conversation, particularly what you mentioned about Tableau, has to do with this error and if it's resolvable:

image

TYIA!

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Sep 24, 2019

Hi @kendraspock , that error is a direct result of this. It's a little confusing since it doesn't actually mean Chrome refused to compile the WebAssembly module, it's reporting that if CSP were enabled, it would refuse to compile the module. It's benign.

@martinberlin
Copy link

@martinberlin martinberlin commented Nov 18, 2019

I implemented successfully a compression protocol called Brotli here:
http://udpx.fasani.de
(It's an old fashioned Chrome app)
Even if wasm-eval seems to work I see that on many Web Assembly existing libraries they use eval() so that is a big restriction to use them for me right now. The funny thing is that I had to upload the binary WASM on a server just to give it back with the right CSP:

header("Content-Type: application/wasm");
header("Access-Control-Allow-Origin: *");

otherwise it won't work, but I though apps restrict scripts from remote URLs.

@FloodGames

This comment was marked as off-topic.

@brycetham
Copy link

@brycetham brycetham commented Jan 15, 2021

Has there been any update on this? Is the only way to use WebAssembly on websites on Chrome still to add 'unsafe-eval' to the CSP?

@fgmccabe
Copy link

@fgmccabe fgmccabe commented Jan 15, 2021

There has not been much progress on this in recent years.
There is an implementation of wasm-eval for chrome but it is restricted to ChromeOS at the moment.
All that being said, it is clear that the priority of this is rising and we are beginning to pick up the dusty threads :)

@Poopooracoocoo
Copy link

@Poopooracoocoo Poopooracoocoo commented Feb 5, 2021

Argghhh I really want this for Ruffle as a user.

@DHunte
Copy link

@DHunte DHunte commented Feb 14, 2021

Just encountered the same issues with firefox, edge and chrome whilst trying to use wasm generated by blazor. Its a real stumbling block in moving from local development to production. Im quite surprised that there has'nt been more progression on this front given the push behind languages to adopt WASM compilation. Also im not sure about the adoption rate of browser updates across multiple platforms and regions etc however I am concerned because I assume that when this feature does eventually release there will be an issue where any application you're trying to rollout safely will for a long period of time only be accessible by a minority of browser users.

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Feb 16, 2021

Just encountered the same issues with firefox

Surprised you encountered this in firefox, as far as I know firefox doesn't gate wasm compilation.

@hackcasual
Copy link
Author

@hackcasual hackcasual commented Feb 16, 2021

Now there is technically a way to use WASM on Chrome without unsafe-eval, as long as you can load a worker with unsafe-eval. This bypass doesn't work in Safari. Depending on your security needs, you might want to do something like per agent CSP policy

https://github.com/hackcasual/ChromeWASMCSP

@DHunte
Copy link

@DHunte DHunte commented Feb 17, 2021

Just encountered the same issues with firefox

Surprised you encountered this in firefox, as far as I know firefox doesn't gate wasm compilation.

It doesent block by default, the issue is if you deploy your application on a server with any kind of csp it seems to occur, though I suppose it's the same as enabling with a local document.

It's also unavoidable since it seems the method of using a js hash as you normally would with javascript in the csp causes it to still get blocked... And these alternative tags being discussed in the this thread when used in the csp also don't allow the execution either... In short csp equals no execution atleast in my tests (which aren't exhaustive as I mentioned).

But generally anywhere I would like to use wasm in production usually requires csps to be defined since security and reputation often are more valuable than performance gains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment