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

Trying to crash server running jint #917

Closed
emilmuller opened this issue Jun 17, 2021 · 3 comments · Fixed by #923
Closed

Trying to crash server running jint #917

emilmuller opened this issue Jun 17, 2021 · 3 comments · Fixed by #923

Comments

@emilmuller
Copy link

emilmuller commented Jun 17, 2021

I'm offering users of my website to run scripts, but I don't want to let them be able to crash my server (or make it unresponsive).
So I've been actively trying to make jint unresponsive.
I'm running the following code to attempt to use up all the memory:

new Engine(o => o.MaxStatements(1000)).Evaluate("for (let a = [1, 2, 3];; a = a.concat(a)) ;");

Interestingly, it doesn't use up all the memory, but it freezes (even though I set a maximum number of statements). No exceptions are thrown.

3.0.0-beta-2032

@lahma
Copy link
Collaborator

lahma commented Jun 17, 2021

I think it's really hard to make everything bulletproof so please keep that in mind. I think we can fix this particular case but there might always be other ways to cause havoc, unfortunately.

@emilmuller
Copy link
Author

Thanks for replying! Just out of curiosity, why doesn't it run out of memory? :)

@lahma
Copy link
Collaborator

lahma commented Jul 8, 2021

It actually halts because array changes logic to use dictionary for large array (it expects it to have holes). I've addressed this in #923 and there's new constraint that can be set for max allowed array size. So in your case CPU is burning in array handling and cannot reach the statement count limit.

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

Successfully merging a pull request may close this issue.

2 participants