3 ms·
Just on a slight tangent, what are the security benefits of having a process run as a non-root user within a Docker container? It's obvious what the benefits ar
by foldr 6y ago
Just on a slight tangent, what are the security benefits of having a process run as a non-root user within a Docker container? It's obvious what the benefits are when running outside a container. Inside a container, on the other hand, there should only really be one important process running. That process will need to have access to all the interesting parts of the file system anyway, and being root inside a container doesn't let you do crazy superuser stuff like installing a kernel module.
- deleted 6y ago[deleted]
- Cthulhu_ 6y agoIt does allow you to exit the boundaries of the application though, and e.g. extract the application's database. That said, is it possible to disable superuser access entirely in a container? Can't login as root if there is no root.
- mattacular 6y agoDocker has a user namespacing feature which can be used to harden container images and also a newer way to run rootless altogether - https://docs.docker.com/engine/security/rootless/ https://docs.docker.com/engine/security/rootless/
- nix23 6y agohttps://developers.redhat.com/blog/2020/09/25/rootless-containers-with-podman-the-basics/ https://developers.redhat.com/blog/2020/09/25/rootless-conta...
- dec0dedab0de 6y agoIf the application user has access to the database, it doesn't matter if you get access to root or not.
- mattacular 6y agoIf you've got root on a container, depending on how it's configured, you can gain access to the host in some situations (eg. Using volumes)
- foldr 6y agoBut non-root users within the container can also access mounted volumes, no? Is there some kind of exploit that only works if running as root?
- lights0123 6y agoYou can setuid root in a volume mounted in host. If that's executed at all by any user, bam you have root on the host. If it's never executed, I don't know what vulnerabilities they were talking about.
- foldr 6y agoRight, but it seems that wouldn't require the app within the Docker container to be running as root to work?
- nix23 6y agoWhat a shitty concept. Typical Linux NIH (learn from zones jails lpar...no we need to reinvent the wheel in square format)
- turminal 6y agoLinux namespaces are quite flexible and aren't used just for docker style containerization. In some use cases having a shared user namespace makes sense. Docker just doesn't use the provided interface by default. Which is a shame because a lot of users don't bother or don't know they should bother to configure it. I think that's kind of a 'we don't care about security' move by docker and given its userbase that's a real problem.
- 6y ago
- coredog64 6y agoIf you don’t at least drop the sys_module cap, you can install a kernel module [0]. Running as root inside the container increases the risk of a breakout. I’ve seen different approaches at different companies. One bank required a hard-to-get security sign off that included MFA to start (so no automation). A different bank bought expensive monitoring tools and then threw a bunch of money at refining the outputs. [0] https://blog.pentesteracademy.com/abusing-sys-module-capability-to-perform-docker-container-breakout-cf5c29956edd?gi=561118cc2eee https://blog.pentesteracademy.com/abusing-sys-module-capabil...