Skip to content

ci: pin every third-party action to a commit sha (#503) - #510

Merged
scttfrdmn merged 1 commit into
mainfrom
chore/pin-actions-to-shas
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
chore/pin-actions-to-shas

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #503.

A tag is mutable. Whoever controls an action's repository can repoint v7 at
different code, and that code runs with this repository's GITHUB_TOKEN — on the
release path with contents: write, packages: write and id-token: write,
which is enough to publish a release, push an image to ghcr, and mint a Sigstore
certificate carrying this repository's identity. Pinning turns "trust this
maintainer permanently and prospectively" into "trust this exact tree, which was
reviewed once".

66 references across five workflow files, each at the sha its current tag
resolves to today. This is a pin and not a bump — no major version moves, so a
behaviour regression cannot be confused with a pinning mistake, which is the
constraint the issue asks for.

Each sha came from git/ref/tags/<tag>, dereferenced through the annotated-tag
object where there was one. The trailing comment names the most specific semver
tag pointing at that same commit rather than the floating major that was written
before, so actions/setup-go@v7 reads # v7.0.0 — what it actually was, which
is the thing a reviewer of the next Dependabot bump needs to see.

The diff is 66 insertions and 66 deletions, one per reference, and the existing
workflow-parsing tests in internal/config/ still pass, so the YAML is intact.

The lasting part is the test

Pinning 66 references is a one-time edit. The failure mode is the next action
someone adds, which will arrive as @v1 because that is what every README shows,
and nothing about a floating tag looks wrong in a diff.

TestEveryActionIsPinnedToASha walks .github/workflows rather than enumerating
it — a new workflow file is precisely the thing most likely to carry an unpinned
action, so a hard-coded file list would check only what was known when the list
was written. It carries a floor (4 files, 5 exist) and a non-zero reference
count, so a walk that stops finding files, or a uses: pattern that stops
matching, fails instead of passing vacuously.

It also requires the version comment, and requires a full 40 characters rather
than [0-9a-f]+: GitHub resolves an abbreviated ref, so a 7-character "pin" is
only as immutable as the objects that happen to share its prefix today.

Local reusable-workflow calls are skipped — ./.github/workflows/ci.yml is this
repository's own code at this repository's own commit, so there is no third party
and nothing to pin.

Ongoing cost

None. .github/dependabot.yml already has a github-actions ecosystem on a
weekly schedule, grouped for minor and patch (verified, lines 77–99), and
Dependabot updates sha pins in place while keeping the comment in sync.

Note on the issue's cosign-installer finding

Still true and now moot here: sigstore/cosign-installer stops publishing
floating majors at v3, so git/ref/tags/v4 is a 404. It was already referenced
as @v4.1.2 rather than @v4, and it is now pinned like everything else — one
action for which pinning removes a resolution problem rather than only a trust
one.

A tag is mutable. Whoever controls an action's repository can repoint `v7` at
different code, and that code runs with this repository's GITHUB_TOKEN — on the
release path with contents: write, packages: write and id-token: write, which is
enough to publish a release, push an image to ghcr, and mint a Sigstore
certificate carrying this repository's identity. Pinning turns "trust this
maintainer permanently and prospectively" into "trust this exact tree, which was
reviewed once".

66 references across five workflow files, each at the sha its current tag
resolves to today, with the release the sha belongs to as a trailing comment.
This is a pin and not a bump: no major version moves, so a behaviour regression
cannot be confused with a pinning mistake. Each sha came from
`git/ref/tags/<tag>`, dereferenced through the annotated-tag object where there
was one, and the comment names the most specific semver tag pointing at that
same commit rather than the floating major that was written before — so
`actions/setup-go@v7` reads `# v7.0.0`, which is what it actually was.

The lasting part is the test. Pinning 66 references is a one-time edit; the
failure mode is the next action someone adds, which will arrive as `@v1` because
that is what every README shows, and nothing about a floating tag looks wrong in
a diff. The test walks .github/workflows rather than enumerating it, since a new
workflow file is precisely the thing most likely to carry an unpinned action, and
it carries a floor so that a walk which stops finding files fails instead of
passing vacuously. It also requires the version comment: a sha alone tells a
reviewer nothing, so without it nobody can tell an upgrade from a downgrade, and
Dependabot uses the comment to name the version it is moving from.

Local reusable-workflow calls are skipped. `./.github/workflows/ci.yml` is this
repository's own code at this repository's own commit; there is no third party
and nothing to pin.

Ongoing cost is nothing: .github/dependabot.yml already has a github-actions
ecosystem on a weekly schedule, grouped for minor and patch, and Dependabot
updates sha pins in place while keeping the comment in sync.
@scttfrdmn
scttfrdmn force-pushed the chore/pin-actions-to-shas branch from 8fecf28 to 8d09dbe Compare September 17, 2026 04:48
@scttfrdmn
scttfrdmn merged commit d85937c into main Sep 17, 2026
42 checks passed
@scttfrdmn
scttfrdmn deleted the chore/pin-actions-to-shas branch September 17, 2026 05:02
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.

Pin every third-party GitHub Action to a commit sha

1 participant