Skip to content

Commit 9f6ec86

Browse files
committed
fix(manifests): set explicit runAsUser/runAsGroup on init container
Copilot's HIGH-severity review flagged two related concerns on the init container's securityContext. OMNI verification (deep mode, embedded diff only) confirmed: - Claim 1 (change readOnlyRootFilesystem to false): REJECTED. OCI runtime creates mount-point directories before applying the readonly rootfs remount (runc mountToRootfs runs before the readonly remount). The emptyDir at /nvml-libs is a separate volume mounted on top of the rootfs; writes to it are unaffected by the rootfs read-only restriction. Weakening the securityContext here trades real protection for a non-issue. - Claim 2 (add runAsUser/runAsGroup: 0): ACCEPTED. busybox:1.36.1 has no USER directive and runs as UID 0 today, but adding explicit runAsUser/runAsGroup makes the intent unambiguous and is robust to a future image change (e.g. if someone swaps busybox for a distroless image with USER 65534, root-owned 700 driver files would become unreadable). The existing kepler main container also uses runAsNonRoot: false without runAsUser, so this PR is just hardening the init container ahead of the curve. Also dropped the redundant quotes around [ALL] in the Helm template for consistency with the raw manifest (commit fedaef7 fixed the raw manifest; the Helm template's drop: ["ALL"] was missed). The Helm template is excluded from yamllint-strict in .pre-commit-config.yaml so this didn't break CI, but consistency is better. Signed-off-by: Himanshu Verma <himnshuverma10152006@gmail.com>
1 parent 372e255 commit 9f6ec86

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

manifests/helm/kepler/templates/daemonset.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ spec:
4747
image: "{{ .Values.daemonset.nvidia.nvmlInitImage.repository }}:{{ .Values.daemonset.nvidia.nvmlInitImage.tag }}"
4848
imagePullPolicy: IfNotPresent
4949
securityContext:
50-
# Runs as root (runAsNonRoot: false) because driver-dir files may be
51-
# root-owned 700. All Linux capabilities are dropped; no setuid/setgid.
50+
# Runs as root (UID 0, GID 0) to read driver-dir files that may be
51+
# root-owned 700. Explicit runAsUser/runAsGroup so behavior does not
52+
# depend on the image's USER directive. All Linux capabilities are
53+
# dropped; no setuid/setgid.
5254
runAsNonRoot: false
55+
runAsUser: 0
56+
runAsGroup: 0
5357
readOnlyRootFilesystem: true
5458
allowPrivilegeEscalation: false
5559
capabilities:
56-
drop: ["ALL"]
60+
drop: [ALL]
5761
command:
5862
- sh
5963
- -c

manifests/k8s/daemonset.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ spec:
3131
image: busybox:1.36.1
3232
imagePullPolicy: IfNotPresent
3333
securityContext:
34-
# Runs as root (runAsNonRoot: false) because driver-dir files may be
35-
# root-owned 700. All Linux capabilities are dropped; no setuid/setgid.
34+
# Runs as root (UID 0, GID 0) to read driver-dir files that may be
35+
# root-owned 700. Explicit runAsUser/runAsGroup so behavior does not
36+
# depend on the image's USER directive. All Linux capabilities are
37+
# dropped; no setuid/setgid.
3638
runAsNonRoot: false
39+
runAsUser: 0
40+
runAsGroup: 0
3741
readOnlyRootFilesystem: true
3842
allowPrivilegeEscalation: false
3943
capabilities:

0 commit comments

Comments
 (0)