fix: update wasm-bindgen to 0.2.109 for CSP compatibility#367
Open
sawa-zen wants to merge 1 commit intodimforge:masterfrom
Open
fix: update wasm-bindgen to 0.2.109 for CSP compatibility#367sawa-zen wants to merge 1 commit intodimforge:masterfrom
sawa-zen wants to merge 1 commit intodimforge:masterfrom
Conversation
wasm-bindgen 0.2.109 removed the `new Function("return this")` fallback
for getting the global object (PR wasm-bindgen/wasm-bindgen#4910),
which required `'unsafe-eval'` in Content-Security-Policy `script-src`.
With this update, applications using @dimforge/rapier3d-compat can use
the more restrictive `'wasm-unsafe-eval'` instead of `'unsafe-eval'`,
blocking JavaScript eval() while still allowing WebAssembly compilation.
Refs: dimforge#366
Author
|
Hi @sebcrozet, friendly bump on this PR. 🙂 This is a minimal one-line change (bumping Happy to address any feedback if needed. Thanks for maintaining Rapier! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Update
wasm-bindgenfrom0.2.100to0.2.109in the Cargo.toml template to remove thenew Function()fallback that requires'unsafe-eval'in CSP.Problem
The current JS glue code generated by
wasm-bindgen0.2.100 includes:This forces applications to allow
'unsafe-eval'in their Content-Security-Policyscript-srcdirective, which is a significant security downgrade — it permits arbitraryeval()andnew Function()calls.Solution
wasm-bindgen0.2.109 (PR #4910) removed thenew Function("return this")fallback entirely in favor ofglobalThis, which is supported in all modern browsers.This is a one-line change to
builds/prepare_builds/templates/Cargo.toml.tera. After rebuilding, applications can use the much safer'wasm-unsafe-eval'(which only permits WebAssembly compilation) instead of'unsafe-eval'.Notes
Cargo.lockwill be updated automatically during the nextwasm-pack build.globalThisbrowser support: Chrome 71+, Firefox 65+, Safari 12.1+ (caniuse)Closes #366