Skip to content

ci: pin actions to commit SHAs and verify downloaded tools - #426

Merged
somanshreddy merged 3 commits into
mainfrom
10-07-pin_ci_actions
Oct 7, 2026
Merged

somanshreddy merged 3 commits into
mainfrom
10-07-pin_ci_actions

Conversation

@somanshreddy

Copy link
Copy Markdown
Collaborator

Scope

Surfaces: CI and release workflows | Module: Build / release pipeline

Summary

CI and both release workflows ran remote code at versions or content nobody fixed: GitHub Actions by mutable tag, GoReleaser by version range, gitleaks and golangci-lint as unverified downloads, and an unpinned pip install. The release jobs hold a write-capable token and AWS credentials, so any of those being swapped upstream would run with them. Every one is now pinned to exact content, or removed.

How it works

The rule is: a tool runs only if this repository fixed what it is. How each one is fixed:

Tool Before Now
GitHub Actions (checkout, setup-go, aws credentials, golangci-lint) mutable tag (@v7) full commit SHA, release in a comment
GoReleaser (CI check, dev and stable release) goreleaser-action, version: "~> v2" .github/scripts/install-goreleaser.sh: exact version, archive sha256 checked before extraction
gitleaks downloaded and run unchecked archive sha256 checked before extraction
golangci-lint action downloads an unverified binary install-mode: goinstall, so go install verifies it against the Go checksum database
PR-template check pip install requests (unpinned, unhashed) standard-library urllib; nothing installed

Every pin is the version already in use today, so behaviour is unchanged. RELEASE.md gains a "Pinned CI tools" section with the bump procedure: change a tool's version and its hash together, taking the hash from that release's checksums.txt.

Design decisions

GoReleaser is installed by a script, not by its action. At the pinned commit, goreleaser-action logs a warning and runs the binary anyway when it cannot fetch checksums.txt, so pinning its version alone left verification failing open in the jobs that hold release credentials. The script fails closed, and keeps the version and hash in one place for all three workflows.

The hashes are recorded in the repository, not fetched alongside the archive. Downloading checksums.txt from the same release would trust the same origin twice. Each recorded hash was matched against three sources: the computed hash of the download, the release's checksums.txt, and GitHub's own asset digest.

Runner images are out of scope. ubuntu-latest and its preinstalled tools (such as the AWS CLI used by the stable upload) are GitHub's. RELEASE.md says so rather than claiming more than the workflows control.

Deferred: the end-user installer. scripts/install.sh verifies archives against a checksum file served from the same CDN as the archive. Closing that needs signed manifests and a separately distributed key, which is a larger change than this one.

Testing

  • Each install step was run under the runner's bash -eo pipefail: the recorded hash installs the tool, and a wrong hash exits 1 before anything is extracted.
  • With the verified GoReleaser binary, goreleaser check validates the config, and a --snapshot --skip=publish release builds all six platform archives plus checksums.
  • The rewritten PR-template script was run against real PRs (pass) and a nonexistent one (HTTP 404, exit 1).
  • actionlint is clean, the workflow-parsing Go version pin test passes, and the diff swaps exactly the 20 uses: lines with no other line removed.

🤖 Generated with Claude Code

@terencechotai2-commits terencechotai2-commits left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I verified everything the description claims and found one small ordering suggestion.

Action pins. All four resolve to the commit of the tag in their comment (dereferencing annotated tags):

  • actions/checkout v7.0.1;
  • actions/setup-go v7.0.0;
  • golangci/golangci-lint-action v9.3.0;
  • aws-actions/configure-aws-credentials v6.3.0.

Each is also the current latest release, and no unpinned uses: is left in any workflow. dependabot.yml covers github-actions weekly, as RELEASE.md says.

install-goreleaser.sh, dry-run here. I used a stub sudo that redirects /usr/local/bin to a scratch dir:

  • Pinned script → goreleaser.tar.gz: OK, exit 0, GitVersion: 2.18.2. goreleaser check validates .goreleaser.yaml.
  • Hash with one character changed → FAILED, exit 1, nothing installed.
  • Nonexistent version → curl 404, exit 22, nothing installed.
  • Empty hash → no properly formatted checksum lines found, exit 1.

It runs under set -euo pipefail, and curl -f makes HTTP errors fatal. The hash is compared against the value recorded in the script; checksums.txt is never fetched.

Hash provenance. I matched both recorded hashes against the release's own checksum file and GitHub's asset digest:

  • GoReleaser 0a96edc9…: matches.
  • gitleaks a65b5253…: matches, and I also recomputed it from the download.

Release job compatibility:

  • v2.18.2 is the current latest v2, which is what ~> v2 resolved to, so the release version doesn't change.
  • .goreleaser.yaml has no signs, sboms, docker or nfpms, so no cosign/syft step depended on the action.
  • The script cds inside its own process, so the job's cwd and dist/ (used by the S3 upload) are unaffected.
  • The asset is Linux_x86_64, which is right for ubuntu-latest. On an arm runner, the x86_64 binary that installs would fail to run, so it would still fail loudly rather than run something unexpected.
  • The goreleaser-check CI job runs the same script on every PR, so a bad version/hash bump is caught before it reaches a release. It's green here, as is the rest of CI.

golangci-lint. At the pinned action commit, goinstall mode takes version literally (go install …/[email protected]), with no remote version-mapping fetch. Module content is checked against sum.golang.org.

check_pr_template.py. urlopen raises on a 4xx/5xx, so it still fails closed.

Low, suggestion: install before tagging (inline).

— tai2

Comment thread .github/workflows/release-stable.yml Outdated
echo "GORELEASER_PREVIOUS_TAG=$prev" >> "$GITHUB_ENV"
fi

- name: Install GoReleaser

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion (Low, same exposure as before but cheap to close): move Install GoReleaser above Create git tag here and in dev-release.yml.

Right now the tag is pushed first. If the download hits a GitHub outage, or the hash fails, the stable tag is left on origin with no release. A re-run then stops at Validate version with tag already exists, and someone has to delete the tag by hand. The install has no dependency on the tag, so running it before the tag makes a failed fetch leave nothing behind.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1d39ac7: Install GoReleaser now runs before Create git tag in both release-stable.yml and dev-release.yml, so a failed or tampered download stops the job before any tag is pushed. Steps after the push (GoReleaser itself, AWS credentials, the S3 upload) can still strand a tag; that predates this PR and is noted as a follow-up.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 6b83bebb. I focused on the release path as asked; tai2 already ran the install script's failure modes (wrong hash, 404, empty hash), so I didn't repeat those and checked the inputs and the claim behind the switch instead.

The switch away from goreleaser-action is justified

At v7 (f06c13b6), src/goreleaser.ts verifyChecksum catches a failed checksums.txt download, logs Skipping checksum verification, and returns. The binary is then extracted and run. So the PR body's reason is accurate. The script is stricter than the action in every case: it never needs checksums.txt, and the archive must match a hash this repo committed.

What the action did that the script doesn't is the cosign check on checksums.txt. That only proves checksums.txt came from GoReleaser's release key, and the pinned hash already fixes the exact archive, so nothing is lost.

Pins checked against upstream

  • GoReleaser v2.18.2: I downloaded goreleaser_Linux_x86_64.tar.gz and its sha256 is 0a96edc9…606d3. That matches the script and the release's checksums.txt. v2.18.2 is also the latest non-nightly release, so ~> v2 was resolving to it.
  • gitleaks 8.28.0: gitleaks_8.28.0_linux_x64.tar.gz hashes to a65b5253…840eb, matching the workflow and the release's checksums file.
  • Actions: checkout v7.0.1, setup-go v7.0.0, golangci-lint-action v9.3.0 and configure-aws-credentials v6.3.0. Each SHA is the commit its tag names, and each is also the current major tag, so behaviour is unchanged. No unpinned uses: is left in .github/. dependabot.yml already covers github-actions weekly, so the RELEASE.md note about reviewing SHA and comment together matches how updates will arrive.

Script

  • Fails closed: set -euo pipefail, curl -f, and sha256sum -c runs before tar, so a mismatch stops before anything is extracted or moved.
  • Platform: it hardcodes Linux_x86_64. On a non-x64 runner the hash wouldn't match and it would fail, which is the safe direction.
  • Executable: the file is committed as 100755, so the bare run: .github/scripts/install-goreleaser.sh works and picks up the shebang's -euo pipefail.

Nit

  • Install before the tag: +1 to tai2's ordering note. In both release workflows the tag is pushed before Install GoReleaser. A download failure, now possible in a new way via a hash mismatch, leaves a pushed tag with no release. Moving the install step above Create git tag costs nothing.

— Rames

@terencechotai2-commits terencechotai2-commits left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 1d39ac7: no findings, and my Low is resolved.

6b83bebb..1d39ac7 is a pure move. In both dev-release.yml and release-stable.yml, the three Install GoReleaser lines moved up, unchanged, to sit right before Create git tag. Nothing else in the diff changed. Order is now install → tag → GoReleaser in both workflows. In stable, install also runs after Validate version and the AWS-config check. So a failed or tampered download stops the job before any tag is pushed.

CI on the new head was still running when I posted (pr-template, secrets and surface-report had passed).

— tai2

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving at 1d39ac74.

The only change since 6b83bebb is the move. In both dev-release.yml and release-stable.yml, Install GoReleaser now sits above Create git tag, and the step body is byte-identical (6 lines in, 6 out per file). The script runs in its own process with its own temp dir, so the move doesn't affect the working directory of the tag or release steps. A failed or mismatched download now stops the job before any tag is pushed. That resolves the ordering nit.

— Rames

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving at 28f2ad8a after the rebase. The PR's diff against its new base (3485904, the #425 merge) is byte-identical to the diff I approved at 1d39ac74. The only commit added underneath is #425's .gitattributes, which doesn't touch any file this PR changes. All three commits are signed and verified.

— Rames

@somanshreddy
somanshreddy merged commit 4fb2037 into main Oct 7, 2026
10 checks passed
@somanshreddy
somanshreddy deleted the 10-07-pin_ci_actions branch October 7, 2026 08:57
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.

3 participants