5.4.1.4 Ensure strong password hashing algorithm is configured (Automated)
Profile
- Level 1 - Server
- Level 1 - Workstation
Description
A cryptographic hash function converts an arbitrary-length input into a fixed length output. Password hashing performs a one-way transformation of a password, turning the password into another string, called the hashed password.
ENCRYPT_METHOD (string) - This defines the system default encryption algorithm for encrypting passwords (if no algorithm are specified on the command line). It can take one of these values:
MD5- MD5-based algorithm will be used for encrypting passwordSHA256- SHA256-based algorithm will be used for encrypting passwordSHA512- SHA512-based algorithm will be used for encrypting passwordBCRYPT- BCRYPT-based algorithm will be used for encrypting passwordYESCRYPT- YESCRYPT-based algorithm will be used for encrypting passwordDES- DES-based algorithm will be used for encrypting password (default)
Note:
- This parameter overrides the deprecated
MD5_CRYPT_ENABvariable. - This parameter will only affect the generation of group passwords.
- The generation of user passwords is done by PAM and subject to the PAM configuration.
- It is recommended to set this variable consistently with the PAM configuration.
Rationale
The SHA-512 and yescrypt algorithms provide a stronger hash than other algorithms used by Linux for password hash generation. A stronger hash provides additional protection to the system by increasing the level of effort needed for an attacker to successfully determine local group passwords.
Audit Procedure
Command Line
Run the following command to verify the hashing algorithm is sha512 or yescrypt in /etc/login.defs:
# grep -Pi -- '^\h*ENCRYPT_METHOD\h+(SHA512|yescrypt)\b' /etc/login.defs
Example output:
ENCRYPT_METHOD SHA512
- OR -
ENCRYPT_METHOD YESCRYPT
Expected Result
Output should show ENCRYPT_METHOD set to SHA512 or YESCRYPT.
Remediation
Command Line
Edit /etc/login.defs and set the ENCRYPT_METHOD to SHA512 or YESCRYPT:
ENCRYPT_METHOD <HASHING_ALGORITHM>
Example:
ENCRYPT_METHOD YESCRYPT
Note:
- This only effects local groups' passwords created after updating the file to use
sha512oryescrypt. - If it is determined that the password algorithm being used is not
sha512oryescrypt, once it is changed, it is recommended that all group passwords be updated to use the stronger hashing algorithm. - It is recommended that the chosen hashing algorithm is consistent across
/etc/login.defsand the PAM configuration
Default Value
ENCRYPT_METHOD SHA512
References
- NIST SP 800-53 Rev. 5: IA-5
CIS Controls
v8 - 3.11 Encrypt Sensitive Data at Rest: Encrypt sensitive data at rest on servers, applications, and databases containing sensitive data. Storage-layer encryption, also known as server-side encryption, meets the minimum requirement of this Safeguard. Additional encryption methods may include application-layer encryption, also known as client-side encryption, where access to the data storage device(s) does not permit access to the plain-text data. (IG 2, IG 3)
v7 - 16.4 Encrypt or Hash all Authentication Credentials: Encrypt or hash with a salt all authentication credentials when stored. (IG 2, IG 3)
MITRE ATT&CK Mappings: T1003, T1003.008, T1110, T1110.002 - Tactics: TA0006 - Mitigations: M1041