Skip to content

Pin GitHub Actions to full-length commit SHAs - #998

Merged
Johannes Schindelin (dscho) merged 4 commits into
microsoft:vfs-2.55.0from
danfiedler-msft:danfiedler/pin-actions
Oct 19, 2026
Merged

Johannes Schindelin (dscho) merged 4 commits into
microsoft:vfs-2.55.0from
danfiedler-msft:danfiedler/pin-actions

Conversation

@danfiedler-msft

Copy link
Copy Markdown

Summary

This PR pins GitHub Actions to full-length commit SHAs for improved security and reproducibility and adds a 7 day cooldown to Dependabot configuration for GitHub Actions. This work is described in more detail at https://aka.ms/action-pinning.

Why?

Pinning actions to commit SHAs prevents supply-chain attacks where a tag could be moved to point to malicious code. This is a recommended security best practice per the GitHub Actions security hardening guide.

This change mitigates the risk of tag retargeting to malicious code as seen in incidents like the tj-actions/changed-files action compromise or codfish/semantic-release-action compromise and improves the integrity and reproducibility of the CI/CD pipeline.

What changed?

Action pinning: Third-party action references in .github/workflows/ that used mutable tag-based references (e.g., actions/checkout@v4) have been updated to full-length commit SHAs with a version comment (e.g., actions/checkout@<sha> # v4) using the pinact tool. References that were already pinned to a SHA, or that used immutable release tags, were left unchanged.

Dependabot configuration: .github/dependabot.yml has been updated to ensure a github-actions package-ecosystem section is present with a cooldown configuration (default-days: 7). If the file did not exist, it was created. If a github-actions section already existed, only the cooldown block was added or its default-days value was increased to 7 if it was lower. The 7-day cooldown provides a window for the community to detect and report compromised releases before they are automatically proposed as updates, reducing exposure to supply-chain attacks via newly published malicious versions.

Is this safe to merge?

Yes. The pinned SHAs correspond to the same commits that the existing tags pointed to. No behavioral changes in action execution are introduced. You can verify the pinned SHA value using the GitHub REST API (e.g., the commit hash for actions/checkout@v7 can be found in the sha property in the JSON response for GET https://api.github.com/repos/actions/checkout/commits/v7).

Additional Information

For more information, please see https://aka.ms/action-pinning

This commit performs a one-time pinning, something that downstream
repositories need to maintain from that point on. Such maintenance comes
at a high cost when the workflows in question are not actually under the
downstream repositories' control, but are inherited from an upstream
project, such as (fast-moving) git/git.

The intention of this patch is to increase security, which to a certain
extent might even be accomplished here, under the assumption that the
current SHA-1s refer to non-vulnerable versions. The commit message is a
bit secretive about whatever analysis went into that, if any, so we
cannot know.

While this patch _might? increase security, it also increases the
maintenance burden in a non-negligible way, though. For example, it
forgot to pin the GitHub Action maintained in the VFS for Git repository
to run the VFS for Git Functional Tests, and it pinned the CodeQL
Actions to an already-outdated version. Let's drop this patch, for that
reason, in preparation for integrating a much more sustainable way to
pin the Actions' SHA-1s (ignoring the question whether pinning Actions
to SHA-1s actually increases security, or merely shifts blame).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Microsoft Git inherits GitHub workflows from upstreams that use
non-pinned versions for convenience. For compliance reasons, Microsoft
Git must pin those to SHA-1s.

Here is a script that exchanges the moving tags/refs in the `uses:`
statements with their fixed SHA-1s.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Microsoft Git inherits workflows that upstream maintains using symbolic
Action refs. Downstream organizational policy requires full commit IDs
instead, adding pin maintenance to this project's maintainers' workload.

Keep pins aligned with the original upstream Action refs in a fresh
downstream snapshot, independent of any earlier pinning commit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I appreciate the rework Johannes Schindelin (@dscho) has done to make this a script and therefore a reusable tool to prevent the maintenance burden.

Note that this pinning does not actually guarantee that out dependencies are safe here.

}).trim();
}

const isSHA = value => /^[0-9a-f]{40}$/i.test(value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't wait for SHA-256 🫣

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, SHA-256 should make the pinning more secure, anyway: A dedicated attacker with $10k to spare could feasibly create a SHA-1 collision for a slow-moving Action, which means that SHA-1 pinning is most likely providing more of a false than of a true sense of security.

}

const isSHA = value => /^[0-9a-f]{40}$/i.test(value);
const uses = /^( *-? *uses: *)(["']?)([\w./-]+)@([^ \t"'\r\n]+)\2([^\r\n]*)/gm;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Local actions get skipped since they don't have an @ (e.g., ./myaction, which I guess is OK here since we only care about unpinned actions, but a local action is already pinned to the current workflow file/repo ref.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Precisely, they are implicitly pinned to the current revision (i.e. safer than any pinned SHA-1).

@dscho
Johannes Schindelin (dscho) merged commit e82b652 into microsoft:vfs-2.55.0 Oct 19, 2026
93 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