Skip to content

ci: sign releases with build provenance and an attested SBOM - #78

Merged
inth3shadows merged 3 commits into
masterfrom
p5-signed-releases
Nov 19, 2026
Merged

inth3shadows merged 3 commits into
masterfrom
p5-signed-releases

Conversation

@inth3shadows

@inth3shadows inth3shadows commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

What

From the next release on, every codeshot release asset can be checked for where it came from:

  • Build provenance. A SLSA provenance attestation records the workflow run, commit and tag that built each archive. It is signed keylessly through Sigstore with the release job's OIDC token, so no key or secret is involved.
  • SBOM. A CycloneDX SBOM of the module, codeshot_<version>.cdx.json, is published with the release, listed in checksums.txt, and attested for the same archives.
  • Verifying a download with the GitHub CLI:
    sha256sum -c checksums.txt --ignore-missing
    gh attestation verify codeshot_0.5.0_linux_amd64.tar.gz --repo inth3shadows/codeshot
    gh attestation verify codeshot_0.5.0_linux_amd64.tar.gz --repo inth3shadows/codeshot \
      --predicate-type https://cyclonedx.org/bom

This is P5c of the program. Only .github/workflows/release.yml and the docs change.

How

  • SBOM: go run github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@v1.12.0 mod -licenses -json. It is pinned through the Go checksum database, so no third-party action is added. The tag checkout gives it the version. There is one SBOM for the module, because all six builds share its dependencies.
  • Attestations: actions/attest v4.2.2, SHA-pinned, in a separate publish job (see Changes since review): provenance over checksums.txt (every archive and the SBOM), then the SBOM for the six archives.
  • Permissions: the workflow grants nothing at the top level (permissions: {}). build gets contents: read; publish gets contents: write (create the release), id-token: write (the OIDC token Sigstore signs with) and attestations: write.
  • Dropped:
    • cosign sign-blob with a Sigstore bundle: it duplicates the attestation's own Sigstore signature and adds a cosign install.
    • A GPG key in a repo secret: a long-lived key to store and rotate.
    • anchore/sbom-action: a Node action that downloads syft at run time.

Measured (base b76efec vs 9936ae1)

  • Build step dry run (verified, locally): I ran the release job's build script on a scratch clone, with a local throwaway tag v0.5.0-sim that was never pushed.
    • The step output is version=0.5.0-sim, matching the SBOM path the attest step reads.
    • Six archives plus codeshot_0.5.0-sim.cdx.json are written, and all seven are in checksums.txt. sha256sum -c passes.
    • The SBOM's main component is github.com/inth3shadows/codeshot v0.5.0-sim, with 14 dependency components.
    • The archived binary prints codeshot 0.5.0-sim.
  • SBOM version on a shallow tag checkout (verified): a --depth 1 clone at v0.4.0, which is what the release job checks out, gives the SBOM the version v0.4.0.
  • Untouched: the persist-credentials and GH_TOKEN lines (the diff touches neither), and the test, cross-compile and archive steps.
  • CI on this PR: the security job's zizmor scan checks the workflow.

Changes since review (2026-11-19)

Round 1 (/code-review + a code-reviewer agent on 9936ae1; the agent read both actions' source at the pinned SHAs), fixed in bc60614:

  • Signing is in its own job. The first version gave id-token/attestations: write to the job that also runs the tests, apt-get and the SBOM tool with its dependencies, any of which could mint the OIDC token and attest arbitrary files as built by this repo. Now build has contents: read only and uploads the files as a one-day artifact; publish, which runs no build or test code, downloads them, checks checksums.txt, attests and publishes.
  • The SBOM lists the Go standard library (-std), which is compiled into every binary, so scanners see Go stdlib advisories. 15 components now, including std (go1.26.5).
  • actions/attest v4.2.2 directly (1e69f48acb82d1966a394da916b4c1698aa569d6) for both attestations: attest-build-provenance and attest-sbom are wrappers around it, pulled in two inner versions, and attest-sbom is deprecated (it printed a warning every run). No storage record (create-storage-record: false), so no artifact-metadata permission.
  • The SBOM is attested for the six archives, not also for itself.
  • A tag that isn't v<semver> (v0.5, v0.5.0rc1) fails the build before anything is made; it would have named the archives one way and given the SBOM a pseudo-version.
  • README verification pins --signer-workflow .../release.yml and --source-ref refs/tags/<tag>, so only the release workflow's attestation for that tag passes, and shows shasum -a 256 -c for macOS.
  • Kept, with reasons: one module SBOM for all six archives (the agent found the component lists identical for linux/amd64, darwin/arm64 and windows/amd64); attestations made before the publish step may outlive a failed publish, but describe real builds; go run tool@version is pinned by the Go checksum database.
  • Build step dry run on a scratch clone (local tag v0.5.0-rc.1, never pushed): v0.5 and v0.5.0rc1 refused (exit 1); v0.5.0-rc.1 builds, sha256sum -c 7/7 OK, SBOM version v0.5.0-rc.1 with std. CI 5/5, zizmor passes the two-job workflow.

Round 2 (verify on bc60614): every round-1 fix held, checked against the actions' source at the pinned SHAs. Fixed in 35af16f:

  • Only the expected files get signed. publish attested whatever checksums.txt listed, so a compromised build job could add a file and have it attested and uploaded. It now refuses unless checksums.txt lists, and the artifact holds, exactly the seven expected files for the version. Tested on a scratch layout: the good set passes; an extra file (listed or not), a missing SBOM, swapped bytes and a wrong version are refused. A compromised build can still change the bytes of those seven files, which no signing step can detect.
  • Strict semver tags. v01.2.3 and v1.2.3-01 passed the first check and gave the SBOM a pseudo-version. Tested: v0.5.0, v1.2.3, v0.5.0-rc.1, v1.2.3-alpha.beta.1, v1.0.0-0 and v1.0.0-x-y pass; v01.2.3, v1.02.3, v1.2.3-01, v1.2.3-rc.01, v0.5, v0.5.0rc1, v1.2.3+meta, v1.2.3-, v1.2.3-.., v1.2.3.4 and v1.2.3-rc_1 are refused.
  • What each check proves, in README and TECHNICAL: the checksum line shows a download is intact (checksums.txt isn't signed); --signer-workflow and --source-ref trust release.yml at the tagged commit, so they are as strong as the protection on v* tags. The workflow header and TECHNICAL now include --source-ref.
  • The artifact is kept 7 days, so publish can be re-run on its own; review IDs and a redundant create-storage-record input are gone.
  • CI 5/5 on 35af16f, zizmor included.

Known limits

  • The two attest steps run only on a real tag push. The first release after this merge (v0.5.0) is where they are proven, with gh attestation verify on an archive and on the SBOM predicate. If that fails, it needs a fix-forward release.
  • The SBOM predicate type in the README (https://cyclonedx.org/bom) is what attest-sbom is expected to use for CycloneDX. It is not yet checked against a real attestation.
  • The composite GitHub Action builds from source at the pinned ref and isn't signed separately.
  • Verification trusts release.yml at the tagged commit; protecting v* tags with a repository ruleset (not part of this PR) would stop anyone with push access from re-pointing a tag at an edited workflow.

The release workflow now writes a CycloneDX SBOM of the module
(cyclonedx-gomod v1.12.0, pinned through the Go checksum database), adds
it to checksums.txt and the release, and attests build provenance and
the SBOM for every archive (actions/attest-build-provenance v4.2.2 and
actions/attest-sbom v4.1.0, SHA-pinned, subject-checksums). Keyless:
Sigstore signs with the job's OIDC token. Permissions move to the job
(contents, id-token, attestations write); the workflow grants nothing at
the top level. README shows how to verify a download.

P5c of the program.
- F1: the build job (tests, builds, SBOM tool) has contents: read only
  and hands the files over as an artifact; a publish job that runs no
  build or test code holds id-token/attestations and attests and
  publishes, so build-time code can't mint the signing token.
- F2: the SBOM includes the Go standard library (-std).
- F5: actions/attest v4.2.2 directly for both attestations (the wrappers
  pulled two inner versions; attest-sbom is deprecated).
- F4: the SBOM is attested for the six archives, not for itself.
- F6: a tag that isn't v<semver> fails the build before anything is made.
- F7/A2: README verification pins the release workflow and tag, and
  shows the macOS checksum command.
- V1/V6: publish refuses unless checksums.txt lists, and the artifact
  holds, exactly the seven expected files for the version, so a
  compromised build job can't add a file to be attested and published.
- A1: the tag check is strict semver (no leading zeros), so v01.2.3 no
  longer gives the SBOM a pseudo-version.
- V2/V3/V5: README and TECHNICAL say what each check proves: checksums
  are integrity only; --signer-workflow/--source-ref trust release.yml
  at the tagged commit, so they are as strong as v* tag protection.
- V7: the artifact is kept seven days, so publish can be re-run alone.
- V8/V9: no review IDs in comments; no redundant storage-record input.
@inth3shadows
inth3shadows merged commit 9952cc9 into master Nov 19, 2026
5 checks passed
@inth3shadows
inth3shadows deleted the p5-signed-releases branch November 19, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant