Java security: Sandboxing plugins loaded via URLClassLoader

From the docs: The AccessControlContext of the thread that created the instance of URLClassLoader will be used when subsequently loading classes and resources. The classes that are loaded are by default granted permission only to access the URLs specified when the URLClassLoader was created. The URLClassLoader is doing exactly as its says, the AccessControlContext is … Read more

why java security manager doesn’t forbid neither creating new Thread() nor starting it?

It isn’t possible to define a security policy that will prevent code from creating and starting a new thread using the standard Java SecurityManager. Let’s say you have the following code: public class Test { public static void main(String [] args) { System.out.println(System.getSecurityManager() != null ? “Secure” : “”); Thread thread = new Thread( new … Read more

Preventing System.exit() from API

There is a blog post here, http://jroller.com/ethdsy/entry/disabling_system_exit Basically it installs a security manager which disables System.exit() with code from here, private static class ExitTrappedException extends SecurityException { } private static void forbidSystemExitCall() { final SecurityManager securityManager = new SecurityManager() { public void checkPermission( Permission permission ) { if( “exitVM”.equals( permission.getName() ) ) { throw new … Read more