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 use of eval #8

Closed
cristianstaicu opened this issue Apr 8, 2016 · 1 comment
Closed

Unsafe use of eval #8

cristianstaicu opened this issue Apr 8, 2016 · 1 comment

Comments

@cristianstaicu
Copy link

The following use of eval in the file lib/resize.js is unsafe:

function getSizeFromRatio(options) {
    var ratio = eval(options.ratio);
    return Math.floor(options.size * ratio);
}

Since the ratio is a parameter passed to your module, the clients of your libary are not aware of these dangers and may allow arbitrary user input. I suggest refactoring out eval, parse the user input or use a sanitization module like:
https://www.npmjs.com/package/eval-sanitizer

@tiagoalves
Copy link
Member

Thank you for bringing this up. I've just changed that particular code to use math.js's eval:

math.eval()

Also published v0.4.3 to npm.

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

2 participants