```

SHA Pinning Isn't a Silver Bullet: How Attackers Route Around GitHub's Supply Chain Defense

Pinning GitHub Actions to an immutable commit hash — the mitigation most teams adopted after years of supply chain incidents — proved it can be defeated at the point of pinning itself, not after it.

The case in point: in March 2026, attackers who hijacked Trivy, the widely used open-source security scanner, planted malicious code crafted to look like GitHub's official checkout action, according to The Hacker News. Because the malicious content was already present in the reference before anyone pinned it, every downstream pin would have validated without complaint — a perfect SHA, verified integrity, hostile code.

What SHA Pinning Actually Guarantees

SHA pinning replaced mutable version tags (such as @v4) with a full commit hash, making it impossible for a maintainer or attacker to silently swap the code behind a workflow reference after the fact. It has since become baseline practice, and organizations should keep it.

But integrity is not provenance. A pinned SHA proves only that the referenced code has not changed since it was pinned. It says nothing about whether that code was trustworthy, or genuinely from the publisher it claims to be. The Trivy incident exploited pre-pin deception, not post-pin mutation: the counterfeit checkout payload was labeled and structured to look official, so mechanical verification had nothing to catch.

The exposure was unusually broad. Trivy is itself a defensive tool — a scanner that teams deploy precisely to find problems — and the checkout action is near-ubiquitous in GitHub Actions workflows. By impersonating it, the attackers gave the counterfeit reach wherever the tool was in use.

A Mitigation Checklist

The fix is not to abandon pinning, but to stop treating it as the whole defense. Industry practice points to four additional layers:

1. Signed provenance and attestations. Require cryptographically signed build provenance for actions and artifacts before they execute. Sigstore's signing and verification tooling, GitHub's artifact attestations, and the SLSA framework's provenance levels all let teams confirm not just that code is unchanged, but that it was produced by whoever claims to have produced it. Where an upstream project publishes signed releases, verify them; where it does not, treat unsigned actions as elevated risk.

2. Policy as code. Move enforcement out of code review and into automated gates. Open Policy Agent with Conftest can reject workflow definitions that reference unpinned or unverified actions. GitHub's organization-level workflow controls and action allowlists add a second chokepoint, restricting which publishers an entire organization may run.

3. Least-privilege workflow hygiene. Set explicit, minimal permissions blocks on every workflow so a compromised action inherits as little access as possible, and isolate secrets from jobs that do not need them.

4. Lookalike-action audits. Periodically inventory workflow references and confirm each action resolves to the expected publisher and repository — catching typosquatted or impersonated actions before they are pinned.

The Bottom Line

SHA pinning is a baseline, not a finish line. It closes the door on post-pin tampering while leaving the provenance question open — and attackers have demonstrated they will exploit that gap directly. Layering attestation, policy-as-code, and token hygiene on top of pinning is what converts a single check into an actual defense-in-depth posture.

For teams wanting a deeper walkthrough of the technique, The Hacker News piece points to an accompanying webinar covering the bypass and how to close it.

Source: The Hacker News


```

SHA Pinning 並非萬靈丹:攻擊者如何繞過 GitHub 的供應鏈防禦

將 GitHub Actions 固定(pinning)至不可變更的 commit hash——這是多年供應鏈事故後大多數團隊採用的緩解措施——已被證明可以在固定環節本身被繞過,而非事後遭篡改。

據 The Hacker News 報導,具體案例發生在 2026 年 3 月:攻擊者劫持了廣泛使用的開源安全掃描工具 Trivy,植入了經過精心偽裝、看似 GitHub 官方 checkout action 的惡意代碼。由於惡意內容在任何人進行固定之前就已存在於被引用的版本中,之後每一次下游固定驗證都不會發出任何異常——一個完美的 SHA、已驗證的完整性,以及惡意代碼。

SHA Pinning 實際保證了什麼

SHA pinning 以完整的 commit hash 取代了可變更的版本標籤(例如 @v4),令維護者或攻擊者無法在事後悄悄替換 workflow 引用背後的代碼。此做法此後已成為基準實踐,各機構應予保留。

然而,完整性(integrity)並不等同於來源出處(provenance)。固定的 SHA 只能證明被引用的代碼自固定以來未曾更改,卻無法說明該代碼是否可信,或是否真的來自其聲稱的發布者。Trivy 事件利用的是固定前的欺騙(pre-pin deception),而非固定後的篡改(post-pin mutation):偽造的 checkout 負載在標籤和結構上都刻意模仿官方外觀,機械式驗證因而無從察覺。

這次影響範圍異常廣泛。Trivy 本身就是一個防禦工具——團隊部署它正是為了找出問題——而 checkout action 在 GitHub Actions workflow 中幾乎無處不在。攻擊者透過冒充該 action,令偽造品隨工具的使用遍及各處。

緩解措施清單

解決方法並非放棄 pinning,而是不要將其視為完整的防禦。業界實踐指出需要另外四層措施:

1. 已簽署的來源出處與 attestations。 要求 action 及 artifacts 在執行前具備經 cryptographic 簽署的建置來源出處。Sigstore 的簽署與驗證工具、GitHub 的 artifact attestations,以及 SLSA framework 的來源出處層級,均令團隊不僅能確認代碼未遭更改,更能確認其確由聲稱的生產者所產生。若上游專案發布已簽署版本,應予驗證;若沒有,則應將未經簽署的 action 視為較高風險。

2. Policy as code。 將執行從代碼審查轉移至自動化閘口。Open Policy Agent 配合 Conftest 可拒絕引用未固定或未經驗證 action 的 workflow 定義。GitHub 的機構級(organization-level)workflow 控制與 action allowlist 則提供第二重管制點,限制整個機構可以運行哪些發布者的作品。

3. 最小權限的 workflow 衛生。 為每個 workflow 設定明確且最小化的 permissions 區塊,令被入侵的 action 所繼承的權限盡可能少,並將 secrets 與不需要它們的 job 隔離。

4. 偽冒 action 審計。 定期盤點 workflow 引用,確認每個 action 都解析至預期的發布者與 repository——在被固定之前揪出 typosquat 或冒充的 action。

總結

SHA pinning 是基準,而非終點。它關上了固定後篡改的大門,卻令來源出處問題懸而未決——而攻擊者已證明他們會直接利用這一漏洞。在 pinning 之上疊加 attestation、policy as code 與 token 衛生,才能將單一檢查轉化為真正的縱深防禦(defense-in-depth)姿態。

如欲深入了解該技術,The Hacker News 的文章附有一場網絡研討會,涵蓋此繞過手法及如何堵塞漏洞。

Source: The Hacker News

新聞來源 / Original News Source