The Comforting Lie Of SHA Pinning

39 points by rrampage


dzwdz

There’s a widely held belief that pinning a GitHub Action to a commit SHA gives you immutability, its what Microsoft/GitHub are recommending, and its what Aqua are recommending. After all, a SHA is content-addressed. It cannot be moved. It cannot be re-tagged. It is, in theory, the most stable reference you can use.

Why is that written as if that wasn't true. It literally is immutable.

I thought that article was going to be about some weird-ass bug where you can fake the commit hash, and swap out a version that someone has pinned for a malicious one. That doesn't seem to be the case here, and pinning works as intended. (I suppose the AI hero image should've been a tell...)

I believe the industry advice is a bit of an overcorrection, and we’ve replaced one weak guarantee (mutable tags but scoped to repo) with another vastly worse idea in unscoped SHAs. Yes you should check, yes you should validate it, but tags are human readable, SHAs are not and if you ask yourself “Do I always properly check?” do you? because I can’t say I do enough validation 100% of the time.

So what? With how things are, you have to choose which of the following you are safe from:

Why would you ever decide that the latter is more important? You can prevent the latter in other ways, because it relies on you making a mistake. You can't prevent the former. Sure, I get why you would want to safeguard yourself against that mistake, but why would you ever do this at the expense of not pinning hashes? This is an absurd trade-off to make.


This is lowkey the sort of article Jia Tan would write if he got commit access to a widely used action.