Harden GitHub Actions workflows#105
Conversation
All actions in this workflow use mutable major-version tags (e.g., actions/checkout@v4, goreleaser/goreleaser-action@v5, aws-actions/configure-aws-credentials@v4) instead of pinned commit SHAs. This workflow has contents: write and id-token: write permissions and produces official releases. If any upstream action maintainer's account is compromised, or a tag is force-pushed with malicious code, the attacker could: (1) steal the OIDC token to assume the AWS IAM role arn:aws:iam::202662887508:role/ecr-prometheus-rds-exporter, (2) steal GITHUB_TOKEN with write access to create/modify releases, (3) inject malicious code into release artifacts (binaries, Docker images, Helm charts) affecting all downstream consumers. Signed-off-by: Vincent Mercier <vmercier@gmail.com>
|
It seems safer indeed to use the immutables hashes instead of the tags. A few comments:
|
Goal
Harden GitHub Actions workflows against supply chain attacks by pinning all action references to immutable commit SHAs and adding integrity verification for downloaded binaries.
Why
A security audit flagged multiple high-confidence findings across our CI/CD workflows:
@v4,@v5) instead of pinned commit SHAs. In workflows withcontents: write,id-token: write,pull-requests: write, orsecurity-events: writepermissions, a compromised upstream action could steal OIDC tokens, push malicious releases, exfiltrate code, or suppress security findings.These are well-known supply chain attack vectors (ref: tj-actions/changed-files compromise, March 2025).
How
Pinned actions to full commit SHAs
All actions across 3 workflow files are now pinned to their latest patch-level commit SHA with a version comment for readability:
build.yamlactions/checkout,aws-actions/configure-aws-credentials,aws-actions/amazon-ecr-login,actions/setup-go,docker/setup-qemu-action,goreleaser/goreleaser-actionlinter.yamlactions/checkout,actions/setup-go,golangci/golangci-lint-actiontest.yamlactions/checkout,actions/setup-go,irongut/CodeCoverageSummary,jwalton/gh-find-current-pr,marocchino/sticky-pull-request-comment,docker/setup-qemu-action,goreleaser/goreleaser-action,bridgecrewio/checkov-action,github/codeql-action/upload-sarifAdded SHA256 checksum verification for binary downloads
build.yaml): verified against official release checksumda36e117...test.yaml): verified against official release checksumd2a10db6...Both steps will now fail-fast if the downloaded binary doesn't match the expected hash.
Release
No functional changes. Existing Dependabot configuration will automatically propose PRs when pinned SHAs have newer versions available.