mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2026-02-03 14:13:26 +00:00
[Security Issue] Docker containers' processes run as root #338
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TheAssassin on GitHub.
(This is the proposal mentioned in https://github.com/dutchcoders/transfer.sh/issues/85#issuecomment-336584896.)
At the moment, the processes in the Docker containers run as root. This is a security problem, as Docker's isolation is not perfect and there's a lot of exploits that could make a root user break out of the container (it's way less of an issue for some random users which are ideally not existing on the host system).
Some links I picked up quite some while ago:
I don't have the time to fix and test this right now. PRs welcome, I guess.
Some drawbacks I experienced earlier which I don't want to withhold (might be useful for the person creating the fix):
(If I should remember any other ones, I'll post them here.)
You can make it easier for anyone if you pick a very high user ID for the Docker container processes, anything above 10000 should suffice.
@TheAssassin commented on GitHub:
That's total nonsense. A Docker image should not be insecure by default. It's considered a best practice to avoid running as root when it's totally unneeded. You can always override the uid/gid, but that's nothing you should have to do to make using a Docker image safe.
Docker environments aren't as isolated as, say, a VM. root can do a lot of harm, even from a container.
Implementing what I suggested is really trivial and increases safety a lot. I would've done it months ago. However, I've never seen a reply like, "ok, let's do it" or "would you be willing to do it".
https://engineering.bitnami.com/articles/why-non-root-containers-are-important-for-security.html
https://medium.com/@mccode/processes-in-containers-should-not-run-as-root-2feae3f0df3b
Running as root is only ever a good idea if a tool is specifically meant for that and implements the right protection measures. I'm thinking about apache2, which drops privileges properly for worker processes, or special init daemons that also do this right. Random software should never be run as root for no reason. This applies outside Docker images just like it applies inside them.
@stek29 commented on GitHub:
since there are no complex entry points, it should be trivial to set uid/gid manually when starting the container
imo it should be up to end user to run the image properly, and images should not enforce uid/gid on their own
@paolafrancesca commented on GitHub:
@stek29 if you are going to suggest how to update the readme I'm happy to do it (you can do as well opening a PR)
@paolafrancesca commented on GitHub:
please, @TheAssassin keep it respectful :)
feel free to open a PR, I'm sorry you were expecting a confirmation for this on my side. If I knew you were I would have given when you opened the issue :)
@stek29 commented on GitHub:
Maybe updating readme with note about setting uid/gid when starting the container would be enough?
@TheAssassin commented on GitHub:
How do you call nonsense nonsense otherwise? I'm not a fan of seeing security concerns not taken seriously or, worse, calling it a user's problem. Blaming the user is always easier than solving an issue properly. This is not a matter of preference or opinion anyway. The principle of least privilege is well established in IT security.
I'll file a PR soon-ish.