linux - 为什么取消共享(CLONE_NEWNET)需要 CAP_SYS_ADMIN?

标签 linux linux-namespaces

我正在玩 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/

相关文章:

c++ - 如何调试丢包?

linux - 如何获取当前附加的 screen session 名称?

linux - LXC 是如何实现网络命名空间的?

linux - 在 bash/shell 中的关键字后添加文本

python - 无法向 iptables 添加规则,没有提交任何内容

linux - CentOS 7's vim can' 无法打开帮助(以 root 身份运行时),因为它无法处理 gzip 压缩的帮助文件

linux - Linux内核-CGROUPS的CPU子系统与CPU调度程序有何不同?

c - 将挂载从子命名空间传播到父命名空间?

linux - 创建非共享命名空间

linux - 从用户命名空间内部加入网络命名空间