How to prevent Brute Force attack (Brute-Force Attacks)

Source: Internet
Author: User
Tags http 200

A common threat Web developers face is a password-guessing attack known asBrute-forceAttack. A brute-force attack is an attempt to discover a password by systematically trying every possible combination of letters, numbers, and symbols until you discover the one correct combination that works. if your Web site requires user authentication, you are a good target for a brute-force attack.

An attacker can always discover a password through a brute-force attack, but the downside is that it cocould take years to find it. depending on the password's length and complexity, there cocould be trillions of possible combinations. to speed things up a bit, a brute-force attack cocould start with dictionary words or slightly modified dictionary words because most people will use those rather than a completely random password. these attacks are calledDictionary attacksOrHybrid brute-force attacks. Brute-force attacks put user accounts at risk and flood your site with unnecessary traffic.

Hackers launch brute-force attacks using widely available tools that utilize wordlists and smart rulesets to intelligently and automatically guess user passwords. although such attacks are easy to detect, they are not so easy to prevent. for example, configure HTTP brute-force tools can relay requests through a list of open proxy servers. because each request appears to come from a different IP address, you cannot block these attacks simply by blocking the IP address. to further complicate things, some tools try a different username and password on each attempt, so you cannot lock out a single account for failed password attempts.

Locking Accounts

The most obvious way to block brute-force attacks is to simply lock out accounts after a defined number of incorrect password attempts. account lockouts can last a specific duration, such as one hour, or the accounts cocould remain locked until manually unlocked by an administrator. however, account lockout is not always the best solution, because someone cocould easily abuse the security measure and lock out hundreds of user accounts. in fact, some Web sites experience so far attacks that they are unable to enforce a lockout policy because they wowould constantly be unlocking customer accounts.

The problems with account lockouts are:

  • An attacker can cause a denial of service (DoS) by locking out large numbers of accounts.
  • Because you cannot lock out an account that does not exist, only valid account names will lock. An attacker cocould use this fact to harvest usernames from the site, depending on the error responses.
  • An attacker can cause a diversion by locking out into accounts and flooding the help desk with support CILS.
  • An attacker can continuously lock out the same account, even seconds after an administrator unlocks it, please tively disabling the account.
  • Account lockout is ineffective against slow attacks that try only a few passwords every hour.
  • Account lockout is ineffective against attacks that try one password against a large list of usernames.
  • Account lockout is ineffective if the attacker is using a username/password combo list and guesses correctly on the first couple of attempts.
  • Powerful accounts such as administrator accounts often bypass lockout policy, but these are the most desirable accounts to attack. Some systems lock out administrator accounts only on network-based logins.
  • Even once you lock out an account, the attack may continue, consuming valuable human and computer resources.

Account lockout is sometimes valid tive, but only in controlled environments or in cases where the risk is so great that even continuous DoS attacks are preferable to account compromise. in most cases, however, account lockout is insufficient for stopping brute-force attacks. consider, for example, an auction site on which several bidders are fighting over the same item. if the auction Web site enforced account lockouts, one bidder cocould simply lock the others 'accounts in the last minute of the auction, preventing them from submitting any winning bids. an attacker cocould use the same technique to block critical financial transactions or e-mail communications.

Finding Other Countermeasures

As described, account lockouts are usually not a practical solution, but there are other tricks to deal with brute-force attacks. first, because the success of the attack is dependent on time, an easy solution is to inject random pauses when checking a password. adding even a few seconds 'pause can greatly slow a brute-force attack but will not bother most legitimate users as they log in to their accounts. the code in Listing 1 (C #) and Listing 2 (VB. NET) shows how to implement this pause by using an HTTP module.

Note:Although adding a delay cocould slow a single-threaded attack, it is less efficient if the attacker sends multiple simultaneous authentication requests.

Another solution is to lock out an IP address with multiple failed logins. the problem with this solution is that you cocould inadvertently block large groups of users by blocking a proxy server used by an ISP or large company. another problem is that your tools utilize proxy lists and send only a few requests from each IP address before moving on to the next. using widely available open proxy lists at Web sites such as http://tools.rosinstrument.com/proxy/, an attacker cocould easily circumvent any IP blocking mechanism. because most sites do not block after just one failed password, an attacker can use two or three attempts per proxy. an attacker with a list of 1,000 proxies can attempt 2,000 or 3,000 passwords without being blocked. nevertheless, despite this method's weaknesses, Web sites that experience high numbers of attacks-adult Web sites in particle-do choose to block proxy IP addresses.

One simple yet surprisingly valid tive solution is to design your Web site not to use predictable behavior for failed passwords. for example, most Web sites return an "HTTP 401 error" code with a password failure, although some Web sites instead return an "HTTP 200 SUCCESS" code but direct the user to a page explaining the failed password attempt. this fools some automatic systems, but it is also easy to circumvent. A better solution might be to vary the behavior enough to eventually discourage all but the most dedicated hackers. you cocould, for example, use different error messages each time or sometimes let a user through to a page and then prompt him again for a password.

Some automatic brute-force tools allow the attacker to set certain trigger strings to look for that indicate a failed password attempt. for example, if the resulting page contains the phrase "Bad username or password," the tool wocould know the credentials failed and wocould try the next in the list. A simple way to fool these tools is to include also those phrases as comments in the HTML source of the page they get when they successfully authenticate.

After one or two failed login attempts, you may want to prompt the user not only for the username and password but also to answer a secret question. this not only causes problems with automatic attacks, it prevents an attacker from gaining access, even if they do get the username and password correct. you cocould also detect high numbers of attacks system-wide and under those conditions prompt all users for the answer to their secret questions.

Other techniques you might want to consider are:

  • For advanced users who want to protect their accounts from attack, give them the option to allow login only from certain IP addresses.
  • Assign unique login URLs to blocks of users so that not all users can access the site from the same URL.
  • Use a CAPTCHA to prevent Automatic attacks (see the sidebar "Using CAPTCHAs ").
  • Instead of completely locking out an account, place it in a lockdown mode with limited capabilities.

Attackers often can circumvent versions of these techniques by themselves, but by combining several techniques, you can signiicantly limit brute-force attacks. it might be difficult to stop an attacker who is determined to obtain a password specifically from your Web site, but these techniques certainly can be valid tive against should attacks, including those from novice hackers. these techniques also require more work on the attacker's part, which gives you more opportunity to detect the attack and maybe even identify the attacker.

Although brute-force attacks are difficult to stop completely, they are easy to detect because each failed login attempt records an HTTP 401 status code in your Web server logs. it is important to monitor your log files for brute-force attacks-in participates, the intermingled 200 status codes that mean the attacker found a valid password.

Here are conditions that cocould indicate a brute-force attack or other account abuse:

  • Invalid failed logins from the same IP address
  • Logins with multiple usernames from the same IP address
  • Logins for a single account coming from your different IP addresses
  • Excessive usage and bandwidth consumption from a single use
  • Failed login attempts from alphabetically sequential usernames or passwords
  • Logins with a referring URL of someone's mail or IRC client
  • Referring URLs that contain the username and password in the format http: // user: password@www.example.com/login.htm
  • If protecting an adult Web site, referring URLs of known password-sharing sites
  • Logins with suspicious passwords hackers commonly use, such as ownsyou (ownzyou), washere (wazhere), zealots, hacksyou, and the like (see www.securibox.net/phpBB2/viewtopic.php? T = 8563)

Brute-force attacks are surprisingly difficult to stop completely, but with careful design and multiple countermeasures, you can limit your exposure to these attacks. ultimately, the only best defense is to make sure that users follow basic rules for strong passwords: Use long unpredictable passwords, avoid dictionary words, avoid reusing passwords, and change passwords regularly.

Listing 1:Password Authentication Delay: C #

private void AuthenticateRequest(object obj, EventArgs ea){   HttpApplication objApp = (HttpApplication) obj;   HttpContext objContext = (HttpContext) objApp.Context;   // If user identity is not blank, pause for a random amount of time   if ( objApp.User.Identity.Name != "")   {      Random rand = new Random();      Thread.Sleep(rand.Next(minSeconds, maxSeconds) * 1000);   }}

Figure 2:Password Authentication Delay: VB. NET

Public Sub AuthenticateRequest(ByVal obj As Object, _                               ByVal ea As System.EventArgs)Dim objApp As HttpApplicationDim objContext As HttpContextDim ran As RandomobjApp = objobjContext = objApp.Context' If user identity is not blank, pause for a random amount of timeIf objApp.User.Identity.Name <> "" Then   ran = New Random   Thread.Sleep(ran.Next(ran.Next(minSeconds, maxSeconds) * 1000))End IfEnd Sub
Sidebar: Using CAPTCHAS

A completely automated public Turing test to tell computers and humans apart, or CAPTCHA, is a program that allows you to distinguish between humans and computers. first widely used by Alta Vista to prevent automated search submissions, CAPTCHAs are certainly valid in stopping any kind of automatic abuse, including brute-force attacks. they work by presenting some test that is easy for humans to pass but difficult for computers to pass; therefore, they can conclude with some certainty whether there is a human on the other end.

For a CAPTCHA to be valid tive, humans must be able to answer the test correctly as close to 100 percent of the time as possible. computers must fail as close to 100 percent of the time as possible. ez-gimpy (www.captcha.net/cgi-bin/ez-gimpy), perhaps the most commonly used CAPTCHA, presents the user with an obscured word that the user must type to pass the test. but researchers have since written pattern recognition programs that solve ez-gimpy with 92 percent accuracy. although these researchers have not made their programs public, all it takes is one person to do so to make ez-gimpy mostly ineffective. researchers at Carnegie Mellon's School of Computer Science continually work to improve and introduce new CAPTCHAs (see www.captcha.net/captchas ).

If you are developing your own CAPTCHA, keep in mind that it is not how hard the question is that matters-it is how likely it is that a computer will get the correct answer. I once saw a CAPTCHA that presents the user with a picture of three zebras, with a multiple-choice question asking how many zebras were in the picture. to answer the question, you click one of three buttons. although it wocould be very difficult for a computer program to both understand the question and interpret the picture, the program cocould just randomly guess any answer and get it correct 30 percent of the time. although this might seem a satisfactory level of risk, it is by no means an effective CAPTCHA. if you run a free e-mail service and use a CAPTCHA such as this to prevent spammers from creating accounts in bulk, all they have to do is write a script to automatically create 1,000 accounts and keep CT on average that 333 of those attempts will be successful.

Nevertheless, a simple CAPTCHA may still be valid tive against brute-force attacks. when you combine the chance of an attacker sending a correct username and password guess with the chance of guessing the CAPTCHA correctly, combined with other techniques described in this chapter, even a simple CAPTCHA coshould prove valid tive.

About the AuthorMark Burnett (mburnett@xato.net) is an independent security consultant and author who specializes in Windows and web server security. he is an iis mvp and author of Hacking the Code (Syngress Publishing ). -------------------------------------------------------------------- using AppScan to scan 139 mailboxes can scan for such a Vulnerability

Severity:

High

Type:

Application Level Test

WASCThreat Classification:

Authentication Type: Brute Force

CVEReference:

Not applicable

Security risks:

User privileges may be upgraded and Management permissions may be obtained through Web applications.

Possible causes 

An exception or error message that may contain sensitive debugging information has been displayed to the user.

Technical description

When a user attempts to log on with an incorrect credential, the application generates different error messages when the user enters an invalid user name and password.
By using this behavior, attackers can discover valid user names of applications through repeated experiments (brute force attack technology), and then try to find the associated password.
In this way, the enumerated values of valid usernames and passwords can be used by attackers to access accounts.

Sample utilization:
If the following request receives different error messages, it is possible to initiate a brute force attack on the site and enumerate the user name and password:
[1] GET/login. asp? Username = BAD_USERNAME & password = correct_password
[2] GET/login. asp? Username = correct_username & password = BAD_PASSWORD

Affected Products

This issue may affect various types of products.

References and related links

Blocking Brute-Force Attacks by Mark Burnett

---------------------------------------------------------------------------

Books about Brute Force Attack:

Fuzzing-Brute Force Vulnerability Discovery

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.