How should you pin third-party actions, and why?
AdvancedConceptGitHub Actions
Answer
Tags like @v4 are mutable: a maintainer (or an attacker who compromises the repo) can repoint the tag to malicious code, as happened in the 2025 tj-actions/changed-files incident that leaked secrets from workflow logs. Pinning to a full commit SHA is the only immutable reference.
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Add Dependabot for github-actions so SHAs get updated by PR, and allow-list permitted actions in org settings (GitHub also offers an org policy to require SHA pinning).
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate