trio.so
Explained

Hash Types and the Attacks Against Them

Common hash types (MD5, SHA-256, bcrypt, NTLM) and the attacks against them: rainbow tables, pass the hash, collisions and hash DoS, with defences.

Mountain landscape representing leadership perspective and vision
Written by
Atena Ladchartabi

Content writer, trio.so

Published on
Modified on

A hash function turns any input into a fixed-length string, and you cannot run it backwards. Systems store password hashes instead of passwords so a stolen database does not hand over the passwords themselves. The common hash types are MD5, SHA-1, SHA-256, bcrypt and NTLM. Attackers break them by guessing (brute force and dictionary attacks), by looking answers up (rainbow tables), by reusing the hash itself (pass the hash), by forcing collisions, or by overloading hash tables (hash DoS).

Hash types: MD5, SHA-1, SHA-256, bcrypt and NTLM compared

There are dozens of hash functions. These five are the ones IT staff meet most. The main split is between fast general-purpose hashes (MD5, SHA-1, SHA-256) and slow password hashes (bcrypt).

HashOutput sizeUsed forStill safe?
MD5128 bitsFile checksums, old password databasesNo for security. Collisions are practical, and it is far too fast for passwords.
SHA-1160 bitsOld certificates, Git object IDs, legacy signaturesNo. NIST deprecated it in 2011 and plans to retire it from its remaining protocols by 31 December 2030.
SHA-256 (SHA-2 family)256 bitsDigital signatures, certificates, integrity checks, blockchainsYes for integrity and signatures. Not on its own for passwords: it is fast, so use a slow password hash around it.
bcrypt60-character string with built-in saltPassword storageYes, with a work factor of at least 10, and a 72-byte limit on password length. OWASP lists it for legacy systems; Argon2id is preferred.
NTLM (NT hash)128 bitsWindows password hashes, NTLM authenticationWeak. It is an unsalted MD4-based hash, quick to crack and reusable in pass-the-hash attacks.

Other types you will see: SHA-3 (a different design, same strength goals as SHA-2), Argon2, scrypt and PBKDF2 (slow, built for passwords) and the obsolete LM hash. OWASP's current Password Storage Cheat Sheet ranks Argon2id first for new systems, then scrypt, bcrypt and PBKDF2 with HMAC-SHA-256 where FIPS compliance is required.

Rainbow table attack

A rainbow table is a precomputed lookup that maps hash values back to likely passwords. Instead of storing every hash, it stores compressed chains of hashes and rebuilds the match, which trades some computing time for much less storage. If an attacker steals a database of unsalted MD5 or NTLM hashes, a rainbow table can reverse many of them quickly.

Defense: salt every password with a unique random value before hashing. A salt makes a table built for one hash useless for the rest, so an attacker must start again for every user. OWASP states that salts defeat precomputed lookup tables and stop an attacker from cracking many hashes in one pass. Use a slow password hash such as Argon2id or bcrypt, which adds a salt automatically.

Pass the hash attack

In a pass-the-hash attack the attacker does not crack anything. MITRE describes it as authenticating as a user without access to the cleartext password, using a stolen password hash. In Windows networks the NTLM hash is enough to prove identity to other machines, so one stolen hash lets an attacker move sideways from computer to computer.

Defense:

  • Stop the theft. Limit local administrator rights and restrict who can log on to which machines, so a hash is never cached on a workstation that does not need it. Tiered administration keeps privileged hashes off ordinary PCs.
  • Turn on Credential Guard where hardware supports it. It isolates secrets in a protected part of the operating system.
  • Give each machine a unique local administrator password, for example with Windows LAPS, so one cracked local admin does not open the whole fleet.
  • Restrict and monitor NTLM, and prefer Kerberos.
  • Patch and use multi-factor authentication to shrink what a stolen credential can reach.

Our guide on how to prevent pass-the-hash attacks goes through these controls in detail.

Brute force and dictionary attacks

With a stolen hash file, attackers guess offline: a brute force attack tries every combination, a dictionary attack tries known words and passwords, and rule-based attacks mutate those words (Password1!). Offline guessing needs no rate limit and no lockouts, only hardware. Fast hashes like MD5, SHA-1 and NTLM let a graphics card test billions of guesses a second.

Defense: store passwords with a slow, salted hash so every guess costs real time, require long passphrases, and check new passwords against known breached lists. See password best practices and credential stuffing prevention.

Hash collision attack

A collision is two different inputs with the same hash. If an attacker can create one on demand, they can swap a harmless file or certificate for a malicious one that carries the same hash, so a signature or checksum still verifies. Collisions are practical for MD5 and SHA-1, which is why both were removed from certificates and signatures. A collision attack is not the same as cracking a password hash. The risk is to signing and integrity.

Defense: use SHA-256 or stronger for signatures and integrity checks, and reject certificates and software signed only with MD5 or SHA-1.

Hash DoS attack

A hash DoS (HashDoS) attack does not target passwords. Programs store data like web form fields in hash tables. If an attacker knows the hash function, they can send many keys that land in the same slot, which turns fast lookups into slow ones and ties up the CPU. A small request can cost a server a lot of time.

Defense: use hash tables with a random per-process seed or a keyed hash such as SipHash (several language runtimes now randomize hashing), cap the number of request parameters and body size, and keep frameworks patched.

Defenses that cover all of them

  • Salt and slow-hash every stored password. Prefer Argon2id. Use bcrypt or PBKDF2 where that is what your system supports.
  • Move off MD5, SHA-1 and unsalted NTLM wherever you control the system. If you cannot, force a password reset so hashes are regenerated with a stronger algorithm.
  • Add MFA so a cracked or stolen password is not enough.
  • Protect credentials on endpoints: Credential Guard, unique local admin passwords and least privilege.
  • Monitor for odd logons, especially one account appearing on many machines in a short time.

For the wider picture, see preventing remote code execution attacks and what endpoint security is.

Ready-to-use Templates

Must-have Template Toolkit for IT Admins

Explore All
Template Toolkit

Start your free trial

No credit card required
Full access to all features

Get Ahead of the Curve

Every organization today needs a solution to automate time-consuming tasks and strengthen security. Without the right tools, manual processes drain resources and leave gaps in protection. trio.so is designed to solve this problem, automating key tasks, boosting security, and ensuring compliance with ease.

Don't let inefficiencies hold you back.

Every organization today needs a solution to automate time-consuming tasks and strengthen security. Without the right tools, manual processes drain resources and leave gaps in protection. trio.so is designed to solve this problem, automating key tasks, boosting security, and ensuring compliance with ease.

Smiling womanAbstract geometric patternAbstract geometric patternSmiling womanSmiling woman

Frequently Asked Questions (FAQ)

Have questions? We've got answers. This section covers some of the most commonly asked questions related to this topic.

There are dozens of hash functions. The ones IT teams meet most are MD5, SHA-1, SHA-256 and the other SHA-2 hashes, NTLM, and password hashes such as bcrypt and Argon2.

Start with length and format. 32 hexadecimal characters is usually MD5 or NTLM, 40 is SHA-1, 64 is SHA-256, and a $2a$, $2b$ or $2y$ prefix is bcrypt. Length is a clue, not proof, so check where the hash came from.

It reverses password hashes with a precomputed lookup table of hashes and the passwords behind them. Unique salts make rainbow tables useless.

The attacker uses a stolen password hash, typically an NTLM hash, to log in as the user without cracking it. Credential Guard, unique local admin passwords and limiting admin logons reduce the risk.

It sends input crafted so many keys collide in a program's hash table, which makes each lookup slow and exhausts the CPU. Randomized or keyed hashing and request limits prevent it.

Related

From the blog

The related industry news, interviews, technologies, and resources.