Collision attacks - How do they work?

Status
Not open for further replies.
I was reading the new Ars article about Microsoft's decision to retire SHA-1 due to its vulnerability to collision attacks.

The article mentions the well-publicized Flame attack of 2012, a key component of which was a collision attack against MD5.

But what is a collision attack?

Not a collision, mind you. That's simply stated: a collision is a pair of messages, m1 and m2, such that hash(m1) = hash(m2).

But how does knowing such a pair of messages help an attacker?
 

Jonathon

Ars Legatus Legionis
17,646
Subscriptor
Basically, the authors of the Flame malware were able to produce a fake intermediate certificate authority (deriving from one of Microsoft's legitimate certificate authorities) because the signature algorithm was weak (in this case, they used MD5).

Some background: one way to validate that a message came from a specific source is to use public and private key cryptography (such as RSA). If I encrypt a copy of a piece of known data with my private key, you can then attempt to decrypt that piece of known data with my public key. You then know (since it's my private key) that the piece of data really came from me. This is the premise by which certificate signing works: if I get a digital certificate (saying, for example, to trust a publisher and run code that they provide), and it's been signed by (for example) Microsoft, I know that said certificate has been approved by Microsoft, and since I trust Microsoft, I run the code that came with that certificate (or, more specifically, the code that was then signed with the public key in that certificate).

Now, it's not terribly efficient to work with the whole piece of data when you want to sign something: it takes longer to transfer, and takes longer to verify. So, rather than encrypt and decrypt the whole certificate as part of the signing and verification process, we want to work with something smaller. That's where cryptographic hashes come in. Hash the data, then encrypt the hash instead. Then, when you want to verify the signature, you recalculate the hash of the (plain-text) data, decrypt the signature using the signer's public key, and if the two hashes match, then the plain-text data (in this case, our certificate) hasn't been tampered with and you can trust it.

This all works great, as long as you don't have a way to force the hash to become a known value when you give it a different text. In the case of MD5 (which is what the certificates involved in Flame used), you can do this-- with padding constructed in a specific way, I can produce whatever certificate I want, and make it look like Microsoft has approved it, without ever knowing Microsoft's private key, because the hash that they encrypted never changed. Mayhem then ensues, because I can now produce code that your computer trusts implicitly-- because, as far as it can tell, the code did come from Microsoft. Flame used this (IIRC) to forge Windows updates.

As to the retirement of SHA-1: that's more of a proactive measure. There aren't (AFAIK) any practical attacks against SHA-1 yet... but, by 2016, when MS retires the algorithm for certificate signing, computers will be faster and people will have had more time to find flaws in the math underlying the algorithm. Best to schedule its retirement before that happens (and hope it doesn't happen earlier).
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
The serious issue for MD5 is that it's gone from 'there exists collision attacks of some form' which are a serious warning sign but not an immediate way to significantly exploit mmny protocols relying on it (or at least not reliably and quickly) to chosen prefix attacks. Once you have that actual real world protocols are *vastly* easier to exploit, many protocols do not prevent stuffing of arbitrary data into their payloads (and may not be able to for them to be useful).

This gets even worse when the protocol involves the attacker being able to supply some input data, and alter it significantly, with unlimited time to construct this data with malicious intent. This sadly includes certificate signing.
For certificate signing the payoff to doing this just once is huge (until someone finds out, you can spoof to anyone else trusting the certificate supplier). For that sort of thing collision attacks that still seem significant cost as a one off become a reasonable target for people with access to significant parallel compute hardware (which is now any one with a few grand for some GPUs and the power bill) cluster. The first publicly demonstrated MD5 certificate collision was using a 2^50 (still a large number) but that got done in academia, extrapolation to what might be possible by nation states not even needed any more, we know they can throw immense amounts of hardware at it in comparison.
 

ramases

Ars Tribunus Angusticlavius
9,024
Subscriptor++
[url=http:/civis/viewtopic.php?p=25675307#p25675307:2haidre0 said:
ShuggyCoUk[/url]":2haidre0]The first publicly demonstrated MD5 certificate collision was using a 2^50 (still a large number) but that got done in academia, extrapolation to what might be possible by nation states not even needed any more, we know they can throw immense amounts of hardware at it in comparison.

That particular attack used about 200 PS3s and took roughly 72 hours to find a collision. It also exploited the fact that this particular certificate authority was generating certificate serial numbers in a purely linear fashion, and you can of course influence this counter progression by ordering dummy certificates. It also took them 2-3 attempts, since when they started their search for a collision they had to correctly guess the serial number counter those 72 hours in advance.

200 PS3s where, while expensive for an individual or maybe a cash-strapped research group, is not a significant outlay for a nation state meaning business.
 
[url=http:/civis/viewtopic.php?p=25675049#p25675049:21lwd2h6 said:
Jonathon[/url]":21lwd2h6]with padding constructed in a specific way, I can produce whatever certificate I want, and make it look like Microsoft has approved it
.

I think this is what's sticking in my brain.

When you change the message, including any "padding", you change the hash. Thus you're no longer doing a birthday "attack". Suppose you've got a list of legitimate messages {m1, ..., mk} = ℳ, with a list of corresponding hashes {hash(m1), ... , hash(mk)} = Ω. You need to create a payload message p such that hash(p) ∈ Ω, AND such that p contains some arbitrarily long substring of your design. If you can do both of those it's clear how to attack. If you can only do the first one, it doesn't seem to help you. I think Shuggy might have explained it. The real threat actually is "chosen prefix" (or "chosen substring") attacks.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
In fairness the moment someone has a collision of any form or complexity that is more than a few bits of strength reduction it's time to run for the hills.
Often converting them into real world attacks takes a long time (years) but who's to know if anyone in the security establishment did better than the academics in less time, or that with that updated knowledge they are at the stage they can achieve a single well chosen attack at great expense but unthinkable to the rest of the world. There's also considerable history of gifted Cryptographers keeping quiet about their achievements for decades to assist their governments.
 

puffinus

Ars Praefectus
4,381
Subscriptor
[url=http:/civis/viewtopic.php?p=25676047#p25676047:2qnupfc5 said:
masonk[/url]":2qnupfc5]
[url=http:/civis/viewtopic.php?p=25675049#p25675049:2qnupfc5 said:
Jonathon[/url]":2qnupfc5]with padding constructed in a specific way, I can produce whatever certificate I want, and make it look like Microsoft has approved it
.

I think this is what's sticking in my brain.

When you change the message, including any "padding", you change the hash. Thus you're no longer doing a birthday "attack". Suppose you've got a list of legitimate messages {m1, ..., mk} = ℳ, with a list of corresponding hashes {hash(m1), ... , hash(mk)} = Ω. You need to create a payload message p such that hash(p) ∈ Ω, AND such that p contains some arbitrarily long substring of your design. If you can do both of those it's clear how to attack. If you can only do the first one, it doesn't seem to help you. I think Shuggy might have explained it. The real threat actually is "chosen prefix" (or "chosen substring") attacks.

One problem with collisions:

If we were talking about a text message like "I'm Joe Smith and I gave this certificate to Bob Jones" it would be fiendishly difficult to produce a useful fake message which generated the correct hash and which also looked plausible.

If we're talking about a data format which allows different input to produce the same output from the user's point of view the problem becomes much easier. Example: an HTML file which displays the text message above to the user but which could contain a comment block the attacker can mess with that won't get noticed.
 

Jonathon

Ars Legatus Legionis
17,646
Subscriptor
Two documents that may be of interest:

Microsoft's dissection of the Flame forged certificates: http://blogs.technet.com/b/srd/archive/ ... lware.aspx

The paper describing the chosen-prefix attack used by Flame, as applied to X.509 certificates: http://www.win.tue.nl/hashclash/EC07v2.0.pdf (and also http://www.win.tue.nl/hashclash/ChosenPrefixCollisions/ )
 
Status
Not open for further replies.