From 31baf53e61a221561380551d27890efa9ea37a61 Mon Sep 17 00:00:00 2001 From: RAHMAT AL ZAMI <112936589+zamibd@users.noreply.github.com> Date: Sat, 28 Nov 2026 20:37:16 +0000 Subject: [PATCH] Upgrade Alpine base packages so security fixes reach the image The runtime stage only ran "apk add", which leaves the packages already in the alpine:3.24 base image at the versions that image was built with. Alpine had published fixes the image did not get: - zlib 1.3.2-r1 -> 1.4-r0 (CVE-2026-4738) - libssl3 / libcrypto3 3.5.9-r0 -> 3.5.9-r1 Run "apk upgrade" first. Trivy now reports no vulnerabilities at all. The scans in CI and before a release now fail on fixable findings of any severity. Trivy rated CVE-2026-4738 MEDIUM while Docker Scout rates it 9.4 critical, so the HIGH/CRITICAL filter let it through; with every package upgraded, any fixable finding means the image is not current. --- .github/workflows/ci.yml | 8 +++++--- .github/workflows/release.yml | 1 - Dockerfile | 7 ++++++- README.md | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ab6e6e..fc945ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,8 +86,11 @@ jobs: REQUIRE_HTTP3: '1' run: tests/smoke.sh nginx:ci - # Fails on HIGH or CRITICAL vulnerabilities in the image's Alpine - # packages when a fixed package exists. The packages are the same on + # Fails on any vulnerability in the image's Alpine packages that has a + # fixed package, whatever its severity: the build upgrades every + # package, so a fixable finding means the image is not current. + # Severities differ between scanners (Trivy and Docker Scout rate some + # CVEs differently), so filtering by severity would let some through. The packages are the same on # both architectures, so one scan is enough. - name: Scan image for known vulnerabilities if: matrix.arch == 'amd64' @@ -95,6 +98,5 @@ jobs: with: image-ref: nginx:ci scanners: vuln - severity: HIGH,CRITICAL ignore-unfixed: true exit-code: '1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8cf3005..7e66fee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -202,7 +202,6 @@ jobs: with: image-ref: nginx:release-test scanners: vuln - severity: HIGH,CRITICAL ignore-unfixed: true exit-code: '1' diff --git a/Dockerfile b/Dockerfile index d890db5..bdbbd2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,7 +99,12 @@ ENV NGINX_VERSION=${NGINX_VERSION} # UID/GID 101 matches the official nginx images, so existing volume # ownership keeps working. -RUN addgroup -g 101 -S nginx \ +# +# "apk upgrade" matters: the Alpine base image is only rebuilt for Alpine +# point releases, so the packages it ships (musl, zlib, ...) can be behind +# the repository's security fixes. "apk add" alone would keep them. +RUN apk upgrade --no-cache \ + && addgroup -g 101 -S nginx \ && adduser -S -D -H -u 101 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \ && apk add --no-cache \ ca-certificates \ diff --git a/README.md b/README.md index bec2dad..136f53a 100644 --- a/README.md +++ b/README.md @@ -276,7 +276,7 @@ The smoke test starts the image read-only with all capabilities dropped and chec - **Lint**: hadolint for the Dockerfile, ShellCheck for the scripts, actionlint for the workflows. - **Build and smoke test** on `amd64` and `arm64`, both on native runners. -- **Vulnerability scan** with Trivy: fails on HIGH or CRITICAL findings in the image's Alpine packages that have a fix available. nginx itself and the two modules are compiled from source, so they are not covered by the scan; keep them current through the pinned versions above. +- **Vulnerability scan** with Trivy: fails on any finding in the image's Alpine packages that has a fix available, whatever its severity. The build runs `apk upgrade`, so every fixed package Alpine has published is in the image. nginx itself and the two modules are compiled from source, so they are not covered by the scan; keep them current through the pinned versions above. [Dependabot](.github/dependabot.yml) opens weekly pull requests for new versions of the GitHub Actions, the Alpine base image and the test dependencies.