关于安全性:什么系统调用来阻止/允许/检查以创建程序主管

What system calls to block/allow/inspect to create a program supervisor

根据Using ptrace to write a program supervisor in userspace,我正在尝试创建在线法官的程序主管组件。

我需要完全阻止哪些系统调用,始终允许或检查 to:

的属性

  • 防止分叉或运行其他命令
  • 限制为标准的"安全"C 和 C 库
  • 防止网络访问
  • 限制对除 2 个文件"in.txt"和"out.txt"之外的所有文件的访问
  • 阻止访问任何系统功能或详细信息。
  • 防止应用程序逃离其主管
  • 防止任何令人讨厌的事情。

非常感谢任何帮助/建议/链接。


从安全的angular来看,最好的方法是弄清楚你需要允许什么,而不是你需要拒绝什么。我建议从只记录一组已知良性程序所做的所有事情的主管开始,然后将这些系统调用和文件访问列入白名单。当新程序与这个非常严格的沙箱发生冲突时,您可以根据具体情况评估放松限制,直到找到正确的配置文件。

这基本上就是在 Mac OS X 上开发应用程序沙箱配置文件的方式。


也许你可以配置 AppArmor 来做你想做的事。来自常见问题解答:

AppArmor is the most effective and easy-to-use Linux application security system available on the market today. AppArmor is a security framework that proactively protects the operating system and applications from external or internal threats, even zero-day attacks, by enforcing good program behavior and preventing even unknown software flaws from being exploited. AppArmor security profiles completely define what system resources individual programs can access, and with what privileges. A number of default policies are included with AppArmor, and using a combination of advanced static analysis and learning-based tools, AppArmor policies for even very complex applications can be deployed successfully in a matter of hours.


如果你只想让系统调用检查另一个进程,你可以使用 ptrace(),但是你将没有任何保证,就像使用 ptrace 在用户空间中编写程序管理器中所说的那样。

您可以使用 valgrind 来检查和挂钩函数调用、库,但这会很乏味,而且黑名单可能不是这样做的好方法。

您还可以使用 systrace (http://en.wikipedia.org/wiki/Systrace) 编写规则以授权/阻止各种事情,例如只打开一些文件等...使用它对进程进行沙箱处理。