Interactive Playground
Experiment with the vulnerable code and security rule below. Edit the code to see how the rule detects different vulnerability patterns.
pathfinder scan --ruleset golang/GO-CRYPTO-005 --project .About This Rule
Understanding the vulnerability and how it is detected
Using MD5 to hash passwords is a critical vulnerability. Password hashing requires an intentionally slow, memory-hard function — MD5 is the opposite: it is designed for speed and runs at **164.1 billion hashes per second** on a single NVIDIA RTX 4090 GPU (hashcat v6.2.6 benchmark).
**Cracking speed in context**: - "8-char lowercase alphanumeric (36^8 ≈ 2.8 trillion): exhausted in ~17 seconds." - "8-char mixed-case + digits (62^8 ≈ 218 trillion): exhausted in ~22 minutes." - "bcrypt cost-10 on the same RTX 4090: ~184,000 hashes/second — ~892,000x slower." - "argon2id: ~1,000–10,000 hashes/second — ~16,000,000x slower than MD5."
**Why salted SHA-256 is also insufficient**: Adding a salt stops rainbow table attacks but does not slow the attacker on GPUs. Salted SHA-256 is still computed at billions of hashes per second. bcrypt's work factor and argon2id's memory hardness are specifically designed to keep per-hash computation time at 100ms–1s even on dedicated hardware, making bulk cracking economically infeasible.
**Real breach consequences**: The "rockyou.txt" password list (32 million entries from the 2009 RockYou breach, which stored passwords in plaintext) became the most widely used cracking wordlist in all password cracking tools — demonstrating how breached data permanently enables future attacks against other services where users reuse credentials.
**Detection**: This rule detects MD5 hash output flowing into password-named functions (storePassword, checkPassword, savePassword, hashPassword, etc.), indicating password storage using MD5.
Security Implications
Potential attack scenarios if this vulnerability is exploited
Instant Password Cracking After Database Breach
An attacker who exfiltrates a database of MD5-hashed passwords can crack the vast majority in hours using a single consumer GPU. Studies of breached password datasets consistently show 90–99% crack rates for MD5 hashes within 24–72 hours when dictionary + rule-based attacks are applied.
Credential Stuffing at Scale
Cracked passwords from one service are used to attack other services where users reuse credentials. A single breached MD5 database provides the attacker with a tested password list for attacks against email, banking, and other accounts.
Rainbow Table Vulnerability
Unsalted MD5 password hashes are directly reversible using pre-computed rainbow tables freely available online. Common passwords are recovered in milliseconds without any cracking computation.
How to Fix
Recommended remediation steps
- 1Replace all MD5 password hashing with bcrypt (golang.org/x/crypto/bcrypt, cost >= 12).
- 2For new systems, prefer argon2id (golang.org/x/crypto/argon2) — PHC winner, memory-hard.
- 3For migration: at next successful login, re-hash the password with bcrypt/argon2id.
- 4Never use any fast hash (MD5, SHA-1, SHA-256) directly for password storage — even salted.
- 5bcrypt has a 72-byte input limit — enforce this or pre-hash input before passing to bcrypt.
- 6Use constant-time comparison (bcrypt.CompareHashAndPassword) to prevent timing attacks.
Detection Scope
How Code Pathfinder analyzes your code for this vulnerability
Detects MD5 hash output (md5.Sum() return value) flowing into functions with password-related names (storePassword, savePassword, checkPassword, hashPassword, etc.). This indicates password storage using MD5.
Compliance & Standards
Industry frameworks and regulations that require detection of this vulnerability
References
External resources and documentation
Similar Rules
Explore related security rules for Go
Use of MD5 Weak Hash Algorithm
Detects use of MD5 (crypto/md5) which is cryptographically broken — collision attacks are feasible in seconds and GPU cracking reaches 164 billion hashes/second.
Use of SHA1 Weak Hash Algorithm
Detects use of SHA1 (crypto/sha1) which has a proven collision (SHAttered, 2017) and is deprecated by NIST for all applications through 2030.
Frequently Asked Questions
Common questions about MD5 Used for Password Hashing
New feature
Get these findings posted directly on your GitHub pull requests
The MD5 Used for Password Hashing rule runs in CI and posts inline review comments on the exact lines — no dashboard, no SARIF viewer.