I am a beginner of SecurityManager. I have been trying to use a Java SecurityManager to sandbox some untrusted code (supposed to be very simple code, like calculate the weight etc.) in linux. I use the command java -Djava.security.manager
to run the .class
file.
One thing that confused me is: someone says default policy of SecurityManager allows almost every action, and you need to write your own policy to deny some risky action (such as read/write file from your disk); while some others says default policy actually deny every risky action and if you need to permit some risky action, you can write your own policy to that action.
My question is:
ps. I actually want to deny all risky action. So, if the default policy is to deny every risky action, I think I will use the default SecurityManager.
The default security policy is pretty tight. You can look at your default java policy at java.home/lib/security/java.policy
Everything which is not included in the grant { ... };
block which applies to all domains, such as java.io.FilePermissions
, is not granted to the arbitrary code you run.
Java security policy files don't support 'deny' configuration, only grant
s. That's part of the reason it makes sense to start out with a relatively strict file on top of which users can add in user or application policy files.
Reference: http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With