admin管理员组文章数量:1632073
http://cwe.mitre/data/definitions/307.html#Demonstrative%20Examples
Description Summary
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.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. 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. Once the attacker gained access as the member of the support staff, he 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 1 References:
Kim Zetter. "Weak Password Brings 'Happiness' to Twitter Hacker". 2009-01-09. < http://www.wired/threatlevel/2009/01/professed-twitt/>. |
Example 2
The following code, extracted from a servlet's doPost() method, performs an authentication lookup every time the servlet is invoked.
(Bad Code) Example Language: Java 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.
(Bad Code) Example Language: PHP $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.
(Bad Code) Example Languages: C and C++ 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.
(Good Code) Example Languages: C and C++ 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); } }
本文标签: RestrictionImpropercweAttemptsauthentication
版权声明:本文标题:cwe ---Improper Restriction of Excessive Authentication Attempts 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1727308050a1107535.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论