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

Use of eval("new "+className+"()") allows XSS when JSON is unmarshalled #183

Open
rudolphi opened this issue May 17, 2021 · 0 comments
Open

Comments

@rudolphi
Copy link

Imagine className could be "String();doWhatever"

Better create a function to create the instances. Split the class name at dots, then go
var base=window;
base=base["first"];
and so on to get the desired class. Finally use one the approaches explained here
https://stackoverflow.com/questions/3362471/how-can-i-call-a-javascript-constructor-using-call-or-apply
https://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
to securely create the instance. The good thing is you never pass any parameters (14 times in 8 files), so the fix should not be a big deal.

rudolphi pushed a commit to rudolphi/draw2d that referenced this issue Jun 6, 2021
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