-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support for dropping inheritable capabilities #8356
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
Support for dropping inheritable capabilities #8356
Conversation
Marking this as a cherry-pick candidate since it is a regression |
Moby doesn't let users supply a base OCI spec to use so I don't think we'd need any changes. |
Thanks Brian! |
I think docs would be a good place to start. @cji, do you have thoughts on whether a warning in the log would be useful or just noisy? |
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 with one nit
oci/spec_opts.go
Outdated
@@ -943,6 +943,11 @@ func WithCapabilities(caps []string) SpecOpts { | |||
s.Process.Capabilities.Bounding = caps | |||
s.Process.Capabilities.Effective = caps | |||
s.Process.Capabilities.Permitted = caps | |||
if caps == nil { |
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.
if caps == nil { | |
if len(caps) == 0 { |
I see that filterCaps
does effectively drop everything if len(caps)==0
anyway, but it looks a little more explicit in WithCapabilities
this way.
Signed-off-by: Derek McGowan <derek@mcg.dev>
8b4384f
to
d0527e2
Compare
I do like the idea of a warning since if I understand this change correctly, instead of failing to start a container with this configuration, it will now properly limit the bounding set silently. Giving a warning to the user that may not otherwise realize the capabilities their container has aren't what they expected sounds useful for any debugging they might end up having to do. |
It'll properly limit the inheritable set. Note that this only applies if inheritable caps have been set, either explicitly or through an overridden base spec (like the CRI plugin supports).
I'm wondering too: should we warn for all containers (which could be quite noisy), or only warn at startup if an overridden |
+1 on the second approach as well. |
Created #8364 to track. That change should not be a part of this PR since this PR is focused on the bug fix. |
Agreed, that's why I approved this one already. |
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
The inheritable capabilities set should never be larger than the bounding capabilities set. When a base spec is provided with non-empty inheritable capabilities today, the container will fail to run when those capabilities are explicitly dropped. This issue is only seen when a base spec with inheritable capabilities is explicitly provided in the configuration file, the default spec already removed inheritable capabilities in GHSA-c9cp-9c75-9v8c. Since the container is unable to start with this setup, there is no security concern. It may be worth a discussion whether more should be done to warn users who may have set this in their configuration before the GHSA, whether through logging or our documentation.
The error seen when dropping the bounding capabilities to less than the inheritable capabilities is