将 Tomcat 与 Java SecurityManager 结合使用?

发布于 2024-07-30 17:18:46 字数 393 浏览 5 评论 0原文

我正在编写一个应该在 Ubuntu 上的 Tomcat 上运行的 Web 应用程序。 在 Ubuntu 上,Tomcat 默认配置为与 Java SecurityManager 一起运行。 除了我自己的 Web 应用程序之外,只会有一些与我自己的相关的知名第三方 Web 应用程序,例如 BIRT 报告引擎。

如果其中一个 Web 应用程序出现故障或受到损害,它可能会在没有损害的情况下关闭所有其他应用程序,因为它们都是一体的。 我不会发生的是,受感染的 Web 应用程序会损害系统本身,例如调用 rm -r /

我是否需要使用 java 安全管理器来实现此目的? 或者只需要保护一个网络应用程序免受另一个网络应用程序的侵害? 我真的很想阻止为我打算使用的所有第 3 方 Web 应用程序创建 .policy 文件。

I'm writing a web application that is supposed to run on Tomcat on Ubuntu. On Ubuntu, Tomcat is per default configured to run with the Java SecurityManager. Besides my own web application, there will only be some well known third party web applications related to my own, like the BIRT report engine.

If one of the web applications fails or gets compromised, it may take down all the others without harm, because they all belong together. What I don't wont to happen is that a compromised web app compromises the system itself, like calling rm -r /

Do I need to use the java security manager to achieve this? Or is it only necessary to protect one web app from the other? I'd really like to prevent the effort to create .policy files for all the 3rd party web applications I intend to use.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

打小就很酷 2024-08-06 17:18:47

理论上是的。 但我听说人们在尝试使用安全管理器“锁定”服务器端代码时遇到了很多问题。 应用程序的设计通常没有考虑到这一点,并且您花费大量时间调试 SecurityExceptions,直到获得正确的所有权限设置。

编辑:

我建议运行两个 Tomcat 实例更简单,以避免一个应用程序执行某些操作会导致单个 Tomcat 中的所有内容崩溃的问题。 (例如,填充堆、泄漏文件描述符或...调用 System.exit()。)

如果您仍然担心应用程序“突破”Java 并执行相当于“rm /*”的操作,那么您可以在单独的“chroot监狱”或虚拟主机中运行每个Tomcat实例。 或者,您可以简单地从受限用户帐户运行 Tomcat,并确保该帐户无法访问/更新不应访问/更新的文件。

In theory yes. But I've heard that people run into stacks of problems when they try to "lock down" server side code using the security manager. Applications are frequently not designed with this in mind, and you spend a lot of time debugging SecurityExceptions until you get all of the permissions settings right.

EDIT:

I suggest that is simpler to run two Tomcat instances to avoid the problem of one application doing something that will bring down everything in a single Tomcat. (For example, fill up the heap, leak file descriptors or ... call System.exit().)

If you still are worried about an application "breaking out" of Java and doing the equivalent of "rm /*", then you could run each Tomcat instance in a separate "chroot jail" or a virtual host. Or you could simply run Tomcat from a restricted user account and make sure that the account cannot access / update files that it should not.

情话已封尘 2024-08-06 17:18:47

避免“rm -r /”不需要安全管理器。 如果运行 Tomcat 进程的用户具有有限的访问权限(即没有对 / 或任何其他重要区域的写入权限),则这就足够了。

Avoiding a "rm -r /" doesn't require a security manager. It is sufficient if the user that runs the Tomcat process has limited access (i.e. doesn't have write access to / or any other important area).

坏尐絯 2024-08-06 17:18:47

SecurityManager 只是您可以应用于 Tomcat 的另一层安全性,并且根据您的应用程序,正确使用它可能非常困难且耗时。 正如您已经指出的,为第三方应用程序和库实现这一点可能会更加困难。

在我看来,进行任何细节配置都是您最不应该考虑的事情。

这里已经说了很多内容,但如果我是你,我会按顺序执行以下步骤:

  1. 在具有尽可能少的权限的帐户下使用 jsvc 运行 Tomcat(按照惯例,帐户名为“tomcat”、“tomcat6”) ETC。)。 如果您已经安装了 Ubuntu 软件包,它安装的 init 脚本已经执行了此操作,因此如果您通过此脚本启动 tomcat,您就可以了。
    有关 jsvc 的更多信息,请参阅 http://tomcat.apache.org/tomcat- 6.0-doc/setup.html
  2. 使用 chroot 运行 jsvc。 将您使用 chroot 指定的虚拟文件系统中的内容限制为仅 Tomcat 需要的内容。
  3. 保护您的 Tomcat、数据库和操作系统配置。 信息安全中心对此有很好的基线指导 - http://cisecurity.org /en-us/?route=downloads.multiform
  4. 应用安全。 这是最重要的,但是通过比较,1.、2. 和 3. 很容易实现,因此我建议您在此之前执行这些操作(或者更好,并行执行)。 确保应用程序的所有输入在使用之前都经过验证。 使用 OWASP 的企业安全 API 等作为起点 - http://www.owasp。 org/index.php/类别:OWASP_Enterprise_Security_API。 您所做的其他一切都是您的应用程序安全工作的故障保险。 如果您的应用程序不安全,则由于您采取的其他步骤(低权限帐户、chroot、安全配置等),其运行的计算机可能会保持安全,但应用程序管理的数据将受到损害。
  5. 安全经理。 一旦您对拥有良好的应用程序安全基线感到满意,请务必考虑将安全策略添加到您正在进行的应用程序安全工作中。

您可以做的其他事情包括在计算机上运行 Snort 等 IDS 来检测某些入侵尝试,运行 swatch 等文件观察器来检测意外的文件修改(尤其是配置文件)以及运行各种日志分析器来尝试检测任何其他入侵尝试。

任何安全努力总是需要做出权衡。 您永远无法完全保护您的应用程序,并且总有一天,进一步的努力是不值得的。 对于大多数人来说,完整的安全管理器配置属于这一类。

“我需要使用 java 安全管理器来实现此目的[损害系统本身]吗?”

不。有更简单的方法(低权限帐户、chroot、安全配置等)

SecurityManager is just another layer of security you can apply to Tomcat and, depending your application, can be very difficult and time consuming to get right. As you've already noted, getting this right for third party applications and libraries can be even more difficult.

In my opinion, configuring this in any detail is the last thing you should be considering.

Much of this has been said already here, but if I were you, I'd follow these steps, in order:

  1. Run Tomcat using jsvc under an account with the least possible privelages (by convention an account named 'tomcat', 'tomcat6' etc.). If you've installed the Ubuntu package, the init script it installed already does this, so if you start tomcat via this script, you're covered.
    For more on jsvc, see http://tomcat.apache.org/tomcat-6.0-doc/setup.html
  2. Run jsvc using chroot. Limit what's in the virtual filesystem you specify with chroot to only what Tomcat needs.
  3. Secure your Tomcat, database and OS configuration. The Center for Information Security has good baseline guidance for this - http://cisecurity.org/en-us/?route=downloads.multiform.
  4. Application security. This is most important, but 1., 2. and 3. are so easily achieved by comparison that I suggest you do those before this (or better, in parallel). Ensure all input to your application is validated before it is used. Use something like OWASP's Enterprise Security API as a starting point - http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API. Everything else you do is a failsafe for your application security efforts. If your application is insecure, the machine it's running on may remain secure because of the other steps you've taken (low privilege account, chroot, secure config etc.) but the data that the application manages will be compromised.
  5. Security Manager. Once you're happy that you have a good baseline of application security, by all means consider adding a security policy to your ongoing application security efforts.

Other things you can do include running an IDS like Snort on the machine to detect some intrusion attempts, running a file watcher like swatch to detect unexpected file modifications (especially to configuration files) and running various log analysers to attempt detect any other attempts at intrusion.

There's always a tradeoff to be made with any security effort. You can never totally secure your application and there always comes a point when further effort just isn't worth it. A full blown security manager configuration, for most people, falls into this category.

"Do I need to use the java security manager to achieve this [compromising the system itself]?"

No. There are easier ways (low privilege account, chroot, secure config etc.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文