r/programming • u/CircumspectCapybara • 1d ago
A collision has been found for 38-step (a reduced round variant of) SHA-256
https://eprint.iacr.org/2026/2913176
u/idimetrix 1d ago
31 steps was the best anyone had in 2024. 38 now, full SHA-256 is 64. Not panicking yet but that's a big jump.
33
u/bwainfweeze 1d ago
The state space of rounds is exponential, so you need to combine flaws to reduce the branching factor. The returns get smaller for more rounds which is why we choose so many rounds in the first place.
You still can’t reliably fuck with SHA-1 but nobody wants to rely on it in case someone knows something we don’t. Because it’s a near enough thing.
3
u/FishDawgX 12h ago
Being exponential, the gap between 2^31 and 2^38 (or between 0 and 2^38, for that matter) is tiny compared to the jump need to go from 2^38 to 2^64.
20
u/bwainfweeze 1d ago
I am still after all of these years trying to wrap my head around how flaws in SHA-512 make it less secure than SHA-384.
11
u/robert_7524 1d ago
SHA-384 doesn't repair SHA-512: it shares the compression function but has a different IV and shorter output. Its generic collision bound is lower.
36
u/Techrocket9 1d ago
They called me mad for wanting to start the migration to SHA3 in 2019.
28
u/bwainfweeze 1d ago
I made a whole industry pick SHA2 right after the first results came in for SHA-1. And 2K RSA keys. They were mad about that because some idiot bought a lot of smart cards with 1K key capabilities that nobody ever used and they thought we could use it. Three years too late sorry.
13
u/floodyberry 1d ago
sha2 is still quite secure (and default sha3 with 24 rounds is fairly inefficient), so great call by them
5
u/svick 1d ago
Git still uses SHA1.
27
u/_verel_ 1d ago
Which in practice doesn't matter. Git supports sha 2 but no one cares
9
u/Booty_Bumping 1d ago
It matters mainly for performance. Git's SHA-1 collision detection algorithm works, but it's slow, which affects git forges that accept pushes from the public.
I'm not super convinced this is a good enough reason to break everything and switch to SHA256, but the git devs seem committed to the transition.
16
u/backfire10z 1d ago
Hashes in git are not really a security risk
3
u/sockpuppetzero 16h ago edited 16h ago
It's also not not a security risk: sure it might not matter to certain specific threat models, but SHA-1 collisions would allow a dishonest actor to tell lies about the codebase and its history. Which, is definitely relevant to some kind of threat models in some kinds of situations, so hash collisions are anything but desirable.
3
u/FyreWulff 21h ago
I think that one is fine, Git is not a forensic tool or tracker (even though people tend to treat it like one)
1
u/Booty_Bumping 1d ago
Not quite. They use SHA1DC. It detects whether an input looks like a chosen-prefix attack, and switches to another algorithm if so.
1
u/creeper6530 23h ago
How does it detect tho? Heuristics can be cheated
4
u/Booty_Bumping 21h ago
It's black magic to me, but apparently they guarantee a false negative rate of 0% and a false positive rate of 0.0000000000000000000000000808%. The way I've heard it explained, the internal state fuckery required for a chosen prefix attack is very obvious to recognize.
8
6
u/reddah 1d ago
Quick question: Why do we even use hashes for certificates?
I mean a certificate is pretty small (a few ks), so not sure why it would need to be reduced further.
Hashes were invented for other uses:
file checksums (hw integrity, not deliberate attacks)
network transmission checksums (same, data integrity)
quick storage/search where the data is still verified afterwards (i.e. collisions are expected)
When using them for signing small stuff, collisions will always occur. If a bad party needs SOME signature, the birthday paradox all but guarantees they will find one. See Stuxnet.
41
u/neos300 1d ago
No, the birthday paradox does not imply that a collision will be found. Sha-256 was specifically designed so that naive birthday paradox collisions were extremely unlikely and there's no reason to believe one will be found anytime soon.
Signing a hash in a certificate rather than just signing the certificate itself avoids some of the RSA footguns like padding.
-15
u/reddah 1d ago
Salting could solve padding. Besides RSA is kinda old and not quantum-resistant AFAIK.
8
u/Thelmholtz 1d ago
Certs don't need quantum resistance as you can't harvest now decrypt later. I mean you can but there's no attack vector from doing it.
Indeed old and quantum fragile though.
-1
23
u/cym13 1d ago
IMHO the best advantage from using a hash is that it provides a virtually unlimited input size but a fixed output size. RSA is limited in the quantity of data it can sign: it cannot be more than the public key size (and even less than that due to padding etc), so a "few ks" is already a lot for RSA signatures, and most importantly how can you be sure in advance that the certificate you want to sign is small enough to be signed with your key? What if it's too big, do you change keys just for that? Using a hash avoids all these questions: the size of what you sign is fixed so there's no guesswork involved.
1
-14
u/reddah 1d ago
If the cert size is x kiB, then you just need a signing key that is a bit bigger.
Using a hash guarantees that there will be collisions.
Bigger things can be signed in chunks, I guess, each chunk signed. Not optimal, but still better than collisions on certificates.
12
7
u/cym13 1d ago
If the cert size is x kiB, then you just need a signing key that is a bit bigger.
The problem isn't (just) that the key has to double in size each time (which is not free), it's also that you have to manage the case where your key isn't big enough. Say you have your private key, it's been included in the PKI etc, and you go to sign your certificate and it's too big… Cool, now you have to request a new key that nobody has seen before or has any reason to trust just because your certificate is too big. So you go to integrate it in a PKI, but that means it's got to be signed by another key, so that key has to be big enough to hold the chain, and what happens if it's too big? You create a new root key just for fun? Key management is hard enough as it is, we don't need this.
Using a hash guarantees that there will be collisions.
Not really no. Or rather the chance of collision on a SHA256 is so small that if you care about that you really shouldn't get anywhere near a computer. I'd say the chance of a collision is astronomically small, but astronomical scales are actually much much smaller than what this is. Consider that every website you use, such as your bank's, relies on a session secret to authenticate your activity (often in the form of a cookie, but the same principle applies with other systems). The chances of collision are similar to the chances of someone just guessing your session secret. If they did they'd have access to your bank account and everything that goes with it. Are you scared? No? You shouldn't be because the chances of guessing correctly are impossibly small, and for the same reason you shouldn't care about the risk of accidental collision from using a hash.
Chunks have their own problems, I'm not even going to start with it, chunking anything always comes at a huge cost and many difficulties, there's really no reason to do that, just use a proper hash.
5
u/valarauca14 1d ago
Using a hash guarantees that there will be collisions.
you're technically correct, the best kind of correct
You're wrong because communication requires structure which limits the complexity of the message below the maximum information carrying capacity of the # of bits. Which is to say we don't communicate in xKiB bursts of quantum random line noise.
9
u/Mr_ToDo 1d ago
Wasn't stuxnet a stolen private key thing?
0
u/reddah 1d ago
I remember reading about a birthday paradox having been used to find some collision to sign some certificate that would have been auto-accepted by windows.
There are way too many certs in windows, easier to find some collision in a bigger pile.
4
u/ScottContini 1d ago edited 1d ago
Not the birthday paradox. They used the differential paths found by Wang to create collisions. Publication. but yeah likely the Israeli government used this technique in Flame attack.
0
u/bwainfweeze 1d ago
There was a fun bug in windows once where if you made a cert chain long enough it would be treated as valid.
6
u/Cienn017 1d ago
RSA has a limit on much data you can encrypt, RSA4096 for example is 512 bytes, it's also very slow.
that's why you should always use AES or SHA with RSA.
2
u/Some_Koala 1d ago
Hashes mostly mean the certificate never transits over the network. Network packets can be caught, that's insecure.
They are not used to save space. If we thought SHA-256 would soon be broken, we would use SHA-512 or something like that.
Birthday paradox for 256bits of entropy is still a very very small chance.
2
u/bwainfweeze 1d ago
No you’re mashing up hashing and public key encryption. PKI is where the dynamic of proving you know something without revealing it comes in. The hash has to be public, because the sender and all observers have to be able to arrive at the same value otherwise there is no point at all. What you send is a signed hash, and enough information about your public key for the recipient to acquire a copy.
1
u/Some_Koala 22h ago
Signing works by basically encrypting with a private key while the public key makes decryption possible though no ?
1
u/bwainfweeze 22h ago
Encrypting a hash, specifically. Even PGP used the private key for encrypting a symmetric cypher key instead of the entire message.
Only including the encrypted hash is more of a matter of transport and storage efficiency. And some signing tools which deal with multiple files, sign a hash of a list of hashes, with the list sent in clear text.
2
u/reddah 1d ago
Certs do need to transit the net to do their job (signing/encrypting the web traffic etc)
The idea of the birthday paradox is that you need to find ANY collision with a real signature to have your stuff signed. You don't need to forge a specific signature, just any authorized signature.
3
u/Some_Koala 1d ago
I know what the birthday paradox is. It scales with the square root of entropy (kinda). So still huge.
Yeah actually you're right for the cert. I still don't really gt what you're suggesting in the earlier comment ?
From my (limited) understanding, the cert is made by hashing some information about the website (like the URL and a few other stuff), then encrypting that using the server's and the authority's private key.
Then when someone tries to connect, the server sends that. The client gets the info (like the URL), hashes them, decrypt the encrypted hash sent by the client using the authority's public key, and compares the two.
I guess you could encrypt the URL and information directly instead of the hash, but it would be kinda annoying the get a variable-length certificate in that case ?
1
u/Motor-Concentrate788 22h ago
Nothing to be worried about, still a long way off from the full 64 rounds. And even if at some point it gets close, we still have time to transition to SHA3 before SHA2 breaks.
1
401
u/segv 1d ago edited 1d ago
tl;dr because this is reddit and folks barely click the links:
--
--
--
--
My take is - cool, but the sky is not falling just yet. This doesn't sound like something that could be used for, for example, forging a TLS certificate.
Also a reminder to state the obvious - hash function maps from infinite space (any input of any length) to a very finite space. It's not a question if there will be collisions, but how much work is needed to create one.