by znpy · 5y ago · 0 comments
I see the point but this kinda looks like extreme paranoia.
I actually advise developers that are not so strong at docker and containers to use his 1000 in their container. Such uid is usually the default first uid in Ubuntu and thus makes running containers in their development machine easier (since now they don't have to deal with file permissions and uids without a corresponding user on their system).
Someone will boo this and maybe even downvote, but it really helps developer "think operationally", and gets their dev environment closer to prod.
That allows an attacker to potentially append some nasty code outside the container and get password-less sudo. Unlikely? Very. But security is all about layers.
I've seen full-fat Ubuntu containers with uid 1000 which is in docker group on the host and ~ mounted to run some python flask app, in production.
If you mount ~ in your containers you have bigger problems than uid 1000.
So then running your containers as that UID without user namespacing (docker’s default) opens you up to more attack surface than if it was uid 1001.
This is probably wrong and lazy. I think the rigorous approach is to use namespaces
https://www.jujens.eu/posts/en/2017/Jul/02/docker-userns-rem...
https://www.objectif-libre.com/en/blog/2020/06/30/securiser-...
At that point, you're gonna to need to change your strategy and properly map the user/group outside the container to the user/group inside the container anyway.