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

Web assembly directive is blocked in our server content security policy. Thus we are not able to use the package #62

Open
mohamedabady opened this issue Jun 28, 2024 · 4 comments
Labels

Comments

@mohamedabady
Copy link

Screenshot 2024-06-27 at 5 06 10 PM

The Issue

after updating our server with the new code using the package, we got the above error in the console. After some small search, i understood that using webassembly might have some security concerns :

there are some security issues associated with using WebAssembly (Wasm). Here are some key concerns:

Code Injection and Exploits: Since WebAssembly allows running low-level binary code in the browser, there is a potential risk for code injection and exploitation if the Wasm module is compromised. Malicious actors could potentially exploit vulnerabilities in the WebAssembly code to perform unauthorized actions.

Memory Safety: While WebAssembly is designed to be memory-safe, bugs in the implementation of WebAssembly engines can lead to memory corruption vulnerabilities. These can be exploited to execute arbitrary code or bypass security restrictions.

Sandboxing Issues: WebAssembly runs in a sandboxed environment, which helps isolate it from the rest of the system. However, if there are flaws in the sandbox implementation, it could allow malicious code to escape the sandbox and interact with the host system or other parts of the browser.

Side-Channel Attacks: WebAssembly can potentially be used to perform side-channel attacks, such as timing attacks, to leak sensitive information. These attacks exploit the way Wasm code executes to infer data from secure contexts.

Third-Party Libraries: Many WebAssembly modules rely on third-party libraries. If these libraries contain vulnerabilities, they can be inherited by the WebAssembly module. Ensuring the security of all dependencies is crucial.

Denial of Service (DoS) Attacks: Malicious WebAssembly code can be used to perform DoS attacks by consuming excessive computational resources, causing the browser or the system to become unresponsive.

Compatibility with Existing Security Policies: WebAssembly might not be fully compatible with existing Content Security Policies (CSP) and other web security mechanisms. This can lead to potential gaps in security coverage.

the question now:

how can we mitigate these risks and use the package normally ?

@brookjordan
Copy link

If we could access a way to use the setZXingModuleOverrides function then we could override the route to the wasm file to be a local one.

Any thoughts on surfacing this?

@code-flow
Copy link

Same here! I would really appreciate the opportunity to access the setZXingModuleOverrides property!

@yudielcurbelo
Copy link
Owner

In version 2.0.7 you can import setZXingModuleOverrides.
I have not try it but you should be able to do something like.

import wasmFile from '{file location}';

import { setZXingModuleOverrides } from '@yudiel/react-qr-scanner';

setZXingModuleOverrides({
  locateFile: (path, prefix) => {
    if (path.endsWith(".wasm")) {
      return wasmFile;
    }
    return prefix + path;
  },
});

Copy link

stale bot commented Sep 12, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants