esm-integration icon indicating copy to clipboard operation
esm-integration copied to clipboard

It seems the proposal may help to run browser extensions w/o CSP wasm-unsafe-eval, WDYT?

Open bashor opened this issue 1 year ago • 3 comments

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_webassembly_execution

bashor avatar Mar 04 '24 20:03 bashor

Yes, wasm modules imported through this proposal don't need wasm-unsafe-eval.

nicolo-ribaudo avatar Mar 04 '24 21:03 nicolo-ribaudo

@nicolo-ribaudo Can you explain why this is safer than WebAssembly.compile/WebAssembly.instantiate? It seems that wasm modules imported through this proposal can import anything the importing module can. Couldn't that include data URIs which effectively allow arbitrary JavaScript code to be executed?

michaelficarra avatar May 15 '24 01:05 michaelficarra

It is not safer, however it is possible to track where they come from because they are not "just some bytes".

Similar to JS, you would be able to say "only allow running Wasm modules loaded from my own domain or example.com" (i.e. script-src 'self' https://example.com/*).

unsafe-wasm-eval is an all-or-nothing choice: if you want to be able to run WebAssembly you cannot protect yourself from accidentally running WebAssembly loaded from an untrusted source.

nicolo-ribaudo avatar May 15 '24 06:05 nicolo-ribaudo