Repository navigation
fix: move the operator image to Azure Linux distroless - #525
Conversation
Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the runtime-image hardening change.
No open issues 🎉
What changed in this PR
Moves the operator runtime from an Alpine development container to Azure Linux distroless, reducing unnecessary packages while preserving the existing UID/GID for Helm upgrade compatibility.
Changes:
- Replaces the runtime base image while retaining
USER 100:101. - Adds image-content checks and test fixtures to reject SSH tools, shells, and package managers.
- Integrates checks into build workflows and documents using
kubectl debugfor troubleshooting.
| File | Description |
|---|---|
operator/src/Dockerfile |
Switches to Azure Linux distroless and preserves UID/GID. |
operator/documentdb-helm-chart/values.yaml |
Updates security-context comments; values remain unchanged. |
CHANGELOG.md |
Documents the security change and shell-free troubleshooting. |
.github/workflows/test-e2e.yml |
Adds image-check scripts to workflow path triggers. |
.github/workflows/test-build-and-package.yml |
Runs check-script tests and validates operator images. |
.github/workflows/build_operator_images.yml |
Checks candidate operator and sidecar images before pushing. |
.github/scripts/assert-minimal-image.sh |
Rejects images containing prohibited runtime tools. |
.github/scripts/assert-minimal-image_test.sh |
Adds clean and prohibited-file image fixtures to test the check. |
Review effort: Balanced
Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
Signed-off-by: Guanzhou Song <85122868+guanzhousongmicrosoft@users.noreply.github.com>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (ci, docs); P0 keyword "cve" in body; effort from diff stats (142+28 LOC, 9 files) If a label is wrong, ping |
be57582
into
documentdb:main
Every operator release (1.0.0 to 1.2.1) is built on
mcr.microsoft.com/devcontainers/base:alpine, so the image carries a full dev container userland (OpenSSH client, BusyBox, bash, zsh,apk,sudo,git) at 838–851 MB. Scanners now flag it for SSHole (CVE-2026-123158). The image has only the OpenSSH client and never runssshd, so it is not exploitable, but future CVEs in any of those packages would flag it the same way.The
apk upgradeadded in 1.1.1 doesn't fix that: it helps only after Alpine ships a fix, and keeps packages the operator never uses. The manager is a static Go binary that needs only CA certificates, tzdata and/tmp, so the runtime stage moves tomcr.microsoft.com/azurelinux/distroless/minimal:3.0(5 packages, no shell or package manager, 93–98 MB). It keeps uid/gid 100:101, so the chart's pinnedrunAsUser/runAsGroupand--reuse-valuesupgrades still work.kubectl execinto the operator pod no longer has a shell; usekubectl debug.assert-minimal-image.shfails the build if the image ships an SSH binary, a shell or a package manager (PR CI for the operator, the candidate build for operator and sidecar). It matches by file name, so it catches a distro base coming back, not a renamed binary. Against the released 1.2.1 image it fails, listingssh,scp,sftp,ssh-agent,bash,zsh,busyboxandapkamong others.The build summary echoes in
test-build-and-package.ymlare grouped into one redirect because the workflow linter reports every line of a changed file, and that block's SC2129 failed it.