Hello guys!
Now that you know so much about hashes let’s move on a see wall talk about attacks on
hash algorithms.
There are 3 types of attacks on hash algorithms:
A collision attack on a cryptographic hash tries to find two inputs producing the same hash value hence
the name hash collision. One of the properties of hash functions is that there is a unique hash for each
input.
So how could we have the same hash for more different inputs because a hash function can have an infinite
number of inputs and a predefined output length,
for example sha256 always produces a hash of 256 bits long,
there is inevitably going to be the possibility of two different inputs that produce the same output
hash. If two different inputs produce the same output hash it is called a collision which can then be
exploited by any application that compares to hashes together - such as password hashes, file integrity,
checks and so on. The odds of a collision are very low especially for new and secure hash functions with
very large output sizes. However, as available computational power increases, the ability to brute force
hash collisions becomes more and more feasible. At this moment
in 2020, the SHA-2 family of hash algorithms are considered strong enough to be safe for the foreseeable
future. If you are trying to perform a coalition attack on sha-256 or sha-512 at a rate which is a thousand
times faster than the fastest computer in the world
you'll need a longer time than the age of the universe. However old and obsolete harsh algorithms like
md5 or sha1 are not considered secure anymore because it's trivial to find collisions.
I'll show you an example of a collision of md5 and a collision of sha1.
Let's take a look at these two images!
You'll notice for sure that they are completely different.
Let's calculate their hashes using md5.
They are on my desktop directory in another directory called hash collisions.
I am moving to that directory.
Okay so md5sum plane.jpg and ship.jpg - the images
and surprise: we notice that even though the input is different, the output hash is the same.
This is a collision of md5. If I used another algorithm I would get different hashes. Let's calculate
their hashes using sha 1.
It's different.
This is a collision
Only for md5. Now
let's see another collision, this time of the sha1 algorithm. PDF files that display
different content, yet have the same SHA-1 digest.
This is the first PDF.
And this is the second; okay!
These are the PDFs. Let's see their hashes sha1sum and the PDF files.
They have the same hash! By the way to find these two colliding files was not an easy job.
It was the shattered project led by Google Research Security in 2017.
You can find more information here.
at shattered.io. The attack "the equivalent processing power of 6,500 years of
single-CPU computations. tThe team has spent two years developing the technique and
and the cost of the resources involved was more than $130,000 at that time.
Many collisions exist in all hash algorithms but you cannot find any in a reasonable amount of time
because it could take you years.
I’ll attach to this lecture the files that produce the collisions as a resource. Another attack
on a hash algorithm is called 1st preimage attack and it means to find the message that has a specific/
a given hash value. If a simple collision means to find two messages that have the same hash.
1st preimage attack means to find the message that has a given hash and it's much harder to be performed
but also more destructive.
Imagine someone has the hash of a password and finds a completely new password, not to the correct one,
that has the same hash as the good one. And the last attack is called the second preimage attack.
It means that for a given message you should find another message that has the same hash.
This is also very destructive.
Just imagine you have a very important document that you want to send to someone and the hacker creates
a second to document that has the same hash.
The shattered attack we've just seen is just a collision, not a preimage attack.
In general a collision attack is easier to be performed than a preimage attack, as it is not restricted
by any set value (any two values can be used to collide).