Authentication Cheat Sheet
- 1 Introduction
- 2 Authentication General Guidelines
- 2.1 Implement Proper Password Strength Controls
- 2.2 Implement Secure Password Recovery Mechanism
- 2.3 Utilize Multi-Factor Authentication
- 2.4 Authentication and Error Messages
- 2.5 Transmit Passwords Only Over TLS
- 2.6 Implement Account Lockout
- 3 Session Management General Guidelines
- 4 References
- 5 Authors and Primary Editors
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsiquent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when mtransmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.
For more information on Authentication, please see the OWASP Guide to Authentication page.
Authentication General Guidelines
Implement Proper Password Strength Controls
A key concern when using passwords for authentication is password strength. A "strong" password policy makes it difficult or even improbable for one to guess the password either by using manual or automated means. The following characteristics define strong a strong password:
The longer the password the more combinations possible combinations of characters exist and is hence more difficult to guess.
Important applications: Minimum of 6 characters in length.
Critical applications: Minimum of 8 characters in length. (consider multi-factor authentication)
Highly critical applications: Consider multi-factor authentication
2. Password complexity
Passwords should be checked for the following composition or a variance of such:
- at least: 1 uppercase character (A-Z)
- at least: 1 lowercase character (a-z)
- at least: 1 digit (0-9)
- at least one special character (!"£$%&...)
- a defined minimum length (e.g. 8 chars)
- a defined maximum length (as with all external input)
- no contiguous characters (e.g. 123abcd)
- not more than 2 identical characters in a row (1111)
Implement Secure Password Recovery Mechanism
It is common for an application to have a mechanism that provides a means for a user to gain access to their account in the event they forget their password. Password recovery systems are difficult to secure against abuse, circumvention. The best way is to keep them as simple as possible.
Weaknesses with sectet questions are common;
Weakness may be that the security question is too easy to guess or find an answer to E.g. Car, Date of Birth (DOB), Colour Such question have a a finite sample space and are easily brute forced/guessed.
Delivery Mechanisims / Implementation weakness
Common issues with a reset password delivery are
Email: Setting the email address to that which is not the email address of the user for which the password is to be reset.
- Password Reset Rate
Limiting the rate at which password reset requests are processed in order to limit hijacking and brute force attempts.
- Authentication: Password recovery mechanism relies only on something the user knows and not something the user has; email account, token, multifactor.
Utilize Multi-Factor Authentication
Multifactor factor authentication is using more than one of:
- Something you know (account details or passwords)
- Something you have (tokens or mobile phones)
- Something you are (biometrics)
to logon or process a transaction.
Authentication schemes such as One Time Passwords (OTP) implemented using a hardware token can also be key in fighting attacks such as CSRF and client-side malware.
Authentication and Error Messages
Incorrectly implemented error messages in the case of authentication functionality can be used for the purposes of user ID and password enumeration.
An application should respond (both HTTP and HTML) in a generic manner which is not unique to the error condition or authentication failure.
An application should respond with a generic error message regardless if the user ID or password was incorrect. It should also no give any indication to the status of an account if it exists.
Incorrect responses examples:
- "Login for User foo: invalid password"
- "Login failed, invalid user ID"
- "Login failed; account disabled"
- "login failed; this user is not active"
Correct response example:
- "Login failed; Invalid user ID or password"
The correct response does not indicate if the user ID or password is the incorrect parameter and hence inferring a valid user ID.
Error Codes and URL's
The application may return a different HTTP Error code depending on the authentication attempt response. It may respond with a 200 for a positive result and a 403 for a negative result. Even though a generc error page is shown to a user the HTTP response code may differ which can indicate a signature.
Transmit Passwords Only Over TLS
Implement Account Lockout
Session Management General Guidelines
Transmit Session ID's Only Over TLS
Ensure Session ID's are Cryptographically Strong and Random
Implement Idle And Absolute Timeout
Caching & Privacy
OWASP Cheat Sheets Project Homepage
Authors and Primary Editors
Eoin Keary eoinkeary[at]owasp.org