DML School of Technology
Menu

Open to everyone Reading, lesson 56 of 100, 2 min read

Sign-in and session flaws

Getting sign-in right

Sign-in and sessions are where attackers aim first. Common mistakes, and their fixes:

MistakeFix
No limit on guessesRate limiting and temporary lockouts per account and per address
Different messages for "no such user" and "wrong password"One generic message, so attackers cannot list valid accounts
Weak passwords allowedMinimum length (at least 12 is common), block known breached and common passwords
Passwords stored badlySalted, slow hashes (Argon2, bcrypt)
No MFA optionOffer it to everyone; require it for admins
Session ID in the URLKeep it in a secure cookie only
Session not renewed at sign-inIssue a new session ID when the user signs in (prevents session fixation)
Sessions never expireIdle and absolute time-outs
Sign-out does nothing on the serverDestroy the session on the server, not just the cookie
Password reset links that never expire or can be guessedLong random single-use tokens, valid for a short time, stored hashed

Password reset is a sign-in door too

Attackers love weak reset flows. A good one:

  1. Always says "if that email has an account, we sent a link", whether or not it exists.
  2. Sends a single-use link that expires in under an hour.
  3. Ends all other sessions after the password changes.
  4. Notifies the user that the password was changed.

Changing important details

When a user changes their email, password or bank details, ask for the current password (or MFA) again, and notify the old email address. This stops a stolen session from quietly taking over an account.

APIs

Mobile apps and other systems use APIs. They need the same care: authentication on every call, authorisation for each object, rate limits, and API keys treated as passwords (shown once, stored hashed, revocable).

Tip

As a user, the "sign out of all other sessions" button is worth knowing. Use it after signing in on a shared computer.