Tuesday, October 30, 2012

Run jar file in a secure way

Often we download java tools/applications that are either from known sources or to try out their features.  Mostly they would come with either a bat/sh file to setup the path for the application and launch the jar.  Say you are logged in with an elevated user and what if the application you want to try just wipes out C drive!!

Always run the jar files (tweak the shell/batch scripts if required) to enable java security manager.  All that we need to do is launch jvm as java -Djava.security.manager -jar <jarFile>

This will use the default policy file that comes with JDK at JAVA_HOME/lib/security/java.policy, which is good enough.

No comments:

Post a Comment