Authentication Vulnerabilities Overview
Authentication Vulnerabilities Overview
Weak Password Policies
Weak Password Policies
- Require a minimum length (at least 12 characters)
- Require a mix of character types (uppercase, lowercase, numbers, special characters)
- Check passwords against lists of commonly used or compromised passwords
- Encourage the use of passphrases
- Consider implementing password strength meters
Plaintext Password Storage
Plaintext Password Storage
- Never store passwords in plaintext
- Use strong, slow hashing algorithms designed for password storage (bcrypt, Argon2, PBKDF2)
- Use a unique salt for each password
- Implement key stretching with an appropriate work factor
- Regularly update hashing algorithms as stronger ones become available
Insecure Authentication Protocols
Insecure Authentication Protocols
- Always use HTTPS for transmitting credentials
- Prefer token-based authentication (JWT, OAuth) over basic authentication
- Implement proper token validation and expiration
- Use secure cookie attributes (HttpOnly, Secure, SameSite)
- Consider implementing multi-factor authentication
Insufficient Brute Force Protection
Insufficient Brute Force Protection
- Implement rate limiting on authentication endpoints
- Use progressive delays between login attempts
- Implement temporary account lockouts after multiple failed attempts
- Consider using CAPTCHA for suspicious login attempts
- Log and alert on unusual authentication patterns
Insecure Password Recovery
Insecure Password Recovery
- Use cryptographically secure tokens with sufficient entropy
- Set short expiration times for reset tokens
- Implement one-time use tokens
- Verify the user’s identity through multiple factors when possible
- Don’t reveal whether an email exists in the system
- Log and notify users about password reset attempts
Session Fixation
Session Fixation
- Generate a new session identifier after authentication
- Invalidate the old session when a user logs in
- Use secure, HttpOnly, and SameSite cookies for session management
- Implement proper session timeout and expiration
- Validate the session against stored user information
Insecure Credential Transmission
Insecure Credential Transmission
- Always use HTTPS for all authentication-related traffic
- Implement HTTP Strict Transport Security (HSTS)
- Use secure cookies with the Secure flag
- Avoid transmitting credentials in URLs
- Consider using client-side hashing before transmission (though not as a replacement for HTTPS)
Missing Multi-Factor Authentication
Missing Multi-Factor Authentication
- Offer multiple types of second factors (TOTP, SMS, email, push notifications, hardware keys)
- Implement secure enrollment and recovery processes
- Allow users to manage their MFA settings
- Provide backup methods for account recovery
- Consider risk-based authentication for sensitive operations
Insecure OAuth Implementation
Insecure OAuth Implementation
- Always use the state parameter to prevent CSRF attacks
- Validate redirect URIs
- Use PKCE (Proof Key for Code Exchange) for public clients
- Securely store client secrets
- Validate tokens properly
- Implement proper scope handling
Hardcoded Credentials
Hardcoded Credentials
- Use environment variables for sensitive configuration
- Implement a secure configuration management system
- Use secrets management services
- Implement proper access controls for configuration files
- Regularly rotate credentials
Insufficient Logging and Monitoring
Insufficient Logging and Monitoring
- Log all authentication events (successful and failed)
- Include relevant context (IP, user agent, timestamp)
- Implement centralized log collection and analysis
- Set up alerts for suspicious authentication patterns
- Ensure logs are tamper-resistant
- Retain logs for an appropriate period
Default or Weak Credentials
Default or Weak Credentials
- Never ship software with default credentials
- Require users to set strong passwords during initial setup
- Implement password strength validation
- Regularly audit for weak credentials
- Consider implementing credential rotation policies
Insecure Remember Me Functionality
Insecure Remember Me Functionality
- Use cryptographically secure tokens
- Store only token hashes in the database
- Implement proper token expiration
- Use secure, HttpOnly, and SameSite cookies
- Provide users with the ability to view and revoke persistent sessions
- Automatically invalidate tokens when users change passwords
Insecure Account Recovery Questions
Insecure Account Recovery Questions
- Avoid common security questions with easily discoverable answers
- Allow users to create their own questions
- Store answers as hashed values, not plaintext
- Consider alternative recovery methods (email, phone, backup codes)
- Implement multi-step recovery processes
- Rate-limit recovery attempts
Missing Account Lockout
Missing Account Lockout
- Lock accounts after a specified number of failed login attempts
- Implement temporary lockouts with increasing durations
- Provide alternative recovery methods for legitimate users
- Log and alert on account lockouts
- Consider implementing progressive security measures instead of hard lockouts
- Use CAPTCHA or other verification methods after a few failed attempts