-
Notifications
You must be signed in to change notification settings - Fork 82
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
Unable to block access to NashornScriptEngine #73
Comments
One addition: Having an active SecurityManager only mitigates the issue when using the most recent Java versions (8u191 etc.) |
I've been experimenting with potential solutions that don't involve a security manager or using the So far, the best solution I've got relies on JavaScript property descriptors to protect the
The default Overall, I agree with the recommendation to use a SecurityManager. |
Hi Anthony, thanks heaps for the info! So do you think adding this to the initialisation for the script could provide some additional (if limited) protection for scripts and its worthwhile to do this by default? |
Hi Max, Hi All, |
@joa23 Please be welcome to use either project. If you find an issue with the Rhino Sandbox, just report it. I have committed the fix suggested by Anthony. Would anyone know a way to get around this implemented fix? TestEngine.java tests pass now as expected. |
@mxro - thanks for committing the fix. |
@joa23 - new version should have already been deployed to Maven central :) I think it all depends on your usecase which library will work better. Please in any case note that proper sandboxing is one of the most challenging things to do in terms of security and both libraries should always be seen with a grain of salt! |
Sorry: Is this still an issue or have you guys fixed it? |
@KSean222 Yes, this issue should be solved! |
Using a security manager is not a reliable solution in itself, as it's fairly easy to disable the security manager itself. |
i am very confused why the POC |
Good question! I assume it is some quirk in the Nashorn Engine to expose the As per the thread above, I believe this should be fixed now. Does this still occur for you? |
Accessing the property on Java objects will call the getter method. Should not matter whether it's .getFactory().getScriptEngine() or .factory.scriptEngine. |
so what do u mean "quirk" ? :)i am what to know how the bottom logic for the Nashorn Engine ? Anyone can explain? |
So, this issue can lead to bypass this sandbox to remote code execution? Besides, why this issue is still open? |
Thanks for following up @fa1c0n1! Here is the test case that validates this scenario is now covered by the sandbox: https://github.com/javadelight/delight-nashorn-sandbox/blob/master/src/test/java/delight/nashornsandbox/TestEngine.java Unless someone provides a different test case that shows this can still be exploited, I will close this issue. Note that I expect a sandbox like this can be escaped. Please use other sandboxing methods if you want to be sure it is safe for public use. |
Nashorn exposes an instance of NashronScriptEngine through the
engine
property.This allows executing arbitrary code as follows:
The test case for this is defined here: Test Engine
Workaround:
It is suggested that this can be resolved when using a SecurityManager.
The text was updated successfully, but these errors were encountered: