Skip to main content
Authentication, Passwords, and Multi-Factor Security
Lesson 5 of 6

Authentication, Passwords, and Multi-Factor Security

Learn how attackers crack or replay passwords, how to apply modern NIST SP 800-63B password guidance, how to store credentials with salted key derivation functions, and how MFA and passkeys protect accounts.

Beginner 25 min Fundamentals

Learning objectives

  • Explain how brute-force, dictionary, rule-based, rainbow table, and credential stuffing attacks compromise accounts
  • Apply modern NIST SP 800-63B guidelines that prioritize length, passphrases, and breached-password screening over arbitrary complexity or periodic rotation
  • Implement salted password hashing with slow key derivation functions such as Argon2id, scrypt, or bcrypt and verify logins safely
  • Evaluate multi-factor authentication methods from phishing-resistant passkeys and hardware keys down to SMS one-time codes

Recommended first: The CIA Triad: Confidentiality, Integrity, Availability

#Why this matters

Passwords still guard email, university portals, cloud consoles, and banking apps. When an attacker guesses a weak password, replays a leaked credential from another site, or cracks a stolen database dump, confidentiality and integrity fail immediately. Strong authentication is therefore one of the highest-impact controls in cybersecurity.

#How password attacks work

Attackers target passwords online (sending logins to a live server) or offline (cracking stolen hashes locally):

  • Brute force: Testing every character combination systematically. Short passwords fall quickly offline on modern GPUs.
  • Dictionary attack: Testing common words and leaked passwords from past breaches instead of random strings.
  • Rule-based attack: Mutating dictionary words with predictable habits, such as capitalizing letters, adding years, or swapping symbols (password to P@ssw0rd1).
  • Rainbow table: Looking up unsalted hashes in a precomputed table of password-hash pairs. Unique per-user salts render rainbow tables useless.
  • Credential stuffing: Replaying leaked login pairs from one breached site against other services where users reused the same password.
  1. Breach or leakAttacker obtains a password dump or leaked login list
  2. Cracking or replayFast hashes are cracked on GPUs or reused logins are replayed online
  3. Account takeoverAttacker signs in as the victim without exploiting software bugs
  4. Lateral impactEmail or admin access unlocks password resets across other services

#Modern password guidance (NIST SP 800-63B)

Older policies forced short passwords with mixed character classes and mandatory 60- or 90-day rotation. Both rules backfire: users choose predictable patterns (Summer2026!) and increment a digit at each forced reset.

Current NIST SP 800-63B and OWASP guidance replaces those habits:

  • Length over arbitrary complexity: A passphrase of four or more random unrelated words (timber-lantern-canyon-velvet) or a 16-character password generated by a password manager resists guessing far better than a short complex string.
  • No forced periodic rotation: Never require calendar-based password expiry. Require a reset only when compromise is suspected or confirmed.
  • Breached-password screening: Reject passwords found in known breach lists, common dictionaries, or context-specific strings like the username.
  • Password manager support: Allow at least 64 characters and never block pasting. Tools such as KeePassXC or Bitwarden store unique passwords for every site behind one strong master passphrase (kept with a secure offline backup).
Strategy Guess resistance Memorability Recommended use
Short or reused (admin123) Very low High Never use
Short complex (P@ssw0rd!) Low against rules Low Avoid
Random passphrase (4-5 words) High High Master passwords and device logins
Random 16+ chars (manager) Very high Vault-managed Every individual web account

#Storing passwords safely: salts and slow KDFs

Never store passwords in plaintext or reversible encryption (such as 3DES or AES). Fast cryptographic hashes like MD5, SHA-1, and plain SHA-256 are also unsafe: GPUs compute tens of billions of guesses per second, and without a salt, identical passwords produce identical digests.

Safe storage combines two controls:

  1. Per-user salt: Generate a unique random salt for every account and store it alongside the hash so identical passwords produce different digests and rainbow tables fail.
  2. Slow Key Derivation Function (KDF): Use Argon2id first; scrypt, bcrypt, or high-iteration PBKDF2 (for strict standards compliance) are valid alternatives.
Fast Hashes vs Password KDFs
Fast Hashes (MD5, SHA-1, SHA-256)
  • Built for high-speed integrity checks
  • No built-in per-user salt
  • GPUs test billions of guesses per second
  • Unsafe for storing user passwords
Password KDFs (Argon2id, scrypt, bcrypt)
  • Intentionally slow and resource-intensive
  • Automatic or mandatory unique random salt
  • Memory and CPU cost severely limits GPU cracking
  • Recommended by OWASP and NIST SP 800-63B

Python's standard library hashlib.scrypt demonstrates salted KDF hashing and constant-time verification with hmac.compare_digest:

python
import hashlib, hmac, secrets

def hash_password(password: str) -> tuple[bytes, bytes]:
    salt = secrets.token_bytes(16)
    digest = hashlib.scrypt(password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32)
    return salt, digest

def verify_password(candidate: str, salt: bytes, stored: bytes) -> bool:
    check = hashlib.scrypt(candidate.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32)
    return hmac.compare_digest(check, stored)

salt, stored = hash_password("timber-lantern-canyon-velvet")
print("Valid:", verify_password("timber-lantern-canyon-velvet", salt, stored))

In PHP, the built-in API manages Argon2id parameters, random salts, and constant-time checks automatically:

php
$hash = password_hash($password, PASSWORD_ARGON2ID);
if (password_verify($input, $hash)) {
    // Authenticated on lab.local
}

#Multi-Factor Authentication (MFA) and passkeys

Because passwords can be phished or stolen, MFA adds an independent second factor. Strength varies by method:

  • Passkeys and hardware security keys (FIDO2 / WebAuthn): Strongest. Cryptographic checks bind to the exact site domain, blocking phishing pages.
  • Authenticator apps (TOTP): Strong and widely supported. Time-based codes are generated locally without mobile networks.
  • Push notifications: Convenient, though vulnerable to "MFA fatigue" unless number matching is enabled.
  • SMS and email OTP: Weakest tier. SMS codes are vulnerable to SIM swapping, where an attacker hijacks the victim's phone number to intercept messages.

#Defending / Common mistakes

  • Using MD5, SHA-1, or plain SHA-256: Migrate to Argon2id, scrypt, or bcrypt on each user's next login.
  • Missing or shared salts: Always generate a unique random salt per user.
  • Forced 90-day rotation and rigid symbol rules: Follow NIST SP 800-63B -- favor length, block breached passwords, and rotate only on compromise.
  • Using SMS OTP for critical accounts: Upgrade to passkeys, hardware keys, or TOTP apps.
  • No login throttling: Combine rate limiting, progressive delays, and CAPTCHA against credential stuffing.
  • Plain == hash comparison: Use password_verify() or hmac.compare_digest() to prevent timing leaks.

#Summary

Password security requires defense in depth across users and servers. NIST SP 800-63B prioritizes long passphrases, password managers, breached-password screening, and no forced periodic rotation. Servers must protect credentials with unique salts and slow KDFs like Argon2id, verified in constant time, while MFA with passkeys, hardware keys, or TOTP blocks takeovers even when passwords leak.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge