diff --git a/pkg/server/container_create.go b/pkg/server/container_create.go index 1b79793e2..315cac6ee 100644 --- a/pkg/server/container_create.go +++ b/pkg/server/container_create.go @@ -372,6 +372,11 @@ func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxP securityContext.GetCapabilities()) } } + // Clear all ambient capabilities. The implication of non-root + caps + // is not clearly defined in Kubernetes. + // See https://github.com/kubernetes/kubernetes/issues/56374 + // Keep docker's behavior for now. + g.Spec().Process.Capabilities.Ambient = []string{} g.SetProcessSelinuxLabel(processLabel) g.SetLinuxMountLabel(mountLabel) diff --git a/pkg/server/container_create_test.go b/pkg/server/container_create_test.go index 92f81678d..9c02decc9 100644 --- a/pkg/server/container_create_test.go +++ b/pkg/server/container_create_test.go @@ -261,6 +261,7 @@ func TestContainerCapabilities(t *testing.T) { assert.NotContains(t, spec.Process.Capabilities.Inheritable, exclude) assert.NotContains(t, spec.Process.Capabilities.Permitted, exclude) } + assert.Empty(t, spec.Process.Capabilities.Ambient) } }