Skip to content

Commit 428b500

Browse files
authored
Merge pull request kubernetes#90949 from pjbgf/seccomp-least-priv-kuberuntime
Add seccomp least privilege for kuberuntime
2 parents 3f8f999 + b451563 commit 428b500

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

pkg/kubelet/kuberuntime/kuberuntime_sandbox.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxLinuxConfig(pod *v1.Pod) (
148148
lc := &runtimeapi.LinuxPodSandboxConfig{
149149
CgroupParent: cgroupParent,
150150
SecurityContext: &runtimeapi.LinuxSandboxSecurityContext{
151-
Privileged: kubecontainer.HasPrivilegedContainer(pod),
152-
SeccompProfilePath: m.getSeccompProfile(pod.Annotations, "", pod.Spec.SecurityContext, nil),
151+
Privileged: kubecontainer.HasPrivilegedContainer(pod),
152+
153+
// Forcing sandbox to run as `runtime/default` allow users to
154+
// use least privileged seccomp profiles at pod level. Issue #84623
155+
SeccompProfilePath: v1.SeccompProfileRuntimeDefault,
153156
},
154157
}
155158

pkg/kubelet/kuberuntime/kuberuntime_sandbox_test.go

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,29 @@ func TestGeneratePodSandboxLinuxConfigSeccomp(t *testing.T) {
6767
expectedProfile string
6868
}{
6969
{
70-
description: "no seccomp defined at pod level should return empty",
71-
pod: newSeccompPod(nil, nil, "", ""),
72-
expectedProfile: "",
70+
description: "no seccomp defined at pod level should return runtime/default",
71+
pod: newSeccompPod(nil, nil, "", "runtime/default"),
72+
expectedProfile: "runtime/default",
7373
},
7474
{
75-
description: "seccomp field defined at pod level should be honoured",
76-
pod: newSeccompPod(&v1.SeccompProfile{Type: v1.SeccompProfileTypeRuntimeDefault}, nil, "", ""),
75+
description: "seccomp field defined at pod level should not be honoured",
76+
pod: newSeccompPod(&v1.SeccompProfile{Type: v1.SeccompProfileTypeUnconfined}, nil, "", ""),
7777
expectedProfile: "runtime/default",
7878
},
7979
{
8080
description: "seccomp field defined at container level should not be honoured",
81-
pod: newSeccompPod(nil, &v1.SeccompProfile{Type: v1.SeccompProfileTypeRuntimeDefault}, "", ""),
82-
expectedProfile: "",
81+
pod: newSeccompPod(nil, &v1.SeccompProfile{Type: v1.SeccompProfileTypeUnconfined}, "", ""),
82+
expectedProfile: "runtime/default",
8383
},
8484
{
85-
description: "seccomp annotation defined at pod level should be honoured",
86-
pod: newSeccompPod(nil, nil, v1.SeccompProfileRuntimeDefault, ""),
85+
description: "seccomp annotation defined at pod level should not be honoured",
86+
pod: newSeccompPod(nil, nil, "unconfined", ""),
8787
expectedProfile: "runtime/default",
8888
},
8989
{
9090
description: "seccomp annotation defined at container level should not be honoured",
91-
pod: newSeccompPod(nil, nil, "", v1.SeccompProfileRuntimeDefault),
92-
expectedProfile: "",
93-
},
94-
{
95-
description: "prioritise pod field over pod annotation",
96-
pod: newSeccompPod(&v1.SeccompProfile{
97-
Type: v1.SeccompProfileTypeLocalhost,
98-
LocalhostProfile: pointer.StringPtr("pod-field"),
99-
}, nil, "localhost/pod-annotation", ""),
100-
expectedProfile: "localhost/" + filepath.Join(fakeSeccompProfileRoot, "pod-field"),
91+
pod: newSeccompPod(nil, nil, "", "unconfined"),
92+
expectedProfile: "runtime/default",
10193
},
10294
}
10395

0 commit comments

Comments
 (0)