-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Chrome Extension Manifest v3 refuses to evaulate unsafe-eval / wasm-unsafe-eval #3098
Comments
That looks to me like the generated bindings for Do you have the full stack trace of the error? That should show what crate is calling |
@Liamolucko Thanks for the quick reply! It didn't provide the entire stack trace, but I was able to get about 2000 lines: wasm-stack-trace-error-line-23562.zip (I just realized after uploading the error is actually on line 501 in that file) I'll look into what's needed to get a more complete stack trace... |
Okay, figured it out. This should provide a more complete set of information: Let me know if there's anything else I can provide that might help! |
Could you compile your code with debug symbols enabled? That should make the stack trace show Rust function names instead of the byte addresses it's currently showing. (So, instead of You mentioned you're using |
Ah! Right, good point. I'm actually using wasm-pack's npm publish capability. I'll set it to import from a local path. Here you go, I just zipped the pkg directory, all that code is open source anyway: Also, here's the contents of the new line exception in the JS file (I've realized the line numbers in the browser and the JS files don't always match):
|
You're probably running into this which means that in your context you won't be able to use |
I managed to get the debug symbols working (thank you for providing the link to the repo!) and it turns out that it's coming from this line in a very old version of the now-deprecated That's being depended on by |
Holy cow, that's awesome, thanks a ton, @Liamolucko ! You gotta tell me how you got proper debug symbols working!? 🙏 |
The debug symbols get stripped when [package.metadata.wasm-pack.profile.release]
# default is ["-O"]; -g means to preserve debug symbols.
wasm-opt = ["-O", "-g"] |
Aha! Thank you very much! Also, thanks for chiming in, @alexcrichton. Your stewardship of all your work is appreciated. Closing this now. |
Describe the Bug
In a Chrome Extension using the new Manifest v3 format, using more recent versions of Chrome (97+?),
wasm-unsafe-eval
is supposed to be used as the content security policy for calling wasm methods. It seems to work in some cases, but it still catches some wasm-bidgen generated calls as violating ordinaryunsafe-eval
rules. For example:Error
Uncaught (in promise) EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval'".
Stack Trace
Steps to Reproduce
Expected Behavior
The Chrome extension should be able to execute the wasm bundle without triggering an unsafe-eval exception.
Actual Behavior
Additional Context
If I had to guess, Chrome is doing some form of static analysis, and there might be a way it expects to see WASM methods called that wasm-bindgen exceeds the bounds of in some ways (but not all). This might include creating a function from strings provided by the wasm binary, as highlighted in the stack trace.
The text was updated successfully, but these errors were encountered: