Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

feat(release): sign published image attestations with keyless cosign (#3914)

Matheus Oliveirac357d37fa93e
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1dbd9bc1b4..7c9dd4356e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -19,9 +19,10 @@ on:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
+# Only the jobs that need an OIDC token request one: push-native (assume the
+# AWS role for ECR Public) and sign-images (that, plus a Fulcio certificate).
permissions:
contents: read
- id-token: write
# Per-tag concurrency. Back-to-back tag pushes (e.g. 1.5.3 and 1.6.0 landing
# minutes apart) resolve to different ${{ github.ref }} values, so they run
@@ -139,6 +140,17 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
+ permissions:
+ contents: read
+ id-token: write
+
+ # Consumed by sign-images. Each is the digest of the pushed manifest index,
+ # which is what cosign signs; the tags above are mutable, the digests are not.
+ outputs:
+ native-digest: ${{ steps.native.outputs.digest }}
+ baseline-digest: ${{ steps.baseline.outputs.digest }}
+ compat-digest: ${{ steps.compat.outputs.digest }}
+
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -194,6 +206,7 @@ jobs:
registry-type: public
- name: Build and push native multi-arch image
+ id: native
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
@@ -235,6 +248,7 @@ jobs:
mv native/arm64/*-runner native/arm64/application
- name: Build and push ARMv8.0 baseline image
+ id: baseline
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
@@ -263,6 +277,7 @@ jobs:
cache-to: type=gha,scope=floci-arm64-baseline,mode=max
- name: Build and push compat multi-arch image
+ id: compat
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
@@ -289,3 +304,64 @@ jobs:
vcs-ref=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
+
+ # ── Sign the published images ────────────────────────────────────────────
+ # Kept out of push-native on purpose: a Fulcio or Rekor outage mid-push would
+ # otherwise leave `latest` updated while -baseline and -compat never publish,
+ # and recovery would mean rebuilding everything. Signing only reads digests
+ # that are already in the registries, so this job can be rerun on its own.
+ sign-images:
+ name: Sign published images
+ needs: push-native
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+
+ permissions:
+ contents: read
+ id-token: write
+
+ steps:
+ - name: Install Cosign
+ # Keyless signing: the job's GitHub Actions OIDC token exchanges for a
+ # short-lived Fulcio certificate and the signature is recorded in Rekor's
+ # transparency log. No signing key to generate, store, or rotate.
+ uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
+ with:
+ cosign-release: 'v3.1.3'
+
+ # cosign writes each signature back to the registry beside the image it
+ # signs, so both destinations need a logged-in session here as well.
+ - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Configure AWS credentials
+ uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
+ with:
+ role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
+ aws-region: us-east-1
+
+ - name: Login to Amazon ECR Public
+ uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
+ with:
+ registry-type: public
+
+ - name: Sign images and their provenance/SBOM attestations
+ # --recursive signs the pushed index and every manifest it references,
+ # which includes the provenance/sbom attestation manifests BuildKit
+ # attaches, not just the per-platform images. Those attestations are
+ # unsigned in-toto JSON rather than cosign's own DSSE envelope, so a
+ # consumer verifies them with `cosign verify` against the attestation
+ # manifest's own digest (found via `docker buildx imagetools inspect`),
+ # not `cosign verify-attestation`.
+ env:
+ DIGESTS: >-
+ ${{ needs.push-native.outputs.native-digest }}
+ ${{ needs.push-native.outputs.baseline-digest }}
+ ${{ needs.push-native.outputs.compat-digest }}
+ run: |
+ for digest in $DIGESTS; do
+ cosign sign --yes --recursive "floci/floci@${digest}"
+ cosign sign --yes --recursive "public.ecr.aws/floci/floci@${digest}"
+ done
diff --git a/docs/configuration/docker-images.md b/docs/configuration/docker-images.md
index ffe6a8991f..6c8c121f25 100644
--- a/docs/configuration/docker-images.md
+++ b/docs/configuration/docker-images.md
@@ -64,6 +64,47 @@ image: floci/floci:nightly
Standard and compat images are published as multi-arch manifests supporting `linux/amd64` and `linux/arm64`. Baseline images are intentionally `linux/arm64` only.
+## Verifying Image Signatures
+
+Release images are signed with [cosign](https://docs.sigstore.dev/) in keyless mode: the release workflow trades its GitHub Actions OIDC token for a short-lived Fulcio certificate and records the signature in the Rekor transparency log. There is no public key to distribute: you verify *who* produced the image instead of *which key* signed it.
+
+```sh
+cosign verify \
+ --certificate-identity-regexp '^https://github\.com/floci-io/floci/\.github/workflows/release\.yml@refs/tags/' \
+ --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
+ floci/floci:x.y.z
+```
+
+The signing identity is the release workflow's own ref, so the regexp above accepts any release tag. To accept exactly one release, drop the regexp and pin the identity:
+
+```sh
+--certificate-identity 'https://github.com/floci-io/floci/.github/workflows/release.yml@refs/tags/x.y.z'
+```
+
+Both registries carry the same signatures: substitute `public.ecr.aws/floci/floci:x.y.z` and the command is otherwise identical. Tags are mutable, so for a check you can rely on, verify a digest (`floci/floci@sha256:...`) rather than a tag.
+
+Only release images are signed. Nightly images are not.
+
+!!! note "Requires cosign v2.6.3 or later"
+ These signatures use the standardized Sigstore bundle format. cosign v2.6.3 and later (including v3) read it automatically. Older versions cannot verify these signatures.
+
+### Provenance and SBOM Attestations
+
+Release images carry BuildKit provenance (SLSA) and SPDX SBOM attestations, attached to the manifest index as separate manifests. Signing is recursive, so the index, every per-platform image, and every attestation manifest are each signed individually. Tampering with an attestation changes its digest, which changes the index descriptor pointing at it, which changes the signed index digest.
+
+List the attached manifests and verify one by its own digest:
+
+```sh
+docker buildx imagetools inspect floci/floci:x.y.z --format '{{json .Manifest}}'
+
+cosign verify \
+ --certificate-identity-regexp '^https://github\.com/floci-io/floci/\.github/workflows/release\.yml@refs/tags/' \
+ --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
+ floci/floci@sha256:<attestation-manifest-digest>
+```
+
+Use `cosign verify`, not `cosign verify-attestation`. The latter targets cosign's own DSSE-wrapped attestations; BuildKit's attestations are plain in-toto manifests with no signature envelope of their own, so they are signed, and verified, by digest.
+
## Raspberry Pi 4 and older ARM64 CPUs
If the standard ARM64 image exits with `CPU features [FP, ASIMD, CRC32, LSE] not supported`, use the `-baseline` release tag. The baseline image is compiled with GraalVM `-march=armv8-a`, so it does not require LSE. For example, use `floci/floci:latest-baseline` or pin `floci/floci:x.y.z-baseline`.