Hacker News new | ask | show | jobs
by hedora 65 days ago
SHA-1 is used for security in git. It's the thing that guarantees a commit SHA is unique. Without that, you open up all sorts of downstream infrastructure to supply chain attacks, where old objects get replaced with malicious ones, and then replicated on each subsequent git pull.

Linus' old argument was that the substitution would probably be noticed eventually, but that's specific to the way Linux uses git, and what he said probably isn't true in practice -- even if it is, there have been enough supply chain attacks since then to prove that even temporarily serving the wrong stuff to developers or CI is enough to allow lateral movement into other packages, production machines, etc, etc..

LWN had a good write up on this a while back: https://lwn.net/Articles/715716/

1 comments

> At that time, Torvalds responded that SHA-1 is not the real security mechanism used in Git and, as a result, even a full compromise of the hash function would not necessarily be a problem.

It seems that the usage of SHA-1 is interpreted as a security mechanism while Linus used it mainly for other reasons, such as look up speed and deduplication of objects.

You can read the original README file when Linus created git[1]:

>+TRUST: The notion of "trust" is really outside the scope of "git", but

>+it's worth noting a few things. First off, since everything is hashed

>+with SHA1, you _can_ trust that an object is intact and has not been

>+messed with by external sources. So the name of an object uniquely

>+identifies a known state - just not a state that you may want to trust.

> ...

> +Another way of saying the same thing: "git" itself only handles content

> +integrity, the trust has to come from outside.

Yes if SHA-1 is broken, then content integrity can be broken but to me it looks like Linus at the time looked it from the point of view of corruption of files instead of "malicious" files.

[1]: https://git.kernel.org/pub/scm/git/git.git/diff/README?id=e8...