632
Nature Type ID Name Page
MemberOf 255 Credentials Management Errors 2315
MemberOf 310 Cryptographic Issues 2318
Applicable Platforms
Language : Not Language-Specific (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Access Control Gain Privileges or Assume Identity
Detection Methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST),
can find some instances of this weakness by analyzing source code (or binary/compiled code)
without having to execute it. Typically, this is done by building a model of data flow and control
flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input)
with "sinks" (destinations where the data interacts with external components, a lower layer such
as the OS, etc.)
Effectiveness = High
Potential Mitigations
Passwords should be encrypted with keys that are at least 128 bits in length for adequate
security.
Demonstrative Examples
Example 1:
The following code reads a password from a properties file and uses the password to connect to a
database.
Example Language: Java (Bad)
...
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties"));
String password = Base64.decode(prop.getProperty("password"));
DriverManager.getConnection(url, usr, password);
...
This code will run successfully, but anyone with access to config.properties can read the value of
password and easily determine that the value has been base 64 encoded. If a devious employee
has access to this information, they can use it to break into the system.
Example 2:
The following code reads a password from the registry and uses the password to create a new
network credential.
Example Language: C# (Bad)
...
string value = regKey.GetValue(passKey).ToString();
byte[] decVal = Convert.FromBase64String(value);
NetworkCredential netCred = newNetworkCredential(username,decVal.toString(),domain);
...
CWE Version 4.14
CWE-262: Not Using Password Aging
CWE-262: Not Using Password Aging