1694
For inbound authentication using passwords: apply strong one-way hashes to passwords and
store those hashes in a configuration file or database with appropriate access control. That way,
theft of the file/database still requires the attacker to try to crack the password. When handling
an incoming password during authentication, take the hash of the password and compare it to
the saved hash. Use randomly assigned salts for each separate hash that is generated. This
increases the amount of computation that an attacker needs to conduct a brute-force attack,
possibly limiting the effectiveness of the rainbow table method.
Phase: Architecture and Design
For front-end to back-end connections: Three solutions are possible, although none are
complete. The first suggestion involves the use of generated passwords or keys that are
changed automatically and must be entered at given time intervals by a system administrator.
These passwords will be held in memory and only be valid for the time intervals. Next, the
passwords or keys should be limited at the back end to only performing actions valid for the
front end, as opposed to having full access. Finally, the messages sent should be tagged and
checksummed with time sensitive values so as to prevent replay-style attacks.
Demonstrative Examples
Example 1:
The following code uses a hard-coded password to connect to a database:
Example Language: Java (Bad)
...
DriverManager.getConnection(url, "scott", "tiger");
...
This is an example of an external hard-coded password on the client-side of a connection. This
code will run successfully, but anyone who has access to it will have access to the password. Once
the program has shipped, there is no going back from the database user "scott" with a password of
"tiger" unless the program is patched. A devious employee with access to this information can use
it to break into the system. Even worse, if attackers have access to the bytecode for application,
they can use the javap -c command to access the disassembled code, which will contain the values
of the passwords used. The result of this operation might look something like the following for the
example above:
Example Language: (Attack)
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
Example 2:
The following code is an example of an internal hard-coded password in the back-end:
Example Language: C (Bad)
int VerifyAdmin(char *password) {
if (strcmp(password, "Mew!")) {
printf("Incorrect Password!\n");
return(0)
}
printf("Entering Diagnostic Mode...\n");
return(1);
}
CWE Version 4.14
CWE-798: Use of Hard-coded Credentials
CWE-798: Use of Hard-coded Credentials