diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd3a050..8d00723 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -197,6 +197,16 @@ jobs: docker run --rm --read-only --cap-drop=ALL \ --security-opt=no-new-privileges rust-panosmcp:ci --version + # The runtime is distroless base-nossl: no libssl/libcrypto (rustls-only + # binary, libssl3t64 carries an unfixed CVE) but libgcc_s must be staged in. + container_id=$(docker create rust-panosmcp:ci) + files=$(docker export "$container_id" | tar -t) + docker rm "$container_id" > /dev/null + if echo "$files" | grep -E 'libssl|libcrypto'; then + echo "FAIL: image ships libssl/libcrypto"; exit 1 + fi + echo "$files" | grep -q 'libgcc_s\.so\.1$' || { echo "FAIL: libgcc_s.so.1 missing from image"; exit 1; } + # Regression test for mecmcp#357: config paths must survive operator overrides. # Docker replaces CMD entirely when the caller supplies args, but ENTRYPOINT # is appended to. Security-relevant flags (device-mapping, tokens-file, diff --git a/.github/workflows/digest-drift.yml b/.github/workflows/digest-drift.yml index 7745fc4..bd1ddc9 100644 --- a/.github/workflows/digest-drift.yml +++ b/.github/workflows/digest-drift.yml @@ -23,21 +23,24 @@ jobs: id: drift run: | set -euo pipefail - line=$(grep -m1 '^FROM gcr.io/distroless/cc-debian13' Dockerfile) + # The last distroless FROM is the runtime; the first is only the libgcc donor. + line=$(grep '^FROM gcr.io/distroless/' Dockerfile | tail -1) + repo=$(printf '%s' "$line" | sed -n 's|^FROM gcr.io/distroless/\([^:@]*\).*|\1|p') pinned=$(printf '%s' "$line" | sed -n 's/.*@\(sha256:[0-9a-f]*\).*/\1/p') - tag=$(printf '%s' "$line" | sed -n 's|^FROM gcr.io/distroless/cc-debian13:\([^@]*\)@.*|\1|p') - [ -n "$pinned" ] && [ -n "$tag" ] || { echo "could not parse Dockerfile FROM line"; exit 1; } + tag=$(printf '%s' "$line" | sed -n 's|^FROM gcr.io/distroless/[^:]*:\([^@]*\)@.*|\1|p') + [ -n "$pinned" ] && [ -n "$tag" ] && [ -n "$repo" ] || { echo "could not parse Dockerfile FROM line"; exit 1; } - token=$(curl -sf "https://gcr.io/v2/token?scope=repository:distroless/cc-debian13:pull&service=gcr.io" \ + token=$(curl -sf "https://gcr.io/v2/token?scope=repository:distroless/${repo}:pull&service=gcr.io" \ | python3 -c "import sys,json;print(json.load(sys.stdin)['token'])") current=$(curl -sfI -H "Authorization: Bearer $token" \ -H "Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json" \ - "https://gcr.io/v2/distroless/cc-debian13/manifests/$tag" \ + "https://gcr.io/v2/distroless/${repo}/manifests/$tag" \ | tr -d '\r' | sed -n 's/^docker-content-digest: //Ip') [ -n "$current" ] || { echo "registry did not return a digest"; exit 1; } - echo "tag=$tag"; echo "pinned=$pinned"; echo "current=$current" + echo "repo=$repo tag=$tag"; echo "pinned=$pinned"; echo "current=$current" { + echo "repo=$repo" echo "tag=$tag" echo "pinned=$pinned" echo "current=$current" @@ -48,6 +51,7 @@ jobs: if: steps.drift.outputs.drifted == 'true' env: GH_TOKEN: ${{ github.token }} + REPO: ${{ steps.drift.outputs.repo }} TAG: ${{ steps.drift.outputs.tag }} PINNED: ${{ steps.drift.outputs.pinned }} CURRENT: ${{ steps.drift.outputs.current }} @@ -55,7 +59,7 @@ jobs: set -euo pipefail title="Pinned distroless digest has drifted from the registry" body=$(printf '%s\n' \ - "\`gcr.io/distroless/cc-debian13:$TAG\` no longer resolves to the pinned digest." \ + "\`gcr.io/distroless/$REPO:$TAG\` no longer resolves to the pinned digest." \ "" \ "| | digest |" \ "|---|---|" \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 3005a42..f074dcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- The image runs on `distroless/base-nossl-debian13` (libgcc_s staged from the + pinned cc image), dropping libssl3t64 and its unfixed CVE-2026-124709. The + binary is rustls-only. - Container images are published for `linux/amd64` and `linux/arm64`, so Apple Silicon pulls a native image instead of failing with `no matching manifest` (mechubsec/rustjunosmcp#648). Each platform builds on its own native runner. diff --git a/Dockerfile b/Dockerfile index 5d5c4a5..1cc4f12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,10 @@ # so a digest-only Dependabot refresh moves the compiler across a point # release while the CI sync check still reports a match. Digest resolved from # the registry 2026-08-24. +# Source of libgcc-s1 only; the runtime is base-nossl, which lacks it. Keep it +# ahead of the builder so the runtime stays the last FROM. +FROM gcr.io/distroless/cc-debian13:nonroot@sha256:cb87acc574abe719b6e5c547384defa2f7b1f24af9605d3f618cf852495d8be2 AS libgcc + FROM rust:1.100.0-slim-bookworm@sha256:7c7d4eb4d05b7781187a327809466cfddf29753f6defdc3d19a0e291951b7a37 AS builder WORKDIR /src @@ -24,11 +28,25 @@ COPY rust-panosmcp-core/src rust-panosmcp-core/src RUN cargo build --release --locked --bin rust-panosmcp -# Runtime base digest verified against registry on 2026-11-10. +# libgcc_s.so.1 is the one library the binary needs beyond glibc, and +# base-nossl does not ship it. Stage it with its dpkg records (status.d) so +# Trivy and the SBOM still see libgcc-s1 and gcc-14-base. The multiarch +# directory comes from the builder's own triplet (x86_64 or aarch64). +COPY --from=libgcc / /cc/ +RUN triplet="$(gcc -dumpmachine | sed 's/-pc-/-/')" \ + && install -d "/stage-libgcc/usr/lib/${triplet}" /stage-libgcc/var/lib/dpkg/status.d \ + && cp -a "/cc/usr/lib/${triplet}/libgcc_s.so.1" "/stage-libgcc/usr/lib/${triplet}/" \ + && cp -a /cc/var/lib/dpkg/status.d/libgcc-s1 /cc/var/lib/dpkg/status.d/libgcc-s1.md5sums \ + /cc/var/lib/dpkg/status.d/gcc-14-base /cc/var/lib/dpkg/status.d/gcc-14-base.md5sums \ + /stage-libgcc/var/lib/dpkg/status.d/ + +# Runtime base: distroless base-nossl (no libssl3t64/libcrypto: the binary is +# rustls-only, and libssl3t64 carries unfixed CVE-2026-124709). Digest is the +# multi-arch index, verified against the registry on 2026-11-21. # Digests have no version ordering and must be validated by resolving the tag -# against the registry (docker pull gcr.io/distroless/cc-debian13:nonroot), +# against the registry (docker pull gcr.io/distroless/base-nossl-debian13:nonroot), # never by comparing hashes or by matching sibling repos. -FROM gcr.io/distroless/cc-debian13:nonroot@sha256:cb87acc574abe719b6e5c547384defa2f7b1f24af9605d3f618cf852495d8be2 +FROM gcr.io/distroless/base-nossl-debian13:nonroot@sha256:89815d620ac01d8de13cdaf04d19ed874447ca2296d4985b14b818f6e5e47854 ARG VERSION=0.2.0 ARG VCS_REF=unknown @@ -41,6 +59,7 @@ LABEL org.opencontainers.image.title="rust-panosmcp" \ # Official MCP Registry ownership check: must equal server.json "name". LABEL io.modelcontextprotocol.server.name="io.github.mechubsec/rustpanosmcp" +COPY --from=builder /stage-libgcc/ / COPY --from=builder --chown=nonroot:nonroot /src/target/release/rust-panosmcp /usr/local/bin/rust-panosmcp ENV RUST_LOG=info diff --git a/scripts/verify-packaging.sh b/scripts/verify-packaging.sh index 91b97ef..fade0fa 100755 --- a/scripts/verify-packaging.sh +++ b/scripts/verify-packaging.sh @@ -130,7 +130,7 @@ grep -Eq '^FROM rust:.*@sha256:[0-9a-f]{64} AS builder$' Dockerfile # Pins the approved runtime base. This must move whenever the Dockerfile's base # moves — it is the check that stops the base drifting silently, so it is # deliberately exact rather than a wildcard over distroless variants. -grep -Eq '^FROM gcr.io/distroless/cc-debian13:nonroot@sha256:[0-9a-f]{64}$' Dockerfile +grep -Eq '^FROM gcr.io/distroless/base-nossl-debian13:nonroot@sha256:[0-9a-f]{64}$' Dockerfile if grep -En '(^|[[:space:]])(curl|wget|apt-get|apk|dnf)([[:space:]]|$)' Dockerfile; then echo "runtime/container build contains an unapproved package-fetch command" >&2 exit 1