如何在沙箱内运行不受信任的 Java Swing 应用程序?
我发现Java有一些安全权限来控制对AWT资源的访问。是否有任何方法可以控制 Swing 应用程序可以做什么或不能做什么,以避免不受信任的应用程序在多应用程序环境中相互干扰?
例如:
- 打开 JFrame。
- 打开一个完全透明的 JFrame。
- 关闭其他不受信任的应用程序的 JFrame 实例。
- 等等...
问题更新:
不受信任的应用程序是从一个单独的 JVM 在单独的线程中启动的,并从单独的类加载器加载。我想知道如何确保上述中断示例不会发生。
另外,如何防止不受信任的应用程序通过模仿其 UI 来冒充其他应用程序的应用程序?欢迎任何建议。
I found that Java has some security permissions to control the access to AWT's resources. Is there anything for controlling what a Swing application can or cannnot do, to avoid untrusted app to disrupt each other in a multi-app environment?
For example:
- Opening a JFrame.
- Opening a totally transparent JFrame.
- Closing other untrusted application's JFrame instance.
- etc ...
Update to the question:
The untrusted applications are launched from a unique JVM, in a separate thread, and loaded from a separate classloader. I would like to know how to make sure that none of the cited above disruption example can happen.
Also, how to prevent an untrusted app to pretend to be one from a different application by mimicing its UI? Any advice is welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你想做的事情是否可行。 AWT 具有一组可以在沙箱中运行应用程序时配置的权限(请参阅 AWTPermission,但它们的作用非常有限,并且似乎更有针对性地防止小程序做坏事。
最重要的是,防止应用程序模仿另一个应用程序对我来说似乎是不可能的;两个应用程序都可以创建 创建与另一个应用程序相同的 UI 组件?
UI 组件,是什么阻止一个应用程序 疯狂的想法是一个窗口管理器,在不受信任的应用程序周围放置一个红色边框,以便用户可以将其识别为不受信任,但是当两个应用程序在同一个 JVM 中运行时,Java 似乎没有足够的支持。因为似乎没有任何方法可以隔离两个应用程序(一个简单的 FocusListener 可以允许一个应用程序访问另一个应用程序的组件并更改它们)。
I'm not sure what you want to do is possible. AWT has a set of permissions that can be configured when running an application in a sandbox (see AWTPermission, but they're very limited, and seem more targeted at preventing applets from doing bad things.
On top of that, preventing an app from mimicking another one seems kinds impossible to me; if both apps are allowed to create UI components, what prevents one from creating the same UI components as the other?
If you have an app you trust and one you don't, you need code that these apps can't control that will run them differently; for example, a crazy idea would be a window manager that puts a red border around the untrusted app, so that users can identify it as untrusted. But Java doesn't seem to have enough support for something like that when both apps are running in the same JVM, since there doesn't seem to be any way to isolate the two apps (a simple FocusListener could allow one app to have access to components of the other and change them).