Dictionary Attacks and Recovery Exploits
CWE-307, CWE-521, CWE-640, CWE-1391, CWE-294
Real-World Attack Scenarios
Scenario 1: Brute Force - No Rate Limiting
Login endpoint with no rate limit:
@app.route('/login', methods=['POST'])
def login():
username = request.form['username']
password = request.form['password']
# NO rate limiting!
user = User.query.filter_by(username=username).first()
if user and verify_password(password, user.password):
session['user_id'] = user.id
return redirect('/dashboard')
return "Invalid credentials", 401The attack:
Attacker uses dictionary/wordlist to brute force:
Speed: 100+ attempts per second, no delays Result: Passwords cracked in hours to days
Finding it: Attempt multiple failed logins. Check for rate limiting, account lockout, or delays.
Scenario 2: Weak Password Policy
System allows weak passwords:
The attack:
Result:
Mass account compromise
Easy password guessing
Finding it: Try weak passwords. Check password requirements. Test for patterns.
Scenario 3: Weak Password Recovery
Password reset using predictable or insecure method:
The attack:
Attacker:
Knows user_id (public information)
Current date is known
Calculates reset token:
md5(123_2024-01-15)Uses token to reset password
Takes over account
Result:
Mass account takeover
Complete system compromise
Finding it: Request password reset. Analyze token format. Try predictable tokens.
Scenario 4: Credential Replay Attack
Attacker captures credentials and replays them:
The attack:
Result:
Account access using replayed credentials
Long-term compromise if password never changes
Finding it: Capture login request. Replay it later. Check if credentials still work.
Mitigation Strategies
Implement rate limiting
Implement account lockout
Enforce strong password policy
Implement secure password reset
Prevent replay attacks
Use nonce and timestamp:
Last updated