Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 'root' user accounts instead of non-root user within docker containers? #14

Closed
grctest opened this issue Aug 11, 2016 · 4 comments · Fixed by #43
Closed

Using 'root' user accounts instead of non-root user within docker containers? #14

grctest opened this issue Aug 11, 2016 · 4 comments · Fixed by #43

Comments

@grctest
Copy link
Contributor

grctest commented Aug 11, 2016

Hey,

I've been messing around with boinc-server-docker trying to make my own project and noticed that within the dockerfile images you're using the user 'root' instead of a non-root user.

Do you think we should use non-root user accounts within the containers to increase security?

Cheers,
CM.

@grctest grctest changed the title Using 'root' user accounts instead of less powerful user within docker containers? Using 'root' user accounts instead of non-root user within docker containers? Aug 11, 2016
@marius311
Copy link
Owner

marius311 commented Aug 12, 2016

This is a very good question. I mostly picked root out of convenience (since files COPYed in via Dockerfile have root permissions by default, so it would require a separate RUN chown ... && chgrp ... to get them a different user).

Most likely non-root would be slightly safer, but it hasn't been at the top of my TODO list because I don't actually think its that much safer. Apache and Mysql run as their usual non-root respective users, so any RCE there is no more dangerous than usual. Its only the daemons that run as root, so I suppose the attack would have to go through Apache/Mysql, then somehow attack daemons via how they communicate with Apache/Mysql (unless I'm mistaken and theres a daemon thats talks to the world?). In any case, the initial Apache/Mysql attack would basically let the attacker do anything they wanted including alter the website / read or edit the DB, so gaining root via the daemons seems like extra work for no gain. Hence, I'm not too worried about it. Although I'm very open hearing other opinions.

Note also that Docker actually is a layer of security b/c even if an attacker gains RCE in Apache/Mysql or even as root, without an (as of yet non-existant) Docker breakout attack, they can't do anything to the machine running the containers.

@marius311
Copy link
Owner

Since moby/moby#34263 was merged, the need to run RUN chown ... && chgrp ... is now gone, we can just do COPY --chown, so there's not much reason not to switch to non-root daemons. I probably don't have the time to do this right now, but if anyone wanted to tinker with this, a PR is more than welcome!

@lfield
Copy link
Contributor

lfield commented Jul 11, 2018

The principle of least privilege should still be followed. Even if it is to just ensure that good habits are maintained. Also anything developed inside a container may have a chance to run outside.

@marius311
Copy link
Owner

Closed by #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants