Skip to content

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

Closed
Dan Fiedler (danfiedler-msft) wants to merge 2 commits into
Azure:mainfrom
danfiedler-msft:danfiedler/pin-actions
Closed

Pin GitHub Actions to full-length commit SHAs#5341
Dan Fiedler (danfiedler-msft) wants to merge 2 commits into
Azure:mainfrom
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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

📦 Package size report

✅ No notable package size changes compared to the base branch.

13 package(s) with no notable change
Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-ts 536.59 KB → 536.71 KB +120 B (+0.0%) 2.58 MB → 2.58 MB +1011 B (+0.0%)
@azure-tools/typespec-java 13.51 MB → 13.51 MB -26 B (-0.0%) 15.03 MB → 15.03 MB
@azure-tools/azure-http-specs 146.71 KB → 146.71 KB 1.16 MB → 1.16 MB
@azure-tools/typespec-autorest 80.93 KB → 80.93 KB 395.06 KB → 395.06 KB
@azure-tools/typespec-autorest-canonical 7.42 KB → 7.42 KB 26.00 KB → 26.00 KB
@azure-tools/typespec-azure-core 129.43 KB → 129.43 KB 702.77 KB → 702.77 KB
@azure-tools/typespec-azure-portal-core 42.40 KB → 42.40 KB 192.91 KB → 192.91 KB
@azure-tools/typespec-azure-resource-manager 171.92 KB → 171.92 KB 1.04 MB → 1.04 MB
@azure-tools/typespec-azure-rulesets 5.16 KB → 5.16 KB 32.09 KB → 32.09 KB
@azure-tools/typespec-client-generator-core 229.48 KB → 229.48 KB 1.23 MB → 1.23 MB
@azure-tools/typespec-go 260.21 KB → 260.21 KB 1.33 MB → 1.33 MB
@azure-tools/typespec-metadata 15.91 KB → 15.91 KB 62.26 KB → 62.26 KB
@azure-tools/typespec-python 42.22 KB → 42.22 KB 164.91 KB → 164.91 KB

Packed = gzipped .tgz published to npm. Unpacked = total extracted size. 🆕 added, 🗑️ removed. Packages from the core/ submodule are not included.
🔴 grew · 🟢 shrank — only changes of at least 512 B and 0.5% are marked.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Go emitter diff

Baseline gh:ec0efa31cccaadaf340043532eeaa62590ec9272 vs this PR.

No changes to generated output.

Rendered diff: inline on the run summary, or the emitter-diff-go-html artifact.

Informational check (core/eng/emitter-diff); does not block the PR.

@timotheeguerin

Copy link
Copy Markdown
Member

Changes merged in #5353

auto-merge was automatically disabled September 1, 2026 12:50

Pull request was closed

Jialin Huang (JialinHuang803) pushed a commit to JialinHuang803/typespec-azure that referenced this pull request Sep 1, 2026
Every third-party action in our workflows was referenced by a mutable
tag (`actions/checkout@v7`). Tags can be retargeted, so a compromised
upstream repo silently gets write access to our CI — exactly what
happened in the
[tj-actions/changed-files](https://www.stepsecurity.io/blog/harden-runner-detection-tj-actions-changed-files-action-is-compromised)
and
[codfish/semantic-release-action](https://www.stepsecurity.io/blog/supply-chain-compromise-codfish-semantic-release-action)
compromises.

Every action is now pinned to a full-length commit SHA, with the version
kept as a comment so it stays readable and Dependabot can keep bumping
it:

```diff
- uses: actions/checkout@v7
+ uses: actions/checkout@3d3c42e # v7.0.1
```

Dependabot also gets a 7 day cooldown on the `github-actions` ecosystem,
giving the community a window to spot a compromised release before we
auto-adopt it.

The SHAs resolve to the same commits the tags pointed at, so there is no
behavioral change. Generated `*.lock.yml` agentic workflows are
untouched — `gh-aw` already emits pinned SHAs there.

Redo of Azure#5341, which went
stale with conflicts. See https://aka.ms/action-pinning.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants