-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix CVE-2024-5979 AstRunTool #16351
Comments
… and check to make sure cluster is up.
… and check to make sure cluster is up.
… and check to make sure cluster is up.
… and check to make sure cluster is up.
After using @tomasfryda suggestion, I was able to reproduce the error using his code: curl http://localhost:54321/99/Rapids --data-urlencode 'ast=(run_tool "MojoConvertTool" ["","","",""])' However, this is due to the following code in MojoConvertTool.java:
Note the System.exit(2) is what causes our H2O-3 cluster to exit. After I change the System.exit(2) to
I ran the same code and H2O-3 did not crash. Hence, any time we run a command that call System.ext() instead of throwing an error will always cause H2O-3 to crash. |
However, there is a way to prevent this here: https://www.quora.com/What-is-the-best-way-to-prevent-JVM-from-exiting-after-calling-System-exit-in-Java-programming-language In Java, when you call System.exit() method, it directly terminates the JVM (Java Virtual Machine) and shuts down the program. This behavior is by design and is intended to forcefully terminate the JVM and end the program. If you want to prevent the JVM from exiting after calling System.exit(), you can use a SecurityManager to intercept the call to System.exit() and prevent it from shutting down the JVM. Here's a basic example of how you can do this: public class NoExitSecurityManager extends SecurityManager { public class Main {
} Please note that using a SecurityManager to prevent the JVM from exiting after calling System.exit() is not a common practice and should be used with caution. It can have unexpected consequences and may not work as expected in all scenarios. Additionally, it's generally recommended to avoid using System.exit() for normal program flow control. It's considered a harsh way to terminate a program and should be used sparingly, typically only for exceptional cases. Instead, you should design your program flow in a way that does not rely on calling System.exit() to exit the program. Profile photo for Syed Mohsin Javed Another way to prevent the JVM from exiting is to use the Java SecurityManager. The SecurityManager can be used to restrict access to certain system resources, such as the System.exit() method. By default, the SecurityManager allows all actions, but this can be changed by overriding the checkExit() method. yet another way is to set the java.lang.SecurityManager property to "SecurityManager" in the java.security file. This will cause the JVM to exit if the SecurityManager is not properly configured. The best way to prevent the JVM from exiting after calling System.exit() is to use a combination of the Shutdown Hook and the SecurityManager. The Shutdown Hook can be used to perform cleanup activities, such as closing files or database connections. The SecurityManager can be used to restrict access to certain system resources, such as the System.exit() method. By combining these two techniques, you can ensure that the JVM will not exit unless you explicitly allow it to. |
A workaround proposed by @mmalohlava is as follows:
|
@wendycwong The issue is not just in I'd be in favor of doing the modification (add |
Yes, we should add that to our own tools main_internal. |
AstRunTool can crash H2O if bad inputs are provided. This is a subtask of #16339
The text was updated successfully, but these errors were encountered: