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

Is eval strictly necessary? #47

Open
JudahGabriel opened this issue Jan 22, 2025 · 0 comments
Open

Is eval strictly necessary? #47

JudahGabriel opened this issue Jan 22, 2025 · 0 comments

Comments

@JudahGabriel
Copy link

JudahGabriel commented Jan 22, 2025

Is eval strictly necessary in this library?

This library uses eval("(-1).toFixed(-1);") to trigger an exception and determine the browser from the exception message length.

What's the problem? Most secure web apps have a Content Security Policy (CSP) that prevents eval. Indeed, at many big corporations, such as GitHub and Microsoft, CSPs that prevent eval is required. Try it now in your browser: hit F12 and in the console, paste eval("(-1).toFixed(-1);") - you'll see GitHub prevents it:

Image

Looking at the code closer, the real exception is calling toFixed(-1). And this library is using the exception message length to determine the browser. It's not at all clear why eval is needed at all. Is it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant