Running processes as root helps attackers #71
Replies: 17 comments 2 replies
-
I totally agree and this is on my radar. I am hoping this will be fixed in #15. The only problem I had was if I set it to I will definitely be revisiting this because its one of the bigger worries I had about this set up. |
Beta Was this translation helpful? Give feedback.
-
Please be aware that |
Beta Was this translation helpful? Give feedback.
-
Setting user in a Docker image should be the last step. I hope you do not intent to install packages in a running container! |
Beta Was this translation helpful? Give feedback.
-
No, this would be like this... Problem
For example(I think I tried this earlier) On a downstream docker project, I might want a new
☝️ If I have Thoughts? |
Beta Was this translation helpful? Give feedback.
-
Done! |
Beta Was this translation helpful? Give feedback.
-
I will definitely give this a whirl, thanks!! |
Beta Was this translation helpful? Give feedback.
-
Here is an update on this: Problem
How to recreate the problem1. Copy my Dockerfile
2. Build my Dockerfile locally
3. Run the local image
Important note:
Things that concern meI don't even know if this is possible to run as a "non-root" user due to how PHP-FPM is structured. I'm pretty sure PHP-FPM needs root in order to start its processes. Other repos that are running PHP as "root"These very talented groups are also not running things as an unprivileged user:
What I think I might have to doMy gut feeling is telling be that I will:
Calling in help@szepeviktor: Are you aware of any examples of projects running PHP as an unprivileged user? |
Beta Was this translation helpful? Give feedback.
-
Hello! It is highly popular to give a sh*t about what is(is going on) inside a container. Actually it is a novice mistake to run something as root - no matter whether inside a container or not. S6 Overlay needs to run as root but it does not mean that PHP-FPM needs too. |
Beta Was this translation helpful? Give feedback.
-
I think PHP-FPM operates this way The master process runs as root, workers run as a normal user. |
Beta Was this translation helpful? Give feedback.
-
Thanks for chiming in! You confirmed my assumptions. I will need to remove the extra arguments on this line: docker-php/php/7.4/cli/Dockerfile Line 51 in 718f310 If I leave those lines in there above, PHP-FPM will not be able to start correctly because its trying to start the master process as Instead, I will have Does that sound like a good approach? |
Beta Was this translation helpful? Give feedback.
-
BTW Debian uses https://github.com/krallin/tini |
Beta Was this translation helpful? Give feedback.
-
At first glace yes. |
Beta Was this translation helpful? Give feedback.
-
php-fpm.conf could have |
Beta Was this translation helpful? Give feedback.
-
Thanks! I have this set already.
Interesting! I will play around with this. Thanks!! |
Beta Was this translation helpful? Give feedback.
-
It is open-source. You can spend weeks with it! |
Beta Was this translation helpful? Give feedback.
-
Sorry for digging this discussion up. It felt like the most fitting place to add my findings/thoughts. I was looking into the topic of the default root user and was worried that laravel queue workers/schedulers could accidentally be started as root (i.e. when not using I realized that I could use the ENV S6_CMD_ARG0='s6-setuidgid webuser' Now all docker commands run as docker run --name=app --rm "<IMAGE>" whoami
# [...]
# webuser Note that any commands executed against the running container would still be as docker exec app whoami
# root While this feels a bit... crude, I currently can't see how this could have any negative effects and it addresses my primary concern about starting docker containers with the root user. @jaydrogers do you have any thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
For cleanliness, I am going to close this discussion in favor of the active issue. I have a lot of work done in v3.0 on this, but still a few things to clean up. Track this for the latest #179 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please consider avoiding root (UID 0) and system users (UID 1-999) e.g. www-data.
Least privileges come with normal users.
Beta Was this translation helpful? Give feedback.
All reactions