Skip to content

ci: pin actions to commit SHAs and set least privilege permissions - #75

Merged
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
waterlemonnn:fix/pin-actions-least-privilege
Aug 7, 2026
Merged

ci: pin actions to commit SHAs and set least privilege permissions#75
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
waterlemonnn:fix/pin-actions-least-privilege

Conversation

@waterlemonnn

Copy link
Copy Markdown
Contributor

Closes #43

.github/workflows/ci.yml, contributors.yml, and pr-title.yml all referenced actions/checkout, actions/setup-node, and actions/github-script by mutable tag (@v7). Tags can be repointed by whoever controls the action repo, and contributors.yml runs several of these steps from pull_request_target and issue_comment, which get write access and secret access from contexts a fork can influence. Pinning to a commit SHA closes that off.

  • Pinned every uses: in all three workflow files to the full 40-char commit SHA that @v7 currently resolves to, with the human-readable version as a trailing comment (actions/checkout@<sha> # v7.0.1, actions/setup-node@<sha> # v7.0.0, actions/github-script@<sha> # v7.1.0). Resolved via the GitHub API against each action repo's tag refs, not guessed.
  • Added a top-level permissions: contents: read block to ci.yml, which had no permissions: at all before this (so its jobs were running with the repo default token scope). contributors.yml already sets narrower per-job permissions and didn't need changes.
  • .github/dependabot.yml already has a github-actions ecosystem entry, so pins will get bumped by PR going forward.
  • Re-checked the pull_request_target job in contributors.yml: none of its jobs check out or execute PR code, they only call actions/github-script with an inline script against the GitHub API.

Verified: grep -rn "uses:.*@v" .github/workflows/ returns nothing, all SHAs are 40 hex chars, and all three workflow files still parse with js-yaml.

actions/checkout, actions/setup-node, and actions/github-script were all
referenced by mutable tag (@v7), so whoever controls those repos could
repoint the tag at different code. contributors.yml runs some of these
jobs from pull_request_target and issue_comment, which have write access
and secrets, so a repointed tag there is a path to repo write.

Pin every uses: to a full commit SHA with the resolved version in a
trailing comment, and add a top level permissions: contents: read to
ci.yml, which had no permissions block at all before this.
@royalpinto007
royalpinto007 merged commit 871df79 into AgentPostmortem:main Aug 7, 2026
11 checks passed
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Merged. Thanks a lot, @waterlemonnn.

agentpostmortem gets better every time someone outside the repo digs in like this.

If you find agentpostmortem useful, consider dropping a star. It helps more people find it.

Happy to see more from you whenever you have the time.

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.

Pin GitHub Actions to commit SHAs and add least privilege permissions to CI

2 participants