Skip to content

Comment on Colliding with the SHA prefix of Linux's initial Git commit

Comments

There were some plans to migrate to SHA256, but somehow it still hasn't happened.

The practical upshot is a git commit hash is not enough l to know you are distributing/executing the legitimate code, as opposed to a malicious doppelganger. This is particularly important for tools that rely on it for dependency management, local caches, etc.

TFA has nothing to do with SHA-1 or SHA-1 collisions. It's about abbreviated hash values introduced for readability by humans. Now these values are used by auxiliary scripts. Which again has little to do with git proper. It's just what the kernel community writes into commit messages and what scripts they use to parse those messages.

The practical upshot is a git commit hash is not enough l to know you are distributing/executing the legitimate code, as opposed to a malicious doppelganger

Really now? Mind if I challenge you?

I have on my machine a git repo with commit '75eb4e3b1369706a4dcd61cc80e49660ac341ea4'.

If you can give me a second git repo with such a commit containing different contents, I'll happily send you $10k USD, or donate it to a charity of your choice.

If you can give me a second git repo with such a commit containing different contents, I'll happily send you $10k USD, or donate it to a charity of your choice.

Calculating that SHA1 collision is going to be a bit more expensive than $10k, by a couple of orders of magnitude.

Finding it in the wild is improbable, but calculating it is definitely possible, and has been done before. http://shattered.io/

Shattered didn't produce a collision for an arbitrary hash, it produced two documents with the same hash (which is a slightly easier problem, about 100,000x faster).

SHA1 is certainly insecure at this point, but not even close to trivially so.

Indeed. We can't even do this for md5, let alone sha1.

Preimage attacks are very different from collision attacks.

That is enough to distribute malicious code though, at least in certain scenarios. Someone might create a setup where reviewers check/sign one version of the source code, and what gets distributed is another version with the same hash.

Code review in the Linux kernel still happens by email to a large degree.

Further up in contribution tree there is additional signing. Would that further complicate the insertion of a false commit? I am not convinced that signing is used all the way down to every contribution.

Linux probably has enough eyeballs on its source to make attacks like that unlikely anyway, but Git isn't just used by Linux.

Can you create a proof of concept and show it here?

What's your point?

My point is that you need to put the money where your mouth is.

You're talking about hundreds of millions of dollars to calculate that. "Put your money where your mouth is".

We know it's theoretically possible. And we also know that this theoretical possibility is within the reach of a couple of countries.

If your goal was to prove that SHA1 collisions are unimportant, far too hard for any group to exploit within the next X years of processing improvements... That means math.

In contrast, this "challenge" stuff is just chasing outage endorphins and internet points.

Think it through, and it's pointless. Any refusal or negative result is utterly compromised and confounded by things like: How trustworthy you appear; whether the amount is reasonable; whether the random commenter has the skillset, free time, and financial assets to try; whether they're part of a larger group they can recruit; etc.

My goal is to see the actual proof of concept that whatever the person I replied to is feasible. Not the daily BS from security wannabes that start with "In certain scenarios it is possible to X and Y" and then never show proof.

"In certain scenarios I could be a ninja": it means absolutely nothing without proving that I actually have the skills and I could actually use them.

It is not pointless, but if you claim something show the proof.

The math is the proof of concept when an attack costs that much money to pull off. Or the various papers that show successful attacks on reduced-round versions of the hash.

Do you not accept those? What would you accept as a proof of concept?

I expected a proof of concept for this statement:

_That is enough to distribute malicious code though, at least in certain scenarios. Someone might create a setup where reviewers check/sign one version of the source code, and what gets distributed is another version with the same hash._

Well the proof of concept without actually having two colliding files is really simple, so I thought it was generally understood.

Here's the easiest to explain way: Upload the malicious version of the file to github. Send an innocuous patch to the kernel devs that creates a file with the same hash. It gets accepted, and anyone that downloads the kernel from github gets the malicious version. Done. That's a small fraction of linux downloaders, but this is just the proof of concept.

A proof of concept became much easier with C11 unicode identifiers, and email patch review. You can trivially hide Cyrillic chars eg. between whitespace changes or other trivial "optimizations". Even without collisions.

And with the current surge of GPU's even collisions are realistic now. The H100's are not doing much when not in training.

which is a slightly easier problem, about 100,000x faster

Where did you get this number from? I was under impression that this is completely infeasible (just like we can generate a collision good md5 in seconds, but we still can't do a preimage attack).

The is not a full git commit hash collision. It has to do with a git note which only needs to matche a 12 character prefix of the git commit.

While you corrected one mistake you added a new one:)

Those are git trailers, see git-interpret-trailers(1).

git-notes(1) is something completely different and not used by the kernel.

people don't really care, because current collision methods are mitigated.

Git does not actually use "sha1", despite what all the docs say, it uses "sha1dc", which is just like sha1 except for inputs which can cause collisions, in which case it either fails with clear error message or returns completely different value.

https://news.ycombinator.com/item?id=17825441

so don't worry, git hashes _are_ enough to know you are distributing/executing the legitimate code.

(not to mention you need a preimage attack to replace known commit, and this is not yet possible with sha1)

From your link:

In this case "hash" will be the same as SHA1(input) in all cases, except those where the input is detected to be malicious (as in the SHAttered attack)

I don't see how this can be more than a fundamentally forward-incompatible sticking plaster over the problem. The problem isn't merely that "detecting maliciousness" seems fraught in itself (how does one infer intent reliably?) -- it's that today's SHA1DC() implementation can only detect and optionally correct today's known attacks, so each new attack necessitates a new, incompatible version of SHA1DC().

Each new _unrelated_ SHA1 attack will need an update in SHA1DC. But it has to be truly unrelated, as the collision detection method is fairly robust. I recommend reading the original "Counter-cryptanalysis" paper [0] for details on how attacks work and how they can be mitigated (there is certain internal state in SHA1 that is used in all known attacks). BTW, this paper has an interesting anecdote: apparently Flame malware had exploited MD5 collisions using novel unpublished attack method... and yet it was detected by collision detector (section 3.2). Another example is that SHA-mbles attack, published 3 years after "Counter-cryptanalysis", was detected as well, with no required code changes.

No, there is nothing "fundamentally incompatible" in the new SHA1DC method. After all, git came out in 2005, 11 years before SHA1 attacks were known, so it used regular SHA1. The collision detector was added in 2017 and nothing broke, because false positive chance is 2^-90 [1].

I have not heard of any new SHA1 collision results, but if they are based on no-difference differential paths, git has nothing to worry about. And if they are not, it may be possible to extend DC detector to seamlessly detect and prevent those attacks, and then only upgrade git clients, keeping backward and forward compatibility for data.

Of course there is always a chance that someone will come out with all-new SHA1 preimage attack that cannot be detected without high rate of false positive, so it's prudent to switch git to sha256. There is a lot of work being done: git's sha256 mode went out of beta in 2.42 (2023), but neither github nor gitlab support it.

But since the current state of git's sha is that there is nothing broken, and git git commit hash _is_ "enough to know you are distributing/executing the legitimate code, as opposed to a malicious doppelganger", there is no real pressure.

[0] https://marc-stevens.nl/research/papers/C13-S.pdf

[1] https://github.com/cr-marcstevens/sha1collisiondetection

The problem isn't merely that "detecting maliciousness" seems fraught in itself (how does one infer intent reliably?)

Its not detecting "intent" it is detecting that the hash is one vulnerable to the attack, which is extremely unlikely to happen by accident, so if you see it you can assume malice.

It might be a band-aid, and sha256 is certainly a much better solution, but its more robust than it sounds at first glance (since it sounds crazy at first glance)

Sure it's plaster, but plaster can last a good while. Sufficiently new attacks don't come around all that often, and every hash has a risk of new attacks showing up.

fwiw, I wasn't too familiar with this usage, looked it up and sticking plaster is in the sense of bandaid here https://en.wikipedia.org/wiki/Adhesive_bandage

But agreed that it's a rather tougher patch than I'd originally thought, reading elsewhere in this thread.

Switching to SHA-256 and switching to longer substrings of hashes for identification are basically orthogonal problems. The former is hardly going to help with the latter, except in the we already broke everything so why not take the chance to break some more sense.

Compatibility between remotes using one or the other hasn't arrived yet, and git doesn't want to break compatibility. But you can create SHA256 one's today. [0]

[0] https://lwn.net/Articles/898522/

The hash space is atoms-in-the-universe range; this is a collision in a much, much smaller subset of that space

I think multiple hashes is the way to go to avoid collisions. it can even be something simple like md5. the chances of finding a collision that matches two or more algorithms is near impossible. Obviously that doesn’t work for passwords, but for verifying that data hasn’t been tampered with, it works.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.