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

Unsafe-eval CSP issue #337

Open
kevinvugts opened this issue Aug 23, 2024 · 7 comments
Open

Unsafe-eval CSP issue #337

kevinvugts opened this issue Aug 23, 2024 · 7 comments
Assignees
Labels
core Core dotLottie rust related question Further information is requested stale

Comments

@kevinvugts
Copy link

Overview

Dear,

I am concerned about the @lottiefiles/dotlottie-react library since it makes use of unsafe-eval. I have to enabled it to make the Lottie file work but I am doubting if this is the way to go.

Could you guys elaborate more on this security topic?

@theashraf
Copy link
Member

@kevinvugts I couldn’t find any usage of eval within the dotlottie-* packages. Could you provide more details to help me investigate further?

I’ll also implement an ESLint rule to check for unsafe-eval in the CSP, which should help me identify the root cause.

@theashraf
Copy link
Member

theashraf commented Aug 26, 2024

Based on this issue -> emscripten-core/emscripten#20994, passing -sDYNAMIC_EXECUTION=0 when building the WASM bindings in the dotlottie-rs core player should fix this issue.

Update: This approach does not resolve the problem, as DYNAMIC_EXECUTION is already disabled in the core player (see https://github.com/LottieFiles/dotlottie-rs/blob/main/Makefile#L263) 🤔

@theashraf theashraf self-assigned this Aug 26, 2024
@theashraf theashraf added bug Something isn't working core Core dotLottie rust related labels Aug 26, 2024
@theashraf theashraf moved this to In Progress in dotlottie-rs Roadmap Aug 26, 2024
@theashraf
Copy link
Member

@kevinvugts One potential solution to consider is using wasm-unsafe-eval in your CSP header.

The wasm-unsafe-eval directive specifically controls WebAssembly execution and is more specific than unsafe-eval. If wasm-unsafe-eval is not specified in the script-src directive, WebAssembly will be blocked from loading and executing on the page. For more details, you can refer to this documentation: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_webassembly_execution

@kevinvugts
Copy link
Author

@kevinvugts One potential solution to consider is using wasm-unsafe-eval in your CSP header.

The wasm-unsafe-eval directive specifically controls WebAssembly execution and is more specific than unsafe-eval. If wasm-unsafe-eval is not specified in the script-src directive, WebAssembly will be blocked from loading and executing on the page. For more details, you can refer to this documentation: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_webassembly_execution

Thank you so much for getting back to me. However, may I ask why the there are references to eval? This is a potential security hazard and shouldn't be present in a core library of LottieFiles in my opinion. CSP policies nowadays prevent these type of attacks by disabling them.

And I don't feel comfortable enabling these inline scripts to be able to be executed. What is your view on this?

@theashraf
Copy link
Member

@kevinvugts, This issue arises from the generated code by the Emscripten library, which compiles our core dotLottie Rust player and handles the WebAssembly and JS-binding "glue" code.

It’s a common issue, as discussed here: WebAssembly/content-security-policy#7. You might find success using wasm-unsafe-eval.

@theashraf theashraf added question Further information is requested and removed bug Something isn't working labels Aug 28, 2024
@kevinvugts
Copy link
Author

wasm-unsafe-eval

Hi @theashraf

I think this would work for now.
However, as the name suggests "wasm-unsafe-eval" it probably isn't a really secure option.

Isn't there another way to compile your core library? As this might open a lot of security risks to all users that use this native library of Lottie. :(

Copy link
Contributor

github-actions bot commented Nov 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the stale label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core dotLottie rust related question Further information is requested stale
Projects
Status: In Progress
Development

No branches or pull requests

2 participants