0

I have a Tomcat Java application, and I want it to be secure, so I created a custom SecurityManager where I blocked all actions I thought was dangerous (I probably missed some, but that's for another question). It worked well for a while, but then my application stopped working, and in catalina.out I saw the following message:

12/07/2011 10:31:42 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler process
SEVERE: Error reading request, ignored
java.lang.SecurityException
    at gwtchat.server.ScriptBotSecurityManager.checkWrite(ScriptBotSecurityManager.java:167)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:234)
    at java.net.SocketOutputStream.<init>(SocketOutputStream.java:58)
    at java.net.AbstractPlainSocketImpl.getOutputStream(AbstractPlainSocketImpl.java:411)
    at java.net.Socket$3.run(Socket.java:857)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.Socket.getOutputStream(Socket.java:854)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:163)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)

In the first line, gwtchat.server.ScriptBotSecurityManager is my custom SecurityManager, and the function is checkWrite(FileDescriptor fd), which I blocked because don't want my application to write to files.

Of course I want to block only my application, and not the Tomcat server itself. How can I do this?

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • I can't answer your question, but I really wonder why you implemented your own security manager. Why do security policies not fulfill your requirements? If you want to solve this problem you must understand **all** Tomcat internals! – home Jul 12 '11 at 16:14
  • I am working on a system where users can send snippets of Javascript code, and they are executed on the server (using ScriptEngine). Therefore I need a very strict security manager, that will not allow the user code to harm the server. But, I do want to allow some specific privileged actions, such data from a specific database table, or write to a specific log file. This is why I need a custom SM. – Erel Segal-Halevi Jul 13 '11 at 09:00

0 Answers0