# A07:2021 – Identification and Authentication Failures ![icon](assets/TOP_10_Icons_Final_Identification_and_Authentication_Failures.png){: style="height:80px;width:80px" align="right"} ## Factors | CWEs Mapped | Max Incidence Rate | Avg Incidence Rate | Avg Weighted Exploit | Avg Weighted Impact | Max Coverage | Avg Coverage | Total Occurrences | Total CVEs | |:-------------:|:--------------------:|:--------------------:|:--------------:|:--------------:|:----------------------:|:---------------------:|:-------------------:|:------------:| | 22 | 14.84% | 2.55% | 7.40 | 6.50 | 79.51% | 45.72% | 132,195 | 3,897 | ## Overview Previously known as *Broken Authentication*, this category slid down from the second position and now includes Common Weakness Enumerations (CWEs) related to identification failures. Notable CWEs included are *CWE-297: Improper Validation of Certificate with Host Mismatch*, *CWE-287: Improper Authentication*, and *CWE-384: Session Fixation*. ## Description Confirmation of the user's identity, authentication, and session management is critical to protect against authentication-related attacks. There may be authentication weaknesses if the application: - Permits automated attacks such as credential stuffing, where the attacker has a list of valid usernames and passwords. - Permits brute force or other automated attacks. - Permits default, weak, or well-known passwords, such as "Password1" or "admin/admin". - Uses weak or ineffective credential recovery and forgot-password processes, such as "knowledge-based answers," which cannot be made safe. - Uses plain text, encrypted, or weakly hashed passwords data stores (see [A02:2021-Cryptographic Failures](A02_2021-Cryptographic_Failures.md)). - Has missing or ineffective multi-factor authentication. - Exposes session identifier in the URL. - Reuse session identifier after successful login. - Does not correctly invalidate Session IDs. User sessions or authentication tokens (mainly single sign-on (SSO) tokens) aren't properly invalidated during logout or a period of inactivity. ## How to Prevent - Where possible, implement multi-factor authentication to prevent automated credential stuffing, brute force, and stolen credential reuse attacks. - Do not ship or deploy with any default credentials, particularly for admin users. - Implement weak password checks, such as testing new or changed passwords against the top 10,000 worst passwords list. - Align password length, complexity, and rotation policies with National Institute of Standards and Technology (NIST) 800-63b's guidelines in section 5.1.1 for Memorized Secrets or other modern, evidence-based password policies. - Ensure registration, credential recovery, and API pathways are hardened against account enumeration attacks by using the same messages for all outcomes. - Limit or increasingly delay failed login attempts, but be careful not to create a denial of service scenario. Log all failures and alert administrators when credential stuffing, brute force, or other attacks are detected. - Use a server-side, secure, built-in session manager that generates a new random session ID with high entropy after login. Session identifier should not be in the URL, be securely stored, and invalidated after logout, idle, and absolute timeouts. ## Example Attack Scenarios **Scenario #1:** Credential stuffing, the use of lists of known passwords, is a common attack. Suppose an application does not implement automated threat or credential stuffing protection. In that case, the application can be used as a password oracle to determine if the credentials are valid. **Scenario #2:** Most authentication attacks occur due to the continued use of passwords as a sole factor. Once considered best practices, password rotation and complexity requirements encourage users to use and reuse weak passwords. Organizations are recommended to stop these practices per NIST 800-63 and use multi-factor authentication. **Scenario #3:** Application session timeouts aren't set correctly. A user uses a public computer to access an application. Instead of selecting "logout," the user simply closes the browser tab and walks away. An attacker uses the same browser an hour later, and the user is still authenticated. ## References - [OWASP Proactive Controls: Implement Digital Identity](https://owasp.org/www-project-proactive-controls/v3/en/c6-digital-identity) - [OWASP Application Security Verification Standard: V2 authentication](https://owasp.org/www-project-application-security-verification-standard) - [OWASP Application Security Verification Standard: V3 Session Management](https://owasp.org/www-project-application-security-verification-standard) - [OWASP Testing Guide: Identity](https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/03-Identity_Management_Testing/README), [Authentication](https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/04-Authentication_Testing/README) - [OWASP Cheat Sheet: Authentication](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html) - [OWASP Cheat Sheet: Credential Stuffing](https://cheatsheetseries.owasp.org/cheatsheets/Credential_Stuffing_Prevention_Cheat_Sheet.html) - [OWASP Cheat Sheet: Forgot Password](https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html) - [OWASP Cheat Sheet: Session Management](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html) - [OWASP Automated Threats Handbook](https://owasp.org/www-project-automated-threats-to-web-applications/) - [NIST 800-63b: 5.1.1 Memorized Secrets](https://pages.nist.gov/800-63-3/sp800-63b.html#memsecret) ## List of Mapped CWEs [CWE-255 Credentials Management Errors](https://cwe.mitre.org/data/definitions/255.html) [CWE-259 Use of Hard-coded Password](https://cwe.mitre.org/data/definitions/259.html) [CWE-287 Improper Authentication](https://cwe.mitre.org/data/definitions/287.html) [CWE-288 Authentication Bypass Using an Alternate Path or Channel](https://cwe.mitre.org/data/definitions/288.html) [CWE-290 Authentication Bypass by Spoofing](https://cwe.mitre.org/data/definitions/290.html) [CWE-294 Authentication Bypass by Capture-replay](https://cwe.mitre.org/data/definitions/294.html) [CWE-295 Improper Certificate Validation](https://cwe.mitre.org/data/definitions/295.html) [CWE-297 Improper Validation of Certificate with Host Mismatch](https://cwe.mitre.org/data/definitions/297.html) [CWE-300 Channel Accessible by Non-Endpoint](https://cwe.mitre.org/data/definitions/300.html) [CWE-302 Authentication Bypass by Assumed-Immutable Data](https://cwe.mitre.org/data/definitions/302.html) [CWE-304 Missing Critical Step in Authentication](https://cwe.mitre.org/data/definitions/304.html) [CWE-306 Missing Authentication for Critical Function](https://cwe.mitre.org/data/definitions/306.html) [CWE-307 Improper Restriction of Excessive Authentication Attempts](https://cwe.mitre.org/data/definitions/307.html) [CWE-346 Origin Validation Error](https://cwe.mitre.org/data/definitions/346.html) [CWE-384 Session Fixation](https://cwe.mitre.org/data/definitions/384.html) [CWE-521 Weak Password Requirements](https://cwe.mitre.org/data/definitions/521.html) [CWE-613 Insufficient Session Expiration](https://cwe.mitre.org/data/definitions/613.html) [CWE-620 Unverified Password Change](https://cwe.mitre.org/data/definitions/620.html) [CWE-640 Weak Password Recovery Mechanism for Forgotten Password](https://cwe.mitre.org/data/definitions/640.html) [CWE-798 Use of Hard-coded Credentials](https://cwe.mitre.org/data/definitions/798.html) [CWE-940 Improper Verification of Source of a Communication Channel](https://cwe.mitre.org/data/definitions/940.html) [CWE-1216 Lockout Mechanism Errors](https://cwe.mitre.org/data/definitions/1216.html)