-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: use the non-root atlantis user instead of root #3886
fix: use the non-root atlantis user instead of root #3886
Conversation
TODO: needs testing locally |
@nitrocode, @GenPage, @jamengual if you have some time later this week - I consider this quite an impactful change and it would require thorough testing before shipping it. |
@bschaatsbergen I see the tests pass which is great but it would be nice to test this out in your setup and verify the following
|
One thing I'm curious about is why there do not need to be any chmod or chown changes as part of this pr? |
Yes, I think we do - as we've removed the line |
Thanks @bschaatsbergen. Please also rerun dockle and show the output in the pr summary. If we can reduce that to zero and still have atlantis running as usual then that would fully close our the associated issue. |
Tested: ✅ atlantis website for locks and plans |
|
This is ready for review @nitrocode, @jamengual, @GenPage - I've extensively tested the alpine image (besides autodiscovery) and I'm unable to test out the debian image - if one of you could check the debian image out that would be appreciated. I've published both an alpine as well as a debian image:
|
chmod g=u /home/atlantis/ && \ | ||
chmod g=u /etc/passwd | ||
chmod u+rwx /home/atlantis/ && \ | ||
chmod u+rw /etc/passwd | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come the chmod of /etc/passwd needs to change? If the line is removed, can atlantis still function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous chmod g=u
sets the group permissions for the /home/atlantis/
directory to be the same as the user's permissions.
The new chmod sets the user's permissions for the /home/atlantis/ directory to read, write (and execute).
So, the change here is that the original command was changing group permissions to match user permissions, and it has been modified to give the user explicit permissions instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but I don't understand why /etc/passwd
perms need to be changed. Can we get away with only changing /home/atlantis
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't want to break anything. Therefor I just gave it read write permissions. We can't use g=u
anymore though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok no worries then, can always tackle it later. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok but the more changes made, the more likely something can break. I'm all for more security, provided @bschaatsbergen has the appetite to keep going 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really the case? I'm happy to add it, but couldn't find it anywhere. I know that users start from 1000 though. Is there a particular reason we should explicitly set this? Omitting it would prevent a uid and gid conflict right? @jamengual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've set uid/gid 100:1000 and removed the passwd entry lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpine and debian have different uid
's it appears: #3317 (comment)
alpine: uid=100, debian: uid=1000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arohter it's removed again, to stay inline with what's in the Dockerfile now. to avoid touching the uid and gid at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, all of my concerns were already addressed. Is there anything left to do @bschaatsbergen based on your last comment?
This comment was marked as resolved.
This comment was marked as resolved.
Fixing this today, been a hectic week! |
378b857
/cherry-pick release-0.26 |
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: PePe Amengual <[email protected]>
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: PePe Amengual <[email protected]>
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: PePe Amengual <[email protected]>
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: Bruno Schaatsbergen <[email protected]>
Asked to comment: https://atlantis-community.slack.com/archives/C5MGGAV0C/p1702475459555389 here as there probably needs to be some documentation in the release notes regarding this update. But here is the lowdown. We use the Atlantis image as a base image and added some extra functionality to the container like so:
And this worked fine prior to v0.27.0. However we started to get an error:
Next we deploy this container via Ansible onto an EC2 instance, but there needed to be some changes in some tasks as we are now the atlantis user. Any time a task that requires you to be root within the container on the host, you now need to explicitly define the root user as the executor of the task. For example, we have an AWS config that needs to be readable by the atlantis user.
|
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: PePe Amengual <[email protected]>
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: PePe Amengual <[email protected]>
* feat: use Atlantis user by default and get rid of gosu * chore: set `DOCKER_CONTENT_TRUST=1` * chore: fix chmod and chown * feat: add a healthcheck to the debian and alpine images * feat: removing setuid and setgid permissions prevents container privilege escalation and improve comments * chore: remove setgid/setuid as we chown an entire directory * chore: keep deps comment generic * chore: grammar * chore: remove redundant comment * chore: rm DOCKER_CONTENT_TRUST * chore: set uid and gid and remove passwd entry * chore: revert gid and uid set as it's conflicting --------- Co-authored-by: PePe Amengual <[email protected]>
what
atlantis
user and not root.atlantis
user anywaysDOCKER_CONTENT_TRUST=1
anywhere we buildwhy
tests
references
atlantis
instead ofroot
#3777