From 1799a798bf148bd327c9ac032c45f3e896cdac3f Mon Sep 17 00:00:00 2001 From: "Cheng-Chen, Chen" Date: Fri, 4 Dec 2026 21:35:55 +0800 Subject: [PATCH] Probe signed package recovery in its exact builder stage --- .github/workflows/publish-current-server.yml | 40 +++++++++++--------- scripts/probe-security-payload-recovery.sh | 4 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/publish-current-server.yml b/.github/workflows/publish-current-server.yml index b472b14992..d83be2cc17 100644 --- a/.github/workflows/publish-current-server.yml +++ b/.github/workflows/publish-current-server.yml @@ -30,6 +30,7 @@ jobs: TARGET_IMAGE: ghcr.io/pasturestack/server:${{ inputs.release_tag }} LAYERED_CANDIDATE_IMAGE: local/pasturestack/server-layered:${{ inputs.release_tag }}-${{ github.run_id }} CANDIDATE_IMAGE: local/pasturestack/server:${{ inputs.release_tag }}-${{ github.run_id }} + SECURITY_PROBE_IMAGE: local/pasturestack/security-builder:${{ github.run_id }} CANDIDATE_NAME: pasturestack-server-release-${{ github.run_id }} CATTLE_VOLUME: pasturestack-server-release-cattle-${{ github.run_id }} MYSQL_VOLUME: pasturestack-server-release-mysql-${{ github.run_id }} @@ -117,6 +118,27 @@ jobs: set -Eeuo pipefail bash scripts/check-server-source-gates.sh + - name: Verify real signed payload recovery in the exact security builder + shell: bash + run: | + set -euo pipefail + evidence="$RUNNER_TEMP/server-evidence" + # Reuse the exact completed build stage and its real signature tools. + # Final runtime installs offline and deliberately excludes gpgv. + docker build --target runtime_security_packages \ + --file source/server/Dockerfile.web-compose-release \ + --tag "$SECURITY_PROBE_IMAGE" source/server + docker run --rm --read-only --security-opt no-new-privileges \ + --tmpfs /tmp:rw,nosuid,size=256m \ + --mount "type=bind,source=$GITHUB_WORKSPACE/source/scripts/probe-security-payload-recovery.sh,target=/probe/run.sh,readonly" \ + --mount "type=bind,source=$GITHUB_WORKSPACE/source/server/scripts/download-ubuntu-security-updates.sh,target=/probe/download.sh,readonly" \ + --mount "type=bind,source=$GITHUB_WORKSPACE/source/server/security/ubuntu-security-approved-records.tsv,target=/probe/approved.tsv,readonly" \ + --mount "type=bind,source=$GITHUB_WORKSPACE/source/server/security/ubuntu-security-packages.lock,target=/probe/versions.lock,readonly" \ + --entrypoint /bin/sh "$SECURITY_PROBE_IMAGE" /probe/run.sh \ + >"$evidence/security-payload-recovery.json" + jq -e '.status == "PASS_NATIVE_OFFICIAL_PAYLOAD_RECOVERY" and .scope == "security-package-builder" and .forcedPayloadFailures == 1 and .actualAptHelper and .packageSetUnchanged and .aptSourcesUnchanged' \ + "$evidence/security-payload-recovery.json" + - name: Build exact release image once shell: bash working-directory: source @@ -187,22 +209,6 @@ jobs: cleanup_extract trap - EXIT - - name: Verify real signed payload recovery on the isolated candidate - shell: bash - run: | - set -euo pipefail - evidence="$RUNNER_TEMP/server-evidence" - docker run --rm --read-only --security-opt no-new-privileges \ - --tmpfs /tmp:rw,nosuid,size=256m \ - --mount "type=bind,source=$GITHUB_WORKSPACE/source/scripts/probe-security-payload-recovery.sh,target=/probe/run.sh,readonly" \ - --mount "type=bind,source=$GITHUB_WORKSPACE/source/server/scripts/download-ubuntu-security-updates.sh,target=/probe/download.sh,readonly" \ - --mount "type=bind,source=$GITHUB_WORKSPACE/source/server/security/ubuntu-security-approved-records.tsv,target=/probe/approved.tsv,readonly" \ - --mount "type=bind,source=$GITHUB_WORKSPACE/source/server/security/ubuntu-security-packages.lock,target=/probe/versions.lock,readonly" \ - --entrypoint /bin/sh "$CANDIDATE_IMAGE" /probe/run.sh \ - >"$evidence/security-payload-recovery.json" - jq -e '.status == "PASS_NATIVE_OFFICIAL_PAYLOAD_RECOVERY" and .forcedPayloadFailures == 1 and .actualAptHelper and .runtimePackageSetUnchanged and .aptSourcesUnchanged' \ - "$evidence/security-payload-recovery.json" - - name: Verify the actual candidate JDK security runtime shell: bash working-directory: source @@ -1025,7 +1031,7 @@ jobs: docker rm -f "$CANDIDATE_NAME" >/dev/null 2>&1 || true docker volume rm "$CATTLE_VOLUME" "$MYSQL_VOLUME" "$MYSQL_LOG_VOLUME" \ >/dev/null 2>&1 || true - docker image rm "$TARGET_IMAGE" "$CANDIDATE_IMAGE" "$TRIVY_IMAGE" \ + docker image rm "$TARGET_IMAGE" "$CANDIDATE_IMAGE" "$SECURITY_PROBE_IMAGE" "$TRIVY_IMAGE" \ >/dev/null 2>&1 || true sudo rm -rf \ "$RUNNER_TEMP/server-rootfs" \ diff --git a/scripts/probe-security-payload-recovery.sh b/scripts/probe-security-payload-recovery.sh index 72353480ea..611a78cf11 100644 --- a/scripts/probe-security-payload-recovery.sh +++ b/scripts/probe-security-payload-recovery.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Isolated release-image probe: real signed APT indexes and apt-helper, with one +# Isolated exact security-builder probe: real signed APT indexes and apt-helper, with one # test-only payload transport fault. Never installs packages or changes sources. set -eu test "$#" -eq 0 @@ -61,5 +61,5 @@ test "$(dpkg-deb -f "$file" Version)" = "$version" test "$(dpkg-deb -f "$file" Architecture)" = "$expected_arch" test "$packages_before" = "$(dpkg-query -W -f='${Package}\t${Version}\t${db:Status-Status}\n' | sha256sum)" test "$sources_before" = "$(find /etc/apt -type f -exec sha256sum {} + | LC_ALL=C sort | sha256sum)" -printf '{"status":"PASS_NATIVE_OFFICIAL_PAYLOAD_RECOVERY","package":"%s","version":"%s","sha256":"%s","bytes":%s,"snapshot":"%s","forcedPayloadFailures":1,"actualAptHelper":true,"runtimePackageSetUnchanged":true,"aptSourcesUnchanged":true}\n' \ +printf '{"status":"PASS_NATIVE_OFFICIAL_PAYLOAD_RECOVERY","scope":"security-package-builder","package":"%s","version":"%s","sha256":"%s","bytes":%s,"snapshot":"%s","forcedPayloadFailures":1,"actualAptHelper":true,"packageSetUnchanged":true,"aptSourcesUnchanged":true}\n' \ "$package" "$version" "$expected_sha" "$expected_size" "$snapshot"