我正在玩 linux 命名空间,我注意到如果用户想在新的网络命名空间中执行进程(不使用用户命名空间),他需要是 root 或拥有 CAP_SYS_ADMIN
能力。
unshare(2)手册页说:
CLONE_NEWNET (since Linux 2.6.24)
This flag has the same effect as the clone(2) CLONE_NEWNET flag. Unshare the network namespace, so that the calling process is moved into a new net‐work namespace which is not shared with any previously existing process. Use of CLONE_NEWNET requires the CAP_SYS_ADMIN capability.
因此,如果我想在网络沙箱中执行 pdf 阅读器,我必须使用 user-net-namespaces 或一些特权包装器。
为什么?新进程将被放置在一个没有接口(interface)的新网络 namespace 中,因此它将与真实网络隔离,对吗?非特权非用户网络 namespace 会引发哪些问题/安全威胁?
最佳答案
创建网络命名空间允许操纵具有 setuid 标志或其他特权的二进制文件的执行环境。用户命名空间消除了这种可能性,因为进程无法获得不包含在用户命名空间中的特权。
一般情况下,无法知道拒绝特权进程访问网络不会导致安全漏洞。因此,内核假定操作是特权的,由系统策略决定是否为普通用户提供特权实用程序。
关于linux - 为什么取消共享(CLONE_NEWNET)需要 CAP_SYS_ADMIN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39539188/