6 ms·
No. The "root" you get in docker is not actually root outside of the namespace the container in running in. Assuming no bugs in the kernel, it should not be a
by chlorion 2mo ago
No.
The "root" you get in docker is not actually root outside of the namespace the container in running in.
Assuming no bugs in the kernel, it should not be able to do anything more than the UID that it's mapped from.
- ptx 2mo agoDoes Docker use user namespaces by default? Otherwise root in the container is actually root on the host, from what I read. Correct me if I'm wrong. (Privileges are still limited by seccomp filters blocking some syscalls, and there's SELinux to block some other stuff, but it's still the actual root user without user namespaces, I think?)
- insanitybit 2mo agoThat's right. Docker still runs without user namespaces by default, which means that root is the same user inside and outside of the container. This does open up attack surface and configuration footguns. Confinement still leverages dropping some root caps, seccomp, various other namespaces, etc.
- inigyou 2mo agoI don't think this is true, otherwise you could just load a kernel module into the host kernel from a container.
- physicalecon 2mo agoIt is very possible to load a kernel module into the host from a container. https://stackoverflow.com/questions/33013539/docker-loading-kernel-modules https://stackoverflow.com/questions/33013539/docker-loading-...
- tjoff 2mo agoFYI, looks like you are shadowbanned.
- physicalecon 2mo ago[dead]
- ptx 2mo agoPresumably Docker's seccomp profile [1] blocks the init_module system call which is used by insmod [2]. Although, looking at the default profile, it seems to explicitly allow it - but maybe only if you have CAP_SYS_MODULE, which I think means running Docker with "--cap-add=SYS_MODULE". [1] https://docs.docker.com/engine/security/seccomp/ https://docs.docker.com/engine/security/seccomp/ [2] https://tldp.org/HOWTO/Module-HOWTO/x627.html https://tldp.org/HOWTO/Module-HOWTO/x627.html
- cyphar 2mo agoRoot is not just one thing on modern Linux, almost all in-kernel privilege checks are now gated via (slightly) more fine-grained capabilities and the default capability set for Docker containers disallows module loading (CAP_SYS_MODULE) and the relevant syscalls (namely (f)init_module) are also blocked with seccomp. People still should use user namespaces (and tools like Podman and Incus do by default) but basic stuff like that is not the reason.
- insanitybit 2mo agoThere are a million ways to load a kernel module from inside of a container into the host kernel (ie: to trigger a load), but seccomp/ linux caps will block the direct ways (as another commenter notes).
- chlorion 2mo agoAt least podman does if running rootless, I assume docker supports rootless operation as well. Not sure about running rootful though. I don't really use rootful containers personally.
- dboreham 2mo agoHmm. Either I've lost my mind, or you're running a different Docker than me, or you're thinking of some strange scenario such as a Mac where docker is actually inside a VM, or you're wrong. While there is a feature to do with UID mapping, it doesn't actually work/isn't usable/nobody uses it in current docker iirc. Therefore root in the container very much is root on the host.
- zamalek 2mo agoUID mapping is how rootless docker works, so tons of people are using it