logoalt Hacker News

kazinator • yesterday at 6:25 PM • 5 replies • view on HN

The problem of a SH1 collision happening by coincidence is vanishingly low and theoretical.

Nothing else matters.

Git hashes are not supposed to be a security mechanism. If your basis for trusting that you have the right checkout is the git hash, in a situation where you have legitimate concern about untrusted parties manipulating remote repositories, then you're simply wrong.


Replies

zygentoma • yesterday at 7:58 PM

Sorry, no.

When I check out code from a git repository in a pipeline using a git hash, I expect the code to be exactly what has been reviewed by me under that hash.

Everything else would just be a crazy invitation to make supply chain attacks uncircumventable.

➕ show 1 reply
someonebaggy • today at 4:11 AM

You could pull a malicious colliding PR and reject it. Then you pull the other half of the collision without realising it is, and it's something good and you merge it. But your CI server already saw the malicious one and thinks it's the same, so builds the malicious code

shakow • yesterday at 6:47 PM

> Git hashes are not supposed to be a security mechanism

Probably a naive question, but why not kill two birds with one stone if it can be done for a reasonable cost?

➕ show 1 reply
SAI_Peregrinus • yesterday at 9:58 PM

> Git hashes are not supposed to be a security mechanism.

Commit signing indicates otherwise.

➕ show 1 reply
pseudohadamard • today at 5:25 AM

That's what a lot of the responses are missing, which is why the response to them in turn is both no and yes. There's no published threat model that I know of for the properties that the hashes are supposed to be providing for git, which means anyone can make up any required property they like and then confidently state that SHA-1 provides or does not provide it, see this discussion for examples. The result is, to use another Linus quote as the OP has already quoted him in the writeup, "people wanking around with their opinions".

We use SHA-1 in our storage mechanism, which predates git. There is a (quite long) written threat model. Someone being able to generate collisions with an enormous amount of effort under just the right conditions is not a threat under that model.