Skip to content

Commit d4fdfb1

Browse files
committed
fix(docker): keep supervisor binary root-owned for rootless Podman
The Podman driver mounts the supervisor image read-only into the sandbox container at /opt/openshell/bin and runs that container as UID 0, but deliberately drops DAC_OVERRIDE for hardening (container.rs:419). With --chown=65534:65534 --chmod=0550 the binary was r-xr-x--- owned by UID 65534, so the container's UID 0 fell into "other" with no read or exec access and the supervisor crashed on start (ContainerExited code 1). Docker and Kubernetes both retain DAC_OVERRIDE, so root could still exec the file — which is why this regression only surfaced in the Podman e2e job. Drop --chown from the supervisor COPY so the binary stays root-owned. Keep --chmod=0550: the security win was dropping world-execute, not changing the owner. The chown bought nothing here because the container is always UID 0 regardless of driver, but it actively broke the only driver that drops DAC_OVERRIDE.
1 parent e164a7e commit d4fdfb1

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎deploy/docker/Dockerfile.supervisor‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ FROM scratch AS supervisor
2323

2424
ARG TARGETARCH
2525

26-
# --chmod=0550 preserves the executable bit through actions/upload-artifact +
27-
# download-artifact (which strip exec perms during the roundtrip) without
28-
# granting world-execute. --chown uses numeric 65534:65534 (nobody:nobody)
29-
# because scratch has no /etc/passwd to resolve a named user against. This
30-
# scratch image is only consumed by the init-container copy-self path, so
31-
# the destination pod's USER governs what can execute the binary.
32-
COPY --chown=65534:65534 --chmod=0550 deploy/docker/.build/prebuilt-binaries/${TARGETARCH}/openshell-sandbox /openshell-sandbox
26+
# --chmod=0550 drops world-execute and survives the actions/upload-artifact
27+
# + download-artifact roundtrip (which strips exec perms). Ownership is left
28+
# at root (0:0) deliberately: the Podman driver mounts this image as a
29+
# read-only image volume into the sandbox container and drops DAC_OVERRIDE,
30+
# so the container's UID 0 must own the binary to read+exec it. Mode 0550
31+
# (r-xr-x---) is the security win; the chown to a non-root UID was breaking
32+
# Podman without buying anything since the container is always UID 0.
33+
COPY --chmod=0550 deploy/docker/.build/prebuilt-binaries/${TARGETARCH}/openshell-sandbox /openshell-sandbox
3334

3435
ENTRYPOINT ["/openshell-sandbox"]

0 commit comments

Comments
 (0)