Pin GitHub Actions to SHAs and add step-security/harden-runner#1588
Pin GitHub Actions to SHAs and add step-security/harden-runner#1588wallies wants to merge 1 commit into
Conversation
Replace floating action refs (@v*, @stable, @master, @release/v1) with verified commit SHAs to mitigate tag-rewrite supply chain attacks of the class that hit reviewdog/action-setup and tj-actions/changed-files in March 2025. Add step-security/harden-runner as the first step of every job in audit mode, with disable-sudo on the 10 jobs that do not need it. Extend dependabot.yml with a github-actions ecosystem so the new pins stay current; switch both ecosystems to weekly with a 7-day cooldown and group minor/patch updates.
jakelishman
left a comment
There was a problem hiding this comment.
Hardening actions by using SHAs is a good idea.
An unsupervised LLM PR attempting to introduce an external dependency on some random AI tooling on every commit and every workflow is the definition of a supply-chain attack itself.
I am closing this, and do not attempt to open a PR like this again. Any further attempt will be treated as actively malicious.
| - name: Harden the runner | ||
| uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3 | ||
| with: | ||
| egress-policy: audit |
There was a problem hiding this comment.
This is an AI bot that is being proposed to run on every commit and every workflow.
This is exactly what a supply-chain attack looks like.
There was a problem hiding this comment.
@jakelishman are you serious? Do you know what step security is and who uses it? Closing this shows a lack of understanding of the community and good practices
Coverage Report for CI Build 26158142145Coverage remained the same at 94.722%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions3 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Summary
Hardens the GitHub Actions CI by:
@v*/@stable/@master/@release/v1floating ref with a verified SHA pin plus a version comment (catches tag-rewrite supply-chain attacks).step-security/harden-runner@<sha>(audit mode) as the first step of every job in every workflow (14 jobs acrossmain.yml,wheels.yml,docs_dev.yml,docs_release.yml).disable-sudo: trueto the 10 jobs that do not need sudo. The 4 jobs that install graphviz/pandoc viasudo apt-getkeep the default.dtolnay/rust-toolchain@stableand@masterreferences to Rust 1.94.1. The existing@1.92pin inbuild_lint(carrying aTODO: unpin clippynote) is preserved at 1.92, only its SHA is now pinned..github/dependabot.ymlso the new SHA pins do not go stale: adds thegithub-actionsecosystem, switches both ecosystems to weekly with a 7-day cooldown, and groups minor/patch updates. Majors continue to open as individual PRs for review.Every SHA in the diff was verified to resolve to a real commit in its source repo via
gh api repos/<owner>/<repo>/commits/<sha>.Why this matters
In March 2025, two consecutive supply chain attacks struck widely-used GitHub Actions.
reviewdog/action-setup@v1was compromised on March 11, 2025; secrets exfiltrated from that incident were then used a few days later to compromisetj-actions/changed-fileson March 14, 2025. In both cases the attacker rewrote existing version tags, so any workflow consuming floating refs like@v1or@v45silently picked up the malicious code on its next run and leaked CI/CD secrets. Workflows pinned to full commit SHAs were unaffected.That attack pattern is the specific class of risk this PR removes. SHA pins make the action ref immutable from the consumer side - retagging at the source no longer changes what runs here.
step-security/harden-runnerprovides defense in depth on top of that: even if a pinned dependency were itself published with malicious code, audit mode logs the unexpected egress and block mode prevents secrets from leaving the runner.This change brings the repo in line with:
Pinned-Dependenciescheck, which requires dependencies be set to a specific hash rather than a mutable version range.Out of scope
Major version bumps
The pinned actions are intentionally kept at their current major. Several are significantly behind latest:
actions/checkoutactions/setup-pythonactions/download-artifactactions/upload-artifactactions/upload-pages-artifactdocker/setup-qemu-actionThese will arrive as individual Dependabot PRs (one per major bump) once this lands, so each can be reviewed on its own merits without bundling breakage risk into the hardening change. The
upload-artifact/download-artifactv4 → v5+ transition in particular changed artifact merge semantics and needs careful validation againstwheels.yml.Pre-existing bugs noted but not fixed
actionlintflagged two pre-existing references to${{ matrix.python-version }}in non-matrix jobs (coverage,docsinmain.yml). These render as empty strings in step names today. Out of scope for this PR.Follow-up: install the Step Security GitHub App and move audit → block
harden-runneris currently inegress-policy: audit, which logs outbound traffic without blocking. To get full value, the maintainers need to:Install the StepSecurity app at https://github.com/apps/stepsecurity for the
Qiskitorganization. This gives access to the dashboard at https://app.stepsecurity.io where audit logs are aggregated and a recommended allowlist is generated.Let several CI runs complete post-merge (a release tag run is especially useful, since
wheels.ymlonly fires on tags) to populate a complete egress profile.Review the audit dashboard and copy the suggested
allowed-endpointslist for each workflow.Flip
egress-policy: audit→egress-policy: blockin the workflows, supplying the endpoint allowlist:Consider extending
disable-sudo: truetotests,docs, and the two doc-deploy jobs by moving thegraphviz/pandocinstall onto a pre-built image or pre-installed runner image, eliminating the last 4 sudo callouts.Without step 1, harden-runner still works (audit logs land in the job summary), but the maintainer experience for tightening the policy is significantly worse.
Test plan
actions/checkoutactions/setup-pythonactions/upload-artifactactions/download-artifactactions/upload-pages-artifactSHAs resolve to expected commits (verified locally; CI re-verifies on first run).main.ymljobs (build_lint,tests,tests_stubs,coverage,docs) succeed on this branch.docs_dev.ymlsucceeds on a push tomain(post-merge).wheels.ymlsucceeds end-to-end on the next release tag, includingdisable-sudo: trueon builder jobs.github-actionsPR within 7 days of next eligible upstream release.References