-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Chart: Explicitly set runAsGroup
.
#11679
Conversation
✅ Deploy Preview for kubernetes-ingress-nginx canceled.
|
7fe497d
to
dffbe50
Compare
/assign Gacko |
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.
Could you please also set it in this comment?
Apart from that, your PR looks good to me!
charts/ingress-nginx/tests/default-backend-deployment_test.yaml
Outdated
Show resolved
Hide resolved
Some context for readers: According to the Kubernetes API reference the |
runAsGroup
configurable for controller & default backend.
41426f4
to
3a91d5b
Compare
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.
/triage accepted
/kind feature
/priority backlog
/lgtm
Does it mean that after this PR merges, the users can set any random gid of their choice ? |
Yes, they can. But I think this PR is more about making explicit what's currently implicit. |
And we want to allow any random gid/uid to be set ? If yes, is there a test needed to generate a random number and set that ? |
/hold |
The intention is not to change it as this would probably break the image. The intention is to explicitly define it and therefore overcome the implicit runtime value defined by your container runtime. |
|
So this PR is mostly about adding certainty and security where currently implicit and unknown behavior could be a security issue even though it might not be in most environments. Of course you can rely on your environment to handle this in a secure way, but the container runtime does not know all use cases and especially not our image. |
runAsGroup
configurable for controller & default backend.runAsGroup
for controller & default backend.
So from my point of view key takeaways from this are:
People (and tools) without deeper knowledge into the ingress-nginx project will see that the deployment doesn't have the securityContext field set and will think its insecure. This can be fixed using this PR. So my proposal would be: We add the possibility to change the gid. Default 82 and add a line explaining the situation in the values.yaml. Something like WDYT? |
That's already possible via the values. You can completely override each and every security context in the chart. For the controller and the default backend you will also need to set the other parts, that are currently hard coded in the template, on your own then. It's just not outlined explicitly so people hopefully would know they are doing / changing this on their own risk rather than in a provided and supported manner. |
Sounds good to me. I would not set it to 82 without checking the process is currently running and working with this ID. This ID was taken from the |
My opinion is not to introduce any new key in values file because while
experts will find solutions on their own, it's NOT a improvement to
increase the risk and add potential new way to create a message, when
nothing is broken or insecure in terms of gid/runAsUser.
…On Mon, 29 Jul, 2024, 13:16 Marco Ebert, ***@***.***> wrote:
So my proposal would be: We add the possibility to change the gid. Default
82 and add a line explaining the situation in the values.yaml. Something
like The official ingress-nginx container image uses uid 101 and gid 82. Do
not change this unless you're using a custom container image that requires
the change.
WDYT?
Sounds good to me. I would not set it to 82 without checking the process
is currently running and working with this ID. This ID was taken from the
passwd file, I don't know if it's also the GID the process is currently
running with.
—
Reply to this email directly, view it on GitHub
<#11679 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGZVWT2OOWVRJDKAOO5AG3ZOXXM7AVCNFSM6AAAAABLOAFT62VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJVGIZTMOJZGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Of course adding this value exposes an API users could use to change the GID, but we already have this API right now with In the end values are just both sides of a coin: Public API for users and dynamic way of configuration for maintainers. We cannot simply hard-code stuff we don't want users to change. That's not a good code style. And also having our defaults set in the values instead of hard-coded makes our chart flexible for real issues we do not know of, yet. So in the end I'm not afraid of adding this key to the values with a proper hint stating that changing this might break your deployment. Right now there's an uncertainty in which GID the images are being executes with as we are not defining them and we therefore rely on the users runtime to work as expected. This also could cause issues. Apart from that and especially in the scope of recent discussion about the security of this project, I'd rather go the explicit way of setting the GID than leaving a question mark. We had those insecure defaults and "up to the user" in the past and we decided to no longer leave it like this. |
runAsGroup
for controller & default backend.runAsGroup
.
Looks like This is from a running ingress-nginx pod
The interesting lines are the |
410819e
to
62471f8
Compare
Set a default value for the runAsGroup in container securityContexts of the controller and default backend. Also set the runAsGroup for opentelemetry and webhook Job container securityContexts. Signed-off-by: Gerald Pape <[email protected]>
62471f8
to
c6a5e4e
Compare
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 left a more concise suggestion with the output of running id
inside a container.
Also I added the double dashes so your hint is included in the README.md
.
Co-authored-by: Marco Ebert <[email protected]>
aec34ea
to
89d8121
Compare
Thanks for your suggestions. I ran helm-docs again and have pushed it. :) |
@Gacko I completely ack that there is controller.podSecurityContext. And this my opinion.
The current runtime-set-gid-of-82 is not a broken/insecure behavior needing a fix/change. |
Once again I'd like to point out that this change is not only meant for giving users the possibility of changing the chart to their needs - because they should not do this in this particular case. If users want to override stuff and therefore break their deployment, they already can do so today. This change is for us as maintainers being explicit about a security relevant setting of our product instead of leaving it open to users' environments. Developing a secure solution should not be about reacting on issues and CVEs, it should be secure by default. Also both In the end we are telling users only to change this value if they want to run a custom image. So from a maintenance point of view nothing changes. Defining a |
@Gacko thanks. |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Gacko, ubergesundheit The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/unhold |
Thanks! |
What this PR does / why we need it:
Set a default value for the
runAsGroup
in containersecurityContext
s of the controller and default backend.Also set the
runAsGroup
for opentelemetry and webhook Job containersecurityContext
s.This change is an improvement over the current suituation as it explicitly sets the group id through
runAsGroup
instead of relying on the default kubernetes behaviour.According to the Kubernetes API reference the runAsGroup defaults to the runtime default if not set. In reality this might be the runAsUser ID, but it doesn't have to.
Types of changes
How Has This Been Tested?
Checklist: