Course contentsShow
← Software Engineering
Lesson 1006 of 1,93331. Authentication and AuthorizationFree lesson

Credential Stuffing and Breach Detection

Protecting against credential reuse attacks by checking passwords against known breach databases like Have I Been Pwned.

Credential Stuffing and Breach Detection

What you'll learn: How to protect your users by checking if their passwords have appeared in known data breaches.

The Problem

Even if you hash passwords perfectly with Argon2 and strong salts, there's a vulnerability you can't control: users reusing passwords across sites. When another service gets breached and leaks millions of username/password combinations, attackers use those credentials to log into other services—a technique called credential stuffing.

Think of it like this: if someone discovers your house key works on your neighbor's door because they're identical, suddenly both homes are at risk.

Checking Against Known Breaches

Services like Have I Been Pwned (HIBP) maintain databases of billions of passwords from known breaches. When a user creates or changes their password, you can check if it appears in these databases.

The genius of HIBP's API: you never send the full password. You hash it with SHA-1, send only the first 5 characters of the hash, and receive back all matching hash suffixes. Your application checks locally if the full hash matches. This preserves privacy while protecting users.

Why This Matters

A user might choose a "strong" password like P@ssw0rd123! that meets all your complexity rules—but if it appeared in a breach, it's compromised. Blocking known-breached passwords dramatically reduces account takeover risk.

This complements—never replaces—proper hashing. You still use Argon2 with salts. Breach detection is an additional layer that says "even if this password is strong, we know attackers have it."

Key Takeaway: Credential stuffing exploits password reuse across sites; checking passwords against breach databases like Have I Been Pwned during registration and password changes provides critical defense against attackers using stolen credentials from other services.