Credential Stuffing: The Automation of Password Reuse
Credential Stuffing: Why Password Reuse Makes Scale the Attacker's Friend
Credential stuffing is an attack where an attacker uses automated tools to replay username and password pairs leaked from one service against many other services. The attack exploits a simple reality: users reuse passwords across multiple sites. When one service is breached, the leaked credentials work everywhere the user has reused their password.
The Economics of Credential Stuffing
The attacker's cost:
- Leaked credential lists are freely available on the dark web (collections like Compilation of Many Breaches contain billions of pairs)
- Automated tools (OpenBullet, Sentry MBA, STORM) cost nothing or very little
- Botnets of thousands of IP addresses are available for rent
- The cost per login attempt is fractions of a cent
The attacker's success rate:
- Industry estimates suggest 0.1-2% of attempts succeed
- With 10 million credential pairs, even 0.1% success = 10,000 compromised accounts
- Each compromised account can be monetized (fraud, resale, data theft)
The defender's challenge:
- Legitimate users and attackers look identical at the login endpoint
- Each IP makes only a few requests (distributed across thousands of IPs)
- Rate limiting per IP is ineffective
How Credential Stuffing Attacks Work
Attack infrastructure:
- Credential lists: Username/email and password pairs from data breaches
- Proxy rotation: Thousands of residential IP addresses to avoid rate limits
- Browser automation: Headless browsers (Puppeteer, Selenium) that execute JavaScript and mimic human behavior
- CAPTCHA solving: Services that solve CAPTCHAs for a fee (or ML-based solvers)
Attack flow:
- Attacker loads a list of credential pairs
- For each pair, the tool sends a login request from a different IP address
- The tool mimics human behavior (random delays, mouse movements, realistic headers)
- Successful logins are collected and monetized
Multi-Layered Credential Stuffing Defense
Defending Against Credential Stuffing with Multiple Layers
No single defense stops credential stuffing. A comprehensive strategy combines multiple layers, each addressing a different aspect of the attack.
Layer 1: Breach Password Detection
Prevent users from setting passwords that have been exposed in known data breaches:
import hashlib
import requests
def is_pwned_password(password):
sha1 = hashlib.sha1(password.encode('utf-8')).hexdigest().upper()
prefix, suffix = sha1[:5], sha1[5:]
response = requests.get(
f'https://api.pwnedpasswords.com/range/{prefix}',
headers={'Add-Padding': 'true'}
)
for line in response.text.splitlines():
hash_suffix, count = line.split(':')
if hash_suffix == suffix:
return True, int(count)
return False, 0
Key features:
- k-anonymity: Only the first 5 characters of the SHA-1 hash are sent to the API
- Privacy: The full password is never transmitted
- User experience: Inform users why their password was rejected without revealing the specific breach
Layer 2: Multi-Factor Authentication (MFA)
MFA is the single most effective defense against credential stuffing. Even if the attacker has the correct username and password, they cannot complete login without the second factor.
Layer 3: Bot Detection and Device Fingerprinting
- Require JavaScript execution before accepting login requests
- Analyze behavioral signals (mouse movements, keystroke dynamics, timing)
- Use device fingerprinting to identify suspicious patterns
- Assign risk scores and apply step-up authentication for high-risk attempts
Layer 4: Rate Limiting and Monitoring
- Implement per-account rate limiting (across all IPs, not per-IP)
- Monitor for credential stuffing patterns (many accounts, few attempts each)
- Alert on anomalous login patterns (unusual geographic distribution, timing)
- Implement CAPTCHA after a threshold of failed attempts
Practice Problems
Design a multi-layered defense against credential stuffing for a web application with 1 million users. Consider both technical controls and user experience.
Optimal Solution — time, space
Combine breach password detection at registration, MFA for all users, device fingerprinting, per-account rate limiting across all IPs, and behavioral analysis. Use CAPTCHA as a progressive challenge, not a blanket requirement.
# Rate limiting pseudocode
if failed_attempts_for_account > 5:
require_captcha()
if failed_attempts_for_account > 10:
require_mfa()
if failed_attempts_for_account > 20:
lock_account()
notify_user() Edge Cases:
- Users without MFA enrolled
- Legacy clients that cannot execute JavaScript
- Shared IP addresses (corporate NAT)
Quiz
1. What is the key difference between credential stuffing and brute force attacks?
2. Why is per-IP rate limiting ineffective against credential stuffing?
3. What is the most effective single defense against credential stuffing?
Flashcards
Question
What is credential stuffing?
Click to reveal answer
Answer
An attack that uses automated tools to replay username/password pairs from data breaches against other services, exploiting password reuse.
Question
Why does credential stuffing work?
Click to reveal answer
Answer
Users reuse passwords across multiple sites. When one service is breached, the leaked credentials work everywhere the user has reused their password.
Question
What is k-anonymity in breach password detection?
Click to reveal answer
Answer
Only the first 5 characters of the password hash are sent to the API, so the full password is never transmitted.
Question
Why is per-IP rate limiting ineffective against credential stuffing?
Click to reveal answer
Answer
Attackers distribute attempts across thousands of residential IP addresses via proxy rotation.
Revision Notes
Key Takeaways
- 1. Credential stuffing exploits password reuse across sites
- 2. MFA is the most effective defense against credential stuffing
- 3. Per-IP rate limiting fails because attackers use distributed IPs
- 4. Breach password detection prevents use of compromised credentials
- 5. Layer multiple defenses for comprehensive protection
Interview Tips
- • Explain the difference between credential stuffing and brute force
- • Describe how you would detect and block credential stuffing in real time
- • Discuss the trade-offs between security and user experience in anti-bot measures
Cheat Sheet
Credential Stuffing Defenses Cheat Sheet
Phase: Password Storage and Session Security | Level: intermediate
Key points:
- Credential stuffing uses real leaked credentials from data breaches
- Per-IP rate limiting is ineffective (attackers use proxy rotation)
- MFA is the most effective single defense
- Breach password detection prevents users from using compromised credentials
- Defense in depth: breach detection + MFA + bot detection + rate limiting + monitoring
Tags: authentication, credential-stuffing, rate-limiting