News for hackers. Stuff that matters.
Re:Docker container security cheat sheet by rzimmerman on Monday August 02, 2021 @09:42PM (#28044847)
It’s widely accepted “best practice” to not run processes in docker containers as root but I think it does a disservice to not explain why. The top benefit in my mind is to be able to mark interpreted code (server side JS/python/ruby) as read only in case someone gains shell access in the container. It’s great to set up another user for execution, but you should also make sure to copy in code and build artifacts as read-only. I’m curious if people can name other direct benefits to a non-root user other than “I don’t trust docker/Linux process isolation”.
Re:Docker container security cheat sheet by raesene9 on Tuesday August 03, 2021 @03:42AM (#28046637)
If you want to set the filesystem as read only in a Docker container you can do that, without needing to set-up multiple users in the container.

In general that's a good piece of hardening advice, you just need to mount an empty volume for any temp files that are needed by the app.

For not running as root, the main benefit (to my view) is that there have been multiple CVEs in container stacks where the issue fully or partially mitigated if the container was running as non UID-0

CVE-2021-30465 was partially mitigated, and CVE-2020-15257 had a requirement of the container running as UID-0.

So whilst it's not a panacea, in general not running containers as root is a good layer of defence.

Re:Docker container security cheat sheet by physicles on Tuesday August 03, 2021 @12:20AM (#28045683)
This seems to mitigate the specific threat where I gain non-root shell access to the container, but there's a root process running interpreted code, which I can modify.

However, if the container doesn't contain any processes running as root, there doesn't seem to be any benefit (besides defense in depth) to marking the code as read-only.