Identity Management / Plaintext Storage of a Password
Plaintext Storage of a Password is a vulnerability that occurs when a system stores a user’s password in plaintext, meaning the user’s password is not encrypted or hashed. This vulnerability has been classified by the Common Weakness Enumeration (CWE) directory as CWE-259 and is listed under the category of Identity Management. The vulnerability can occur in both web and API systems as well as in infrastructure systems. According to the OWASP Testing Guide, this vulnerability can be easily identified by reviewing the source code of the application.
The risk associated with the Plaintext Storage of a Password vulnerability is a high risk. If an attacker were to gain access to the plaintext passwords, they would be able to access the user's credentials and use them to gain access to the system or application. Additionally, if passwords are stored in plaintext, they can be easily exposed in the event of a data breach.
To prevent Plaintext Storage of a Password vulnerability, passwords should always be stored in a secure, encrypted format. Additionally, passwords should be hashed using a strong hashing algorithm. Furthermore, the application should not store passwords in the clear or in any reversible format.
The following code is an example from the CVE directory of a vulnerability related to Plaintext Storage of a Password.
String plaintextPassword = request.getParameter("password"); // Store the plaintext password in a database String query = "INSERT INTO users (username, password) VALUES (?, ?)"; PreparedStatement statement = connection.prepareStatement(query); statement.setString(1, username); statement.setString(2, plaintextPassword); statement.executeUpdate();