有人可以用sun.misc.unsafe破坏安全经理吗? [英] Can one break a secury manager with sun.misc.unsafe?
问题描述
在另一个问题,引起了一个有趣的问题。
Following a conversation on another question, an interesting issue is being raised.
加载了安全管理器的类受到相应安全性的保护。这种安全性可能会禁用反射(例如)。
Classes loaded with a security manager are protected with the corresponding security. This security could disable reflection (for example).
问题是:是否有可能使用sun.misc.unsafe破坏安全管理器?如果是,怎么办?
The question is: is it possible to break a security manager with sun.misc.unsafe? If yes, how?
编辑
已更改
推荐答案
否。 sun.misc.Unsafe
类需要进行访问检查,就像其他任何特权操作一样。您可以使用自定义类加载器或安全管理器阻止它。这是一个简单的示例,其中有一个空的安全管理器,显示将抛出 AccessControlException
:
No. The sun.misc.Unsafe
class requires an access check just like any other privileged action. You can block it with a custom class loader or security manager. Here's a simple example with an empty security manager that shows it'll throw an AccessControlException
:
System.setSecurityManager(new SecurityManager());
Unsafe unsafe = Unsafe.getUnsafe();
这篇关于有人可以用sun.misc.unsafe破坏安全经理吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!