CWE-916: Use of Password Hash With Insufficient Computational Effort

Description:
The product generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.

Extended Description:
Many password storage mechanisms compute a hash and store the hash, instead of storing the original password in plaintext. In this design, authentication involves accepting an incoming password, computing its hash, and comparing it to the stored hash. 
             Many hash algorithms are designed to execute quickly with minimal overhead, even cryptographic hashes. However, this efficiency is a problem for password storage, because it can reduce an attacker's workload for brute-force password cracking. If an attacker can obtain the hashes through some other method (such as SQL injection on a database that stores hashes), then the attacker can store the hashes offline and use various techniques to crack the passwords by computing hashes efficiently. Without a built-in workload, modern attacks can compute large numbers of hashes, or even exhaust the entire space of all possible passwords, within a very short amount of time, using massively-parallel computing (such as cloud computing) an

Affected languages: Not Language-Specific
Parent weaknesses: CWE-328, CWE-327

Consequences:
  - Access Control: Bypass Protection Mechanism

Detection methods:
  - Automated Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful: 
                   
                      Cost effective for partial coverage: 
                         
             
  - Manual Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful: 
                   
                      Cost effective for partial coverage: 
                         
             
  - Manual Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful: 
                   
                      Highly cost effective: 
                         
                           
  - Automated Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful: 
                   
                      Highly cost effective: 
                         
                           

Mitigations:
  - [Architecture and Design] Use an adaptive hash function that can be configured to change the amount of computational effort needed to compute the hash, such as the number of iterations ("stretching") or the amount of memory required. Some hash functions perform salting automatically. These functions can significantly increas
  - [Implementation] When using industry-approved techniques, use them correctly. Don't cut corners by skipping resource-intensive steps (CWE-325). These steps are often essential for preventing common attacks.

Demonstrative examples:
In this example, a new user provides a new username and password to create an account. The program hashes the new user's password then stores it in a database.
While it is good to avoid storing a cleartext password, the program does not provide a salt to the hashing function, thus increasing the chances of an attacker being able to reverse the hash and discover the original password if the database is compromised.
def storePassword(userName,Password): hasher = hashlib.new('md5') hasher.update(Password) hashed[CREDENTIAL_REDACTED].digest() 
                         
                         # UpdateUserLogin returns True on success, False otherwise 
                         return updateUserLogin(userName,hashedPassword)
def storePassword(userName,Password): hasher = hashlib.new('md5',b'SaltGoe

Real-world examples:
  - CVE-2008-1526: Router does not use a salt with a hash, making it easier to crack passwords.
  - CVE-2006-1058: Router does not use a salt with a hash, making it easier to crack passwords.
  - CVE-2008-4905: Blogging software uses a hard-coded salt when calculating a password hash.
  - CVE-2002-1657: Database server uses the username for a salt when encrypting passwords, simplifying brute force attacks.
  - CVE-2001-0967: Server uses a constant salt when encrypting passwords, simplifying brute force attacks.