Skip to content

ci: harden reusable GitHub Actions#12

Merged
huitseeker merged 1 commit into
mainfrom
harden-reusable-github-actions
Apr 16, 2026
Merged

ci: harden reusable GitHub Actions#12
huitseeker merged 1 commit into
mainfrom
harden-reusable-github-actions

Conversation

@huitseeker
Copy link
Copy Markdown
Collaborator

This tightens the shared GitHub Actions without changing their public inputs or expected behavior.

It pins third-party actions to full commit SHAs, gives each workflow permissions: {} by default, adds job-level token scopes, disables checkout credential persistence, and moves user-controlled values out of shell code paths so they are read as quoted environment variables instead.

It also adds a pinned zizmor-action workflow. The new check gates high-severity findings only, because the remaining medium findings ask for deployment environments around secrets. Adding those here would change caller approval and secret behavior.

The Debian action change that looks odd is the removal of type: choice and options from the composite action inputs. GitHub composite actions do not support those keys; actionlint treats them as invalid metadata. The real arch allow-list is still enforced by the publishing job matrix: arch: [amd64, arm64]. So the behavior stays the same, but the action metadata becomes valid.

@bitwalker
Copy link
Copy Markdown
Collaborator

One thing we need to be uber careful of, is allowing PRs which change the pinned SHA of a GitHub Action without it being actually confirmed as belonging to the repo we think we're fetching it from. GitHub will allow SHAs from any fork to resolve under the "real" org/repo identifier, meaning that anyone can fork a GitHub Action repo, push a commit that contains something malicious, and then issue a PR to some repo that uses the upstream repo, but references the SHA from their fork and GitHub allows this without any warning.

steps:
- name: Rust cache
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
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.

I would like if we would make it practice to have a comment above these with a hyperlink to the referenced commit - to make review easier should the SHA change in a PR.

@huitseeker
Copy link
Copy Markdown
Collaborator Author

@bitwalker

One thing we need to be uber careful of, is allowing PRs which change the pinned SHA of a GitHub Action without it being actually confirmed as belonging to the repo we think we're fetching it from

Yep, 💯 you're talking about impostor commits, that's where the included zizmor linter and action included in this PR come in: https://docs.zizmor.sh/audits/#impostor-commit. (the current setting sets online-audits to true, which turns impostor-commit detection on)

Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

A very superficial review from me - but looks good! Thank you!

@huitseeker huitseeker merged commit 4dea44e into main Apr 16, 2026
3 checks passed
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