CWE-257 以可恢复格式存储口令

Storing Passwords in a Recoverable Format

结构: Simple

Abstraction: Base

状态: Incomplete

被利用可能性: High


The storage of passwords in a recoverable format makes them subject to password reuse attacks by malicious users. In fact, it should be noted that recoverable encrypted passwords provide no significant benefit over plaintext passwords since they are subject not only to reuse by malicious attackers but also by malicious insiders. If a system administrator can recover a password directly, or use a brute force search on the available information, the administrator can use the password on other accounts.


  • cwe_Nature: ChildOf cwe_CWE_ID: 522 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 522 cwe_View_ID: 699 cwe_Ordinal: Primary

  • cwe_Nature: PeerOf cwe_CWE_ID: 259 cwe_View_ID: 1000


Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}


范围 影响 注释
['Confidentiality', 'Access Control'] Gain Privileges or Assume Identity User's passwords may be revealed.
Access Control Gain Privileges or Assume Identity Revealed passwords may be reused elsewhere to impersonate the users in question.


Architecture and Design


Use strong, non-reversible encryption to protect stored passwords.


Both of these examples verify a password by comparing it to a stored compressed version.

bad C

int VerifyAdmin(char *password) {
if (strcmp(compress(password), compressed_password)) {
printf("Incorrect Password!\n");
printf("Entering Diagnostic Mode...\n");

bad Java

int VerifyAdmin(String password) {
if (passwd.Equals(compress(password), compressed_password)) {
//Diagnostic Mode

Because a compression algorithm is used instead of a one way hashing algorithm, an attacker can recover compressed passwords stored in the database.

The following examples show a portion of properties and configuration files for Java and ASP.NET applications. The files include username and password information but they are stored in plaintext.

This Java example shows a properties file with a plaintext username / password pair.

bad Java

# Java Web App ResourceBundle properties file

The following example shows a portion of a configuration file for an ASP.Net application. This configuration file includes username and password information for a connection to a database but the pair is stored in plaintext.


<add name="ud_DEV" connectionString="connectDB=uDB; uid=db2admin; pwd=password; dbalias=uDB;" providerName="System.Data.Odbc" />

Username and password information should not be included in a configuration file or a properties file in plaintext as this will allow anyone who can read the file access to the resource. If possible, encrypt this information and avoid CWE-260 and CWE-13.



映射的分类名 ImNode ID Fit Mapped Node Name
CLASP Storing passwords in a recoverable format
Software Fault Patterns SFP23 Exposed Data


  • CAPEC-49