0

Right now I am loading classes with a custom Classloader, and then running them. However I want to implement a Security Manager for these classes to prevent them from doing anything malicious.

This includes accessing the filesystem, network, reflection, or running threads. In fact I want to be able whitelist the API they are allowed to access/include/instantiate. Obviously I also want it to be able to access its own files.

The program in question is just a standard Java Program. Not Tomcat, embedded or an applet.

Chase
  • 1,419
  • 12
  • 17
  • How do you intend to prevent an infinite loop from causing a [DOS attack](http://en.wikipedia.org/wiki/Denial-of-service_attack)? There are a **lot** of ways a plug-in might harm an app. or a machine. – Andrew Thompson Dec 02 '13 at 08:24
  • At the moment I am not worried about that. But I will likely eventually monitor how long its methods run, and if they go too long it will be killed manually. – Chase Dec 02 '13 at 08:26
  • 1
    Well this is possible and it is obviously an intended use case for the `SecurityManager`. But what’s your question? – Holger Dec 02 '13 at 09:16
  • That... is a really good question. I suppose I am asking how to do that. – Chase Dec 02 '13 at 09:30
  • Note, since Java 2, you rarely need a **custom** security manager. / You don't can't really protect yourself from DoS by killing the method. For instance, the method may be running on the finaliser thread. You need to accept that the untrusted code could trust you and deal with that. – Tom Hawtin - tackline Dec 04 '13 at 07:33

0 Answers0