OWASP Top 10 Security Lab

A07

Identification and Authentication Failures

Exploit authentication and session management vulnerabilities

What are Identification and Authentication Failures?

Authentication and session management functions are often implemented incorrectly, allowing attackers to compromise passwords, keys, session tokens, or exploit other implementation flaws to assume other users' identities temporarily or permanently.

🎯 Common Authentication Vulnerabilities

  • Weak Credentials: Default, weak, or well-known passwords
  • Credential Stuffing: Automated attacks using known username/password pairs
  • Brute Force: Systematic password guessing without proper rate limiting
  • Authentication Bypass: Logical flaws allowing access without valid credentials
  • Weak Password Recovery: Knowledge-based authentication and insecure reset mechanisms
  • Session Management: Predictable session IDs, fixation, and hijacking vulnerabilities
  • Multi-Factor Bypass: Flaws in 2FA/MFA implementation and validation

⚠️ Attack Impact

  • Complete account takeover and identity theft
  • Unauthorized access to sensitive data and systems
  • Privilege escalation through compromised admin accounts
  • Financial fraud and unauthorized transactions
  • Data exfiltration and privacy violations
  • Reputation damage and legal liability

🔍 Common Attack Techniques

# Credential Stuffing Attack usernames = ["admin", "user", "test", "guest"] passwords = ["password", "123456", "admin", "password123"] for user in usernames: for pwd in passwords: response = login(user, pwd) if "success" in response: print(f"SUCCESS: {user}:{pwd}") # SQL Injection Authentication Bypass username = "admin' OR '1'='1' --" password = "anything" # Results in: SELECT * FROM users WHERE username='admin' OR '1'='1' --' AND password='anything' # Session Fixation Attack 1. Attacker obtains valid session ID: JSESSIONID=ABC123 2. Victim is tricked into using this session ID 3. Victim authenticates normally 4. Attacker uses same session ID to access victim's account # Brute Force with Rate Limit Bypass # Technique: IP rotation and distributed attacks proxies = ["1.1.1.1", "2.2.2.2", "3.3.3.3"] for proxy in proxies: for password in wordlist: attack_with_proxy(proxy, username, password)

🛡️ Secure Authentication Design

  • Strong Password Policies: Length, complexity, and regular rotation requirements
  • Multi-Factor Authentication: Something you know, have, and are
  • Account Lockout: Rate limiting and progressive delays
  • Secure Session Management: Cryptographically random session IDs
  • Password Storage: Proper hashing with salt (bcrypt, Argon2)
  • Monitoring and Logging: Failed login attempts and anomaly detection
// Secure Authentication Implementation class SecureAuth { // Strong password hashing hashPassword(password) { return bcrypt.hash(password, 12); // High cost factor } // Rate limiting checkRateLimit(ip, username) { const attempts = getFailedAttempts(ip, username); if (attempts > 5) { throw new Error("Account temporarily locked"); } } // Secure session management generateSession() { return crypto.randomBytes(32).toString('hex'); } // Input validation validateCredentials(username, password) { if (!username || !password) return false; if (containsSQLChars(username)) return false; return true; } } // Multi-Factor Authentication class MFA { generateTOTP(secret) { return speakeasy.totp({ secret: secret, encoding: 'base32', window: 1 }); } }

🎯 Lab Preview

In the following labs, you'll explore authentication and session vulnerabilities:

  • Lab 1: Authentication bypass techniques - weak credentials, brute force, logic flaws, MFA bypass
  • Lab 2: Session management attacks - fixation, hijacking, predictable tokens, JWT manipulation