Skip to content

ci: pin github actions to commit shas and declare workflow permissions - #1193

Open
Totara-thib wants to merge 2 commits into
go-resty:v3from
Totara-thib:ci-hardening
Open

ci: pin github actions to commit shas and declare workflow permissions#1193
Totara-thib wants to merge 2 commits into
go-resty:v3from
Totara-thib:ci-hardening

Conversation

@Totara-thib

Copy link
Copy Markdown

Hi, drive-by CI hardening in two commits, one logical change each.

Commit 1 pins the actions to their commit shas, versions kept as comments. A tag like @v4 is a movable pointer: whoever controls the action, or anyone who compromises it, can re-point it and your next run executes their code with the job's token. Same pattern as the tj-actions/changed-files incident (CVE-2025-30066). All shas were resolved from the upstream repos and cross checked against their release tags. The pins stay maintainable: if you want them bumped automatically, a dependabot config with the github-actions ecosystem does it, one small block.

Commit 2 adds permissions: contents: read to both workflows. The scope is exact, not guessed: the jobs only check out, build, test and upload coverage through the dedicated CODECOV_TOKEN secret, the GitHub token itself is never used.

One heads up: if the org uses an Actions allowlist in settings, patterns written against tags (like owner/action@v4) stop matching once refs are shas and workflows refuse to start. Entries need to be owner/action@* in that case.

Found with the Plumber CLI (https://github.com/getplumber/plumber), verified on v3. I will also open a PR which adds it to CI so this does not quietly drift back, that one is a bonus, this PR stands on its own.

Mutable tags are movable pointers: whoever controls an action, or
anyone who compromises it, can re-point the tag and the next run
executes unreviewed code with the job's token. Same pattern as the
tj-actions/changed-files incident (CVE-2025-30066).

Pinning to the full commit sha freezes what runs; the version each
sha corresponds to stays as a comment so update tooling keeps
tracking them. Every sha was resolved from the upstream repository
and cross-checked against its release tag. No workflow logic
changes.
Without a permissions block, both jobs' GITHUB_TOKEN inherits the
repository default scope. They only check out, build, test and
upload coverage through the dedicated CODECOV_TOKEN secret, the
GitHub token itself is never used, so both workflows get contents
read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant