CWE-307: Improper Restriction of Excessive Authentication Attempts

Description

The product does not implement sufficient measures to prevent multiple failed authentication attempts within a short time frame, making it more susceptible to brute force attacks.

Submission Date :

July 19, 2006, midnight

Modification Date :

2023-06-29 00:00:00+00:00

Organization :

MITRE
Example Vulnerable Codes

Example - 1

In January 2009, an attacker was able to gain administrator access to a Twitter server because the server did not restrict the number of login attempts [REF-236]. The attacker targeted a member of Twitter's support team and was able to successfully guess the member's password using a brute force attack by guessing a large number of common words. After gaining access as the member of the support staff, the attacker used the administrator panel to gain access to 33 accounts that belonged to celebrities and politicians. Ultimately, fake Twitter messages were sent that appeared to come from the compromised accounts.

Example - 2

The following code, extracted from a servlet's doPost() method, performs an authentication lookup every time the servlet is invoked.


String username = request.getParameter("username");String password = request.getParameter("password");int authResult = authenticateUser(username, password);

However, the software makes no attempt to restrict excessive authentication attempts.

Example - 3

This code attempts to limit the number of login attempts by causing the process to sleep before completing the authentication.


$username = $_POST['username'];$password = $_POST['password'];sleep(2000);$isAuthenticated = authenticateUser($username, $password);

However, there is no limit on parallel connections, so this does not increase the amount of time an attacker needs to complete an attack.

Example - 4

In the following C/C++ example the validateUser method opens a socket connection, reads a username and password from the socket and attempts to authenticate the username and password.




printf("Unable to open socket connection");return(FAIL);
isValidUser = AuthenticateUser(username, password);if (getNextMessage(socket, password, PASSWORD_SIZE) > 0) {}if (getNextMessage(socket, username, USERNAME_SIZE) > 0) {}
int socket = openSocketConnection(host, port);if (socket < 0) {}int isValidUser = 0;char username[USERNAME_SIZE];char password[PASSWORD_SIZE];while (isValidUser == 0) {}return(SUCCESS);int validateUser(char *host, int port){}

The validateUser method will continuously check for a valid username and password without any restriction on the number of authentication attempts made. The method should limit the number of authentication attempts made to prevent brute force attacks as in the following example code.



isValidUser = AuthenticateUser(username, password);if (getNextMessage(socket, password, PASSWORD_SIZE) > 0) {}
if (getNextMessage(socket, username, USERNAME_SIZE) > 0) {}count++;
return(SUCCESS);
return(FAIL);...int count = 0;while ((isValidUser == 0) && (count < MAX_ATTEMPTS)) {}if (isValidUser) {}else {}int validateUser(char *host, int port){}

Example - 5

Consider this example from areal-world attack against the iPhone[REF-1218]. An attacker can use brute forcemethods; each time there is a failed guess, theattacker quickly cuts the power before the failedentry is recorded, effectively bypassing theintended limit on the number of failedauthentication attempts. Note that this attackrequires removal of the cell phone battery andconnecting directly to the phone's power source,and the brute force attack is stilltime-consuming.

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.