Is there any likelyhood that two different versions of the same file will produce the same characters at the start of the hash and at the end of the hash (say, the first/last five characters) - is it really only necessary to check those characters? Since this is routinely done by visual verification, what is the level of risk that a subtle difference would not be detected?

  • 1
    You're effectively turning it into a 40 bit hash. The collision rate should be similar to other 40 bit hashes, I would imagine. – broadway Oct 16 '15 at 3:35
  • What are you concerned about? Are you just concerned about accidental errors? If so then you're better off with your method than with CRC32, but if you think someone might be trying to deceive you then check the whole hash (and it would be in your best interest to use a more secure hash function while you're at it) – Owen Oct 17 '15 at 1:49

Yes, you do.

If you're only comparing the first and last five characters of a hash, you've effectively turned it into a 40-bit hash. Under these conditions, a collision has a complexity of 2^20, low enough that an attacker can generate one through brute force in a second or less. A preimage is harder, at 2^40, but dedicated hardware (eg. a GPU array) can generate it in only a few minutes.

It doesn't matter what hash algorithm you're using, either: if you're ignoring the middle of the hash, the difficulty of making the ends match doesn't depend on how long that middle is.


I usually place the hashes side by side, it should be easy to spot differences quickly. Probably takes only a few seconds more to check.

It is orders of magnitudes easier to generate hashes which look similar, e.g. first 5 and last 5 characters the same. However, the adversary must take into account that someone might check the entire hash and when a mistake is found, the alarm is raised. Hence, he has "burned" a potential vector of attack since the server owner will be notified and will patch the system to prevent the adversary from accessing the server in future.

The other thing to note is that while obtaining a complete hash collision might not be very difficult. The resultant file obtained must be executable, contain the malicious code intended, and be of a reasonable size. There is no point replacing a 2GB ISO with a 5TB file containing gibberish and cannot be mounted as an ISO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.