All guides

Software supply chain: pin, sign and verify

An attacker no longer needs your servers. A changed dependency or a moved tag in your pipeline is enough. Four habits close most of that gap.

A laptop on a desk beside stacks of books and a lamp

1. Pin third-party actions to a commit

A tag such as v2 can be moved to different code. A full commit hash cannot. GitHub's own hardening guide says to pin actions to a full-length commit SHA.

# the tag in the comment is for people; the hash is what runs
- uses: some-org/some-action@0123456789abcdef0123456789abcdef01234567 # v2.1.0

Take the hash from the action's own repository, never from a fork.

2. Give the workflow token the least access

permissions:
  contents: read

Set this at the top of every workflow and raise it only in the job that needs more. A job that only runs tests has no reason to hold a token that can push.

3. Attest what you build

An attestation is a signed statement of which workflow, in which repository, built this exact file. GitHub's actions/attest action creates one:

permissions:
  id-token: write
  contents: read
  attestations: write

steps:
  - uses: actions/attest@v4
    with:
      subject-path: dist/app.tar.gz

Artifact attestations work in public repositories on every plan. Private and internal repositories need GitHub Enterprise Cloud.

4. Verify before you deploy

gh attestation verify dist/app.tar.gz -R my-org/my-repo

For container images, Sigstore's cosign signs without a key to look after (cosign sign $IMAGE) and checks who signed:

cosign verify ghcr.io/my-org/app:1.4.2 \
  --certificate-identity=https://github.com/my-org/my-repo/.github/workflows/release.yml@refs/heads/main \
  --certificate-oidc-issuer=https://token.actions.githubusercontent.com

Put the check in the deploy job, so an image that was not built by your release workflow never reaches production.

Where to start

Pinning and the read-only token cost an afternoon and break nothing. Do those two first, then add attestation to the one artifact you ship most often.

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides