626
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 which 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
used 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);
}
Example Language: Java (Bad)
int VerifyAdmin(String password) {
if (!password.equals("Mew!")) {
return(0)
}
//Diagnostic Mode
return(1);
}
CWE Version 4.14
CWE-259: Use of Hard-coded Password
CWE-259: Use of Hard-coded Password