Hello,
I'm really excited about the prospect of using WASM within our Chrome extension, specifically from within the background page. As a proof of concept I have the WebAssembly Studio fibannoci.wasm demo[1] configured in a sample extension and it's working fine after updating manifest.json to include `wasm-eval` in the CSP:
> "content_security_policy": "script-src 'self' 'wasm-eval'; object-src 'self'"
This is great but I'm not overly happy about including `wasm-eval` as in theory it would allow for arbitrary code execution. Along with the WebAssembly CSP spec recently renaming `wasm-eval` to `wasm-unsafe-eval`[2], I'm nervous about including this directive within our extension.
I'm wondering if my worry is founded, however, as I'm having troubles imagining how an attacker could exploit `wasm-eval`. It seems to launch a successful exploit, an attacker would depend on `unsafe-eval` in order to inject their malicious code, which is something we would definitely NOT be including. And since our code will only ever load WASM files from within the extension folder (i.e. no remote downloading of code), these local files couldn't be tampered with by attackers as Chrome would detect the extension's code signature is no longer valid.
Assuming we avoid "unsafe-eval" and we only ever load WASM code from within the extension itself, is it safe to use `wasm-eval`? Are there other best practices we could be following to be even more defensive when using WASM?
By the way, it would be awesome if Chrome supported using SRI (sha256-*) hashes in the script-src. That would allay all these fears as we could calculate the sha during the build phase and ensure that only our code is ever ran. Unfortunately I couldn't get this to work. I created a sample project[3] that demonstrates the issue and opened issue 945121[4] to see about adding support for this if anyone is interested in more details.
Thanks!
++dave;