Improper Restriction of Excessive Authentication Attempts

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


Demonstrations

The following examples help to illustrate the nature of this weakness and describe methods or techniques which can be used to mitigate the risk.

Note that the examples here are by no means exhaustive and any given weakness may have many subtle varieties, each of which may require different detection methods or runtime controls.

Example One

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. 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 Two

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 Three

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 Four

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.

int validateUser(char *host, int port)
{

  int socket = openSocketConnection(host, port);
  if (socket < 0) {
    printf("Unable to open socket connection");
    return(FAIL);
  }

  int isValidUser = 0;
  char username[USERNAME_SIZE];
  char password[PASSWORD_SIZE];

  while (isValidUser == 0) {

    if (getNextMessage(socket, username, USERNAME_SIZE) > 0) {
      if (getNextMessage(socket, password, PASSWORD_SIZE) > 0) {
        isValidUser = AuthenticateUser(username, password);
      }
    }

  }
  return(SUCCESS);

}

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.

int validateUser(char *host, int port)
{

  ...

  int count = 0;
  while ((isValidUser == 0) && (count < MAX_ATTEMPTS)) {

    if (getNextMessage(socket, username, USERNAME_SIZE) > 0) {
      if (getNextMessage(socket, password, PASSWORD_SIZE) > 0) {
        isValidUser = AuthenticateUser(username, password);
      }
    }
    count++;

  }
  if (isValidUser) {
    return(SUCCESS);
  }
  else {
    return(FAIL);
  }

}

See Also

Authentication Errors

Weaknesses in this category are related to authentication components of a system. Frequently these deal with the ability to verify that an entity is indeed who it clai...

Authenticate Actors

Weaknesses in this category are related to the design and architecture of authentication components of the system. Frequently these deal with verifying the entity is i...

SFP Secondary Cluster: Unrestricted Authentication

This category identifies Software Fault Patterns (SFPs) within the Unrestricted Authentication cluster (SFP34).

Comprehensive CWE Dictionary

This view (slice) covers all the elements in CWE.

CWE Cross-section

This view contains a selection of weaknesses that represent the variety of weaknesses that are captured in CWE, at a level of abstraction that is likely to be useful t...

Weaknesses Introduced During Design

This view (slice) lists weaknesses that can be introduced during design.


Common Weakness Enumeration content on this website is copyright of The MITRE Corporation unless otherwise specified. Use of the Common Weakness Enumeration and the associated references on this website are subject to the Terms of Use as specified by The MITRE Corporation.