-
-
Notifications
You must be signed in to change notification settings - Fork 567
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
Service module defaulting user to root #221
Comments
And what value should it be set to knowing that not setting a value causes conflicts with the ECS APIs? |
The AWS documentation states that the user property of a container definition is not required: "The user to use inside the container. This parameter maps to User in the docker container create command and the --user option to docker run." This suggests that if it does map to the docker --user then if not provided then the User specified in the image is used. Are you saying that the problem is that the service module always provides Out of interest, what conflict do you get when its not set? To be honest, this is the first time i have encountered the user property in a task definition as i have always driven it with the dockerfile. |
the issue is not within this module, but a conflict between the ECS API and the Terraform AWS provider. You can see here for more details hashicorp/terraform-provider-aws#11526 (comment) While I agree that using the root user is far from ideal - it then becomes a question of what value do you use? We cannot simply guess at a UID/GUID and "hope" that works - the root user tends to work most often because of its permissions and therefore a safer default value to ensure things "just work" in the majority of cases. This then puts the onus on users to explicitly set a value that works for their container that is not the root user ID |
Setting the user to For example:
Happy to create a new PR if it looks good to you. |
Thank you but no thank you - if folks aren't reading their Terraform plan output, why do we think they'll read the obscure notes we put in the repo docs 😅 |
As a new greenfield deploy there is a lot to take in during a plan which could have (and obviously has a few times) been missed. It wouldn't do any harm to highlight this in the docs as a someone doing a new setup would be referencing them. Not sure why the offer to update them for you is not wanted, is there something i am missing here that would be a negative? |
Its not a negative, I just don't see any value in that one line blurb. For example, we have this which is under an explicit
I am all for improvements but we have been down this path and it hasn't yielded the results expected so why would we go down that same path? if there is a different way of making this information more apparent, or in this case, a different way to resolve this specific issue around diffs with the API and needing to set a default of the root users - I am all ears. In fact, if anyone wants to submit a pull request, I would really really REALLY appreciate if you can submit one on the provider that removes this issue so we can set |
Ok, I still think a note on the |
Using root is not such a big issue if you stick to read-only file system |
Hi. Thank you for maintaining this module and caring for improvements. I hope this gives a new perspective. TLDRThe default should be user = try(each.value.user, var.container_definition_defaults.user, null) ContextI was in the process of creating a PR now because I've been using my fork in production for the past month and it's been working OK. The only change needed for this issue is that line mentioned in the issue description. I was drafting a PR today because I saw a month ago this past issue #102 that was closed without resolution by the github-actions bot because it was stale. But when creating the PR and adding the description, I noticed this new issue and wanted your feedback. I'm happy to discuss this further and try to help because I would like to continue using this great module. Longer explanation for the moduleThe default should be
I quote two explanations from the AWS and Docker documentation below. AWS ECS "Run containers as a non-root user"
Docker blog "Understanding the Docker USER Instruction"https://www.docker.com/blog/understanding-the-docker-user-instruction
|
hi @gmeligio - tl;dr - its an upstream issue, not a module issue. we're talking about things that are inconsequential unless its fixed at the source |
But the module sets the root (value I'm not following what's the upstream issue. Could you elaborate a bit more? |
Sorry for not reading your specific comment. To me it's not the same issue as this one.
Regarding this upstream issue you mentioned, there is a comment that says
I might be missing something and it could be related. Anyways, the workaround of passing |
I was analyzing more the following links:
After analyzing a bit more, I think I understand now why the change was introduced in #101, but maybe it was unintended to force root and not allow the default ECS behaviour, and a way of passing The tradeoff between the options I see is:
For my use case, I always replace the task definition in the CI/CD pipeline because the image is rebuilt in each pipeline run, so I didn't experience the upstream issue. That's why I considered only Option 1. Maybe applying Option 2 is the best for the users of this module, and I'm OK with that. I would only need a workaround for setting Does someone know a workaround when consuming this module to pass user = try(each.value.user, var.container_definition_defaults.user, 0) |
This issue has been automatically marked as stale because it has been open 30 days |
bump |
An additional issue is that the variable documentation for var.user no longer matches the actual module execution: The user to run as inside the container. Can be any of these formats: user, user:group, uid, uid:gid, user:gid, uid:group. The default (null) will use the container's configured |
in v6.0 we will be reverting the root user back to |
Description
The container definition sub module is configured to set the user to null if not specified as it should. When using the container definition submodule in the service sub module, it gets set to 0 when not supplied.
https://github.com/terraform-aws-modules/terraform-aws-ecs/blob/3b70e1e46e1b96a2da7fbfe6e2c11d44009607f1/modules/service/main.tf#L573C3-L573C93
This issue is listed and i totally agree with the original posters comment by @jackylamhk:
#190 (comment)
I also spent too long trying to find out why my container was failing when moving to this module due to this issue. Defaulting to root (especially when un-documented) is surely a security issue.
I am posting this again as i noticed that the original one was closed/locked which means this it drops off the radar. I get the breaking change but surely security should be the priority and be cause enough for this to stay on the radar.
The text was updated successfully, but these errors were encountered: