Skip to content

Commit 72ac2ff

Browse files
committed
Do not drop all capabilities
- previous configurations didn't work with ESXi runtime - dropping all capabilities except CHOWN, DAC_OVERRIDE, and FOWNER - CHOWN is necessary to change a file's owner, the second is necessary to permit chown to traverse directories to which root doesn't otherwise have access. FOWNER bypass checks on operations that require the file system UID of the process to match the UID of the file.
1 parent b0a099b commit 72ac2ff

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

internal/resource/statefulset.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,20 @@ func (builder *StatefulSetBuilder) podTemplateSpec(previousPodAnnotations map[st
521521
SecurityContext: &corev1.SecurityContext{
522522
RunAsUser: pointer.Int64Ptr(0),
523523
Capabilities: &corev1.Capabilities{
524-
Drop: []corev1.Capability{"ALL"},
525-
Add: []corev1.Capability{"CHOWN", "FOWNER"},
524+
// drop default set from Docker except for CHOWN, FOWNER, and DAC_OVERRIDE
525+
Drop: []corev1.Capability{
526+
"FSETID",
527+
"KILL",
528+
"SETGID",
529+
"SETUID",
530+
"SETPCAP",
531+
"NET_BIND_SERVICE",
532+
"NET_RAW",
533+
"SYS_CHROOT",
534+
"MKNOD",
535+
"AUDIT_WRITE",
536+
"SETFCAP",
537+
},
526538
},
527539
},
528540
Command: []string{

internal/resource/statefulset_test.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,20 @@ var _ = Describe("StatefulSet", func() {
10861086
"Image": Equal("rabbitmq-image-from-cr"),
10871087
"SecurityContext": PointTo(MatchFields(IgnoreExtras, Fields{
10881088
"Capabilities": PointTo(MatchAllFields(Fields{
1089-
"Drop": ConsistOf([]corev1.Capability{"ALL"}),
1090-
"Add": ConsistOf([]corev1.Capability{"CHOWN", "FOWNER"}),
1089+
"Drop": ConsistOf([]corev1.Capability{
1090+
"FSETID",
1091+
"KILL",
1092+
"SETGID",
1093+
"SETUID",
1094+
"SETPCAP",
1095+
"NET_BIND_SERVICE",
1096+
"NET_RAW",
1097+
"SYS_CHROOT",
1098+
"MKNOD",
1099+
"AUDIT_WRITE",
1100+
"SETFCAP",
1101+
}),
1102+
"Add": BeEmpty(),
10911103
})),
10921104
})),
10931105
"Command": ConsistOf(

0 commit comments

Comments
 (0)