News for hackers. Stuff that matters.
Re:What does a PGP signature on a Git commit prove? by petertodd on Tuesday March 30, 2021 @08:16PM (#26642120)
So the big problem with Git and SHA1 is that in many cases you are giving full control to an untrusted third party over the sha1 hash of something. For example, if you merge a binary file, it'd be quite easy for them to generate two different versions of the same file, with the same SHA1 digest, and then use the second version to cause problems in the future. You may also be able to modify a text file in the same way without getting noticed in review (I'm not up to speed on how advanced sha1 collision techniques are now).

Similarly, the git commits you merge themselves could have that done - the actual git commit serialization gives you a fair bit of ability to append stuff to it that isn't shown in the UI. That wouldn't affect the signed git commits. But it's still dubious to have the ability to change old history in a checkout.

Anyway, Git is apparently moving towards SHA256 support, so hopefully this problem will be fixed soon: https://lwn.net/Articles/823352/

Re:What does a PGP signature on a Git commit prove? by thephyber on Tuesday March 30, 2021 @09:47PM (#26642668)
> it'd be quite easy for them to generate two different versions of the same file

Citation needed. When SHA1 was cracked, it cost $110k worth of cloud computing. And there was some restriction on the two files which matched checksums. IIRC it was like the Birthday Paradox — you don’t pick one and find another sharing the same match, but you generate billions of mutations of similar binaries and statistically two would have the same checksum.

Not exactly easy, fast, cheap, or work with all use cases.

Re:What does a PGP signature on a Git commit prove? by cratermoon on Wednesday March 31, 2021 @12:48AM (#26643627)
Re:What does a PGP signature on a Git commit prove? by bawolff on Wednesday March 31, 2021 @01:23AM (#26643807)
That was a later attack, not the original. Attacks get cheaper with time.
Re:What does a PGP signature on a Git commit prove? by bawolff on Wednesday March 31, 2021 @01:33AM (#26643856)
Later versions of the attack were much cheaper and also chosen prefix collisions which are much less restrictive in the requirements on the file.
Re:What does a PGP signature on a Git commit prove? by petertodd on Wednesday March 31, 2021 @04:56AM (#26644954)
> And there was some restriction on the two files which matched checksums.

I know. That's why I mentioned the difference in difficulty between getting a collision in binary files and git commit objects themselves, and textual sourcecode.

Re:What does a PGP signature on a Git commit prove? by westurner on Tuesday March 30, 2021 @11:39PM (#26643265)
That nonce value could be ±\0 or 5,621,964,321e100; though for well-designed cryptographic hash functions it's far less likely that - at maximum difficulty - a low nonce value will result in a hash collision.
Re:What does a PGP signature on a Git commit prove? by bawolff on Wednesday March 31, 2021 @01:25AM (#26643815)
? How are nonces even involved in this?
Re:What does a PGP signature on a Git commit prove? by westurner on Wednesday March 31, 2021 @03:40AM (#26644487)
Searching for the value to prepend or append that causes a hash collision is exactly the same as finding a nonce value at maximum difficulty (not less than the difficulty value, exactly equal to the target hash).

Mutate and check.

Re:What does a PGP signature on a Git commit prove? by bawolff on Wednesday March 31, 2021 @04:18AM (#26644723)
The term nonce has a broader meaning than how it is used in bitcoin. (Edit: i reworded this sentence from what i originally had)

That said, no, finding a collision and finding a preimage are very different things, and well the collision attacks on sha1 will involve a lot of guessing and checking, they are not generic birthday or bruteforce attacks but rely on weaknesses in sha-1 to be practical. They also do not make preimage attacks practical.

Re:What does a PGP signature on a Git commit prove? by westurner on Wednesday March 31, 2021 @09:13AM (#26646821)
Brute forcing to find `hash(data_1+nonce) == hash(data_0)` differs very little from ``hash(data_1+nonce) < difficulty_level`. Write each and compare the cost/fitness/survival functions.

If the hash function is reversible - as may be discovered through e.g. mutation and selection - that would help find hashes that are equal and maybe also less than.

Practically, there are "rainbow tables" for very many combinations of primes and stacked transforms: it's not necessary to search the whole space for simple collisions and may not be necessary for preimages; we don't know and it's just a matter of time. "Collision attack" https://en.wikipedia.org/wiki/Collision_attack

Crytographic nonce > hashing: https://en.wikipedia.org/wiki/Cryptographic_nonce#Hashing

Re:What does a PGP signature on a Git commit prove? by bawolff on Wednesday March 31, 2021 @09:56AM (#26647337)
> Brute forcing

The attack being discussed is not a brute force attack (or not purely). If the best attack on sha1 was bruteforce than we would still be using it.

> to find `hash(data_1+nonce) == hash(data_0)` differs very little from ``hash(data_1+nonce) < difficulty_level`.

Neither of those are collision attacks (assuming you dont control the data variable). The first is a second pre-image and the second (with equality) would be a normal preimage.

The attack for sha1 under discussion (chosen prefix collision) is finding hash(a+b) == hash(c+d) where you control b and d (but not neccesarily a and c)

> Practically, there are "rainbow tables" for very many combinations of primes and stacked transforms:

What do primes or rainbow tables have to do with any of this? Primes especially. Rainbow tables are at least related to reversing hashes, if totally irrelavent to the subject at hand, but how did you get to primes?

Re:What does a PGP signature on a Git commit prove? by westurner on Wednesday March 31, 2021 @05:54PM (#26653631)
Practically, iff browsers still relied upon SHA-1 to fingerprint and pin and verify certificates instead of the actual chain, and there were no file size limits on x.509 certificates, some fields in a cert (e.g. CommonName and SAN) would be chosen and other fields would then potentially be nonce.

In context to finding a valid cert with a known good hash fingerprint, how many prime keypairs could there be to precompute and cache/memoize when brute forcing.

"SHA-1 > Cryptanalysis and validation " does list chosen prefix collision as one of many weaknesses now identified in SHA-1: https://en.wikipedia.org/wiki/SHA-1#Cryptanalysis_and_valida...

This from 2008 re: the 200 PS3s it took to generate a rogue CA cert with a considered-valid MD5 hash: https://hackaday.com/2008/12/30/25c3-hackers-completely-brea...

... Was just discussing e.g. frankencerts the other day: https://news.ycombinator.com/item?id=26605647

Re:What does a PGP signature on a Git commit prove? by zie on Wednesday March 31, 2021 @12:08AM (#26643416)
'quite easy' is relative, and just because you can find some file that matches the hash, there is also a very high likelihood that the file will be useless. The chances of generating a USEFUL file(where useful means it does something, like compile, nefarious or not) and causes a SHA1 hash collision are very low... currently.

So to get a nefarious file that puts in an exploit or something useful for an attacker AND causes a SHA1 collision is a very very high bar to meet, currently.

Hopefully they replace SHA1 with SHA256/etc before the capability becomes feasible.

Re:What does a PGP signature on a Git commit prove? by pdpi on Wednesday March 31, 2021 @12:20AM (#26643476)
Sort of. This is really tricky to achieve with text files (where the padding necessary to make the hashes line up looks completely out of place), but many binary formats allow arbitrary padding — e.g. zip files have an index at the end. Inversely, png files have a header and ignore meaningless data at the end. Both can be padded with arbitrary data (and, indeed, you can cat a png and a zip together as a janky steganography system)
Re:What does a PGP signature on a Git commit prove? by michaelt on Wednesday March 31, 2021 @03:49AM (#26644529)
For text files, tools for brute forcing a git commit hash [1] work by messing with the author and committer timestamps.

Of course, that only gives you about 40 bits to play with (assuming the further you move the timestamp, the easier it is to detect) so it wouldn't be completely sufficient on its own.

[1] https://github.com/DesWurstes/VanityCommit#alternatives

Re:What does a PGP signature on a Git commit prove? by zie on Wednesday March 31, 2021 @04:03PM (#26652362)
I agree in binary formats, it's easier to accomplish, but it by no means is easy.

Thankfully most source code is plain text. There are mostly trivial ways to encode information in whitespace/etc, but again, the ability to carry some useful information AND commit a SHA1 collision is currently non-trivial. Plus Git has specifically put in some hardening for the existing SHA1 hashes to make this even less feasible in the particular application of a git repo.

A pipe wrench to the back of the head(or social engineering) of some random committer is probably a LOT easier to accomplish.

That said, if your primary nemesis is one the giant nation states(US, China, Russia, Etc) AND you were very high target for them, then all bets are off, as they can pretty much accomplish whatever they want against any individual/small group on the planet. I would imagine most of us are not even remotely in this situation.

Re:What does a PGP signature on a Git commit prove? by hnedeotes on Wednesday March 31, 2021 @02:06AM (#26644004)
I have thought about this in regards to Nix but as far as I could conceive, it seemed that:

a) you can definitively generate content that will be hashed to the same value - this is a given since anything that compresses a source into a much shorter representation allows that by definition (lets ignore feasibility/time/cost)

b) Making a) in a way that the contents are usable for a given purpose, doesn't introduce severe noticeable changes, and plays ball with the remaining stuff (OS, build chains, the context where it's included in, etc) seems to be the actual difficult part

So my conclusion was at the time that in terms of feasibility it's probably easier to hack the chain itself replacing the hash. But again, if there's a master "hash" for whatever artefact is produced that relies on all those hashes it would also need to be replaced?

Re:What does a PGP signature on a Git commit prove? by bawolff on Wednesday March 31, 2021 @01:31AM (#26643840)
I dont think this is true.

For a chosen prefix collision you need to be able to hide a few bytes of binary data in the file. Sometimes that is prohibitive but in most file formats that is do-able.

Re:What does a PGP signature on a Git commit prove? by zie on Wednesday March 31, 2021 @04:07PM (#26652426)
OK, let's assume what you say is true. You spent the $100k or whatever to compute a SHA1 hash collision and you can replace the bits 11011 with the bits 1010. How is this useful? It *MIGHT* be useful, but chances are it's not very useful, as lots of data formats are pretty lossy and a random bitflip here or there doesn't matter that much.

Just because you have a SHA1 collision doesn't mean you can put any bits wherever you want and still have it be a SHA1 collision.

The really hard part is being able to flip whatever bits you want(to achieve some goal, like a RCE or whatever) AND make it a SHA1 collision. This is currently very much an open problem, nobody has been able to demonstrate(that we are aware of).

Re:What does a PGP signature on a Git commit prove? by josefx on Wednesday March 31, 2021 @07:01AM (#26645728)
> For example, if you merge a binary file, it'd be quite easy for them to generate two different versions of the same file, with the same SHA1 digest, and then use the second version to cause problems in the future.

I think the last time I saw this come up the response was that git will just ignore your attempt to merge a new file if the checksum is the same. So you would have to compromise the repo server directly to replace it.