by stormbrew · 4y ago · 0 comments
I'm confused by this, don't you need CAP_SYS_ADMIN to unshare(CLONE_NEWNS) to begin with?
From unshare(2):
> CLONE_NEWNS
> This flag has the same effect as the clone(2) CLONE_NEWNS flag. Unshare the mount namespace, so that the calling process has a private copy of its namespace which is not shared with any other process. Specifying this flag automatically implies CLONE_FS as well. Use of CLONE_NEWNS requires the CAP_SYS_ADMIN capability. For further information, see mount_namespaces(7).
Edit: Oh does this work specifically because you're also unsharing into a new user namespace where you have that capability? This is kind of wild tbh.
But now any code can be root in its own namespace... so all of this code that's far less scrutinized is now reachable.
Counterintuitively, using containers makes your system less secure because you have to expose this huge kernel attack surface to non-root users.