SWR-008- The user's password is stored in the database as a hashed password
Internal ID | SWR_008 |
Title | The user's password is stored in the database as a hashed password |
Category | SECURITY REGULATORY |
Importance | CRITICAL |
System | Backend, Database |
Editor(s) | Alejandro Carmena Magro , JD-017 |
Supervisor | Alfonso Medela , JD-005 |
Approval | PENDING |
Created at | 24 Jun 2024 |
Description​
For user authentication, passwords are stored either as plaintext or hashes. Since passwords stored as plaintext are easily stolen if database access is compromised, databases typically store hashes instead. Thus, no one (including the authentication system) can learn a password merely by looking at the value stored in the database.
When we create a new account for a user or they update their password, the plaintext password is first combined with a unique salt value. This salt is a random string of characters that is unique to each password and helps to protect against rainbow table attacks. The combined password and salt are then passed through a hashing algorithm, which converts the input into a fixed-length string of characters. The output, known as the hash, does not reveal the original password and is computationally infeasible to reverse. This hashed password, along with the salt, is then stored in the database. Each time a user logs in, the software hashes the entered password with the stored salt and compares the result to the stored hash to verify the user's identity without ever needing to store or transmit the plaintext password.
Rationale​
This requirement significantly improves the security of user data. Storing passwords as plaintext poses a severe security risk, as any breach of the database would expose user credentials. Hashing passwords mitigates this risk by ensuring that even if the database is compromised, the actual passwords remain protected.
Source​
- Alejandro Carmena Magro , JD-017
- Regulatory standards (e.g., GDPR)
- Industry best practices
Tested by software tests​
Activities generated​
- Incorporating a secure hashing algorithm (e.g., bcrypt, Argon2) in the backend code.
- Configuring the user registration and password update workflows to include hashing.
Implements user needs​
This requirement guarantees the security and privacy of user accounts, addressing concerns about personal information safety and boosting trust in the software.
Regulatory requirements​
8.1: The device shall be compliant with MDR 2017/745, Annex I, point 17.2, 17.4, 18.8, 23.4(ab).
8.2: The device shall be compliant with data privacy regulation (Regulation (EU) 2016/679 (General Data Protection Regulation)).
Causes failure modes​
- Incorrect implementation or usage of the hashing algorithm could result in weak security.
- Failure to properly hash passwords before storage could leave plaintext passwords exposed.
Implements risk control measures​
- Hashing passwords helps protect against credential stuffing attacks, where attackers use leaked usernames and passwords from one service to try to gain access to other services.
- Even if an insider gains access to the database, they cannot easily retrieve plaintext passwords, thus reducing the risk from internal threats.
- Storing passwords in a hashed format helps in complying with various regulatory requirements like GDPR, HIPAA, and others.
- A security breach exposing plaintext passwords can severely damage the reputation of the organization. Using hashed passwords helps mitigate the potential damage to the company's reputation in case of a data breach.
Acceptance criteria​
- All user passwords are hashed before storage in the database.
- The hashing algorithm used must be a recognized secure method (e.g., bcrypt, Argon2).
- Unit and integration tests demonstrating that plaintext passwords are not stored in the database.
Constraints​
- The chosen hashing algorithm must balance security and performance, ensuring it is robust enough to resist attacks while not introducing excessive computational overhead in user authentication processes.
Dependencies​
- Availability of cryptographic libraries (such as OpenSSL, Bcrypt, Argon2) to provide the hashing algorithms.
- Database management system.
- User account management system.
- User authentication system.
Performance considerations​
- The hashing process should not significantly degrade the performance of login operations.
Additional notes​
Regularly review and update the hashing algorithm to align with the latest security recommendations.
Revision history​
Document version | Date | Author | Description |
---|---|---|---|