Skip to content

Instantly share code, notes, and snippets.

@tjunghans
Last active September 6, 2021 19:57
Show Gist options
  • Save tjunghans/32327bb4c0a0a9b0faf380849f192346 to your computer and use it in GitHub Desktop.
Save tjunghans/32327bb4c0a0a9b0faf380849f192346 to your computer and use it in GitHub Desktop.
Summary Notes on "Implementing Secure User Authentication in PHP Applications with Long-Term Persistence"

Summary Notes on "Implementing Secure User Authentication in PHP Applications with Long-Term Persistence"

Source

  • Secure Authentication is hard

Secure Password Storage in 2015

Passwords: Hashes, Salts, and Policies

  • MD5 and SHA1 are not secure password hashing algorithms due to collisions. A collision is when to different strings result in the same hash.
  • Argon2, bcrypt, scrypt and PBKDF2 are acceptable hashing algorithms
  • bcrypt > PBKDF2
  • Use existing password_hash() and password_verify() API instead of writing their own crypt()-based implementation
  • Use pashword_hash() instead of generating an own salt
  • bcrypt has limitations in that it truncates to 72
  • Use SHA-384 instead of SHA-256
  • Peppers do not add any meaningful security above and beyond the salt that password_hash() generates for you
  • Try to employ hardware separation, ideally different adminst have access
  • Instead of pepper, encrypt hashes before inserting into DB

Password Policies

  • asking for min length is ok
  • enforcing a maximum password length is NOT ok
  • asking for specific characters is NOT ok
  • use Dropbox's zxcvbn library to provide feedback to users about the strength of their passwords

Reasonable Password Policy Example

  • Passwords must be at between 12 and 4,096 characters in length.
  • Passwords can contain any characters (including Unicode).
  • We strongly encourage the use of a password manager like KeePass or KeePassX to generate and store your passwords.
  • Your zxcvbn password strength must be at least level 3 (on the 0-4 scale).

Persistent Authentication ("Remember Me" Checkboxes with Long-Term Cookies) Done Right

Account Recovery ("Forgot Your Password?")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment