Brute force attacks: guessing until something works

A brute force attack tries passwords against a sign-in form, one after another, until one of them is accepted. It needs no weakness in the code, only a sign-in that answers every attempt. The defence is to make each wrong guess cost something, without turning that cost against the real owner of the account.

Section Bots Updated Targets sign-in

Quick facts

Target
Sign-in forms and authentication APIs
Weakness
CWE-307: improper restriction of excessive authentication attempts
Variants
Simple guessing, dictionary attacks, password spraying, credential stuffing
In your logs
Many failed sign-ins, concentrated on one account or spread across many from the same sources
Does a WAF stop it?
Partly. Rate and pattern of attempts can be limited; password policy, second factors and lockout logic live in the application

Definitions follow OWASP and CWE-307.

How a brute force attack works

The attacker picks a target, usually a username, and sends sign-in attempts with different passwords. Each attempt is an ordinary request; what makes it an attack is the number of them and the fact that almost all fail.

Pure brute force tries every combination and is slow against any password of reasonable length. Real attacks are smarter about which passwords to try first, which is why the variants below matter more than the textbook definition.

Dictionary attacks, spraying and stuffing

  • Dictionary attack. Tries likely passwords first: common words, leaked password lists and their usual variations.
  • Password spraying. Tries one or a few common passwords against many accounts, staying under per-account limits.
  • Credential stuffing. Tries username and password pairs leaked from other sites; see credential stuffing.
  • Reverse brute force. Starts from one known password and looks for an account that uses it.

The difference decides what catches them. Attempts concentrated on one account show up in per-account counts; spraying and stuffing show up only in totals per source and in the ratio of failures to successes.

WHICH DEFENCE SEES WHICH VARIANT PER-ACCOUNT LIMIT PER-SOURCE LIMIT SECOND FACTOR BRUTE FORCE / DICTIONARY PASSWORD SPRAYING CREDENTIAL STUFFING // a second factor is the only column that catches all three
// three variants, and the one defence that catches all of them

What it looks like in your logs

A burst of failed sign-ins is the obvious sign. The quieter signs matter more: a steady rate of failures across many accounts, failures from hosting ranges rather than from homes and phones, usernames that do not exist on your site, and a success that follows a long run of failures from the same source.

That last pattern deserves an alert of its own. A success after many failures is a likely compromise, and the account should be checked before its owner notices.

Why brute force still works

Brute force succeeds because people reuse and choose predictable passwords, and because many sign-in forms answer an unlimited number of attempts at full speed. Lists of leaked passwords give attackers the likely guesses first, so a weak password falls in minutes, not years.

Each part of that is fixable. Limits remove the unlimited attempts, breached-password checks remove the likely guesses, and a second factor makes a correct guess insufficient on its own.

How to prevent brute force attacks

  1. Add a second factor. Multi-factor authentication defeats a guessed password; the OWASP Authentication Cheat Sheet puts it first.
  2. Throttle failed attempts. Slow down or delay after failures without hard lockouts. NIST SP 800-63B section 5.2.2 sets a ceiling of 100 consecutive failed attempts per account and lists ways to avoid locking real users out.
  3. Limit per source as well as per account. Spraying and stuffing stay under per-account limits; choosing the subject of a limit explains the trade.
  4. Refuse known-bad passwords. Check new passwords against breached and common password lists.
  5. Answer every outcome the same way. Identical responses for wrong user and wrong password stop attackers from learning which usernames exist.

Hard lockout is the measure to use carefully: anyone who knows a username can then lock its owner out on purpose. CAPTCHA is one way to slow attempts; it costs real users, so it belongs after other signals, not on every sign-in.

Brute force outside the web layer

The same attack runs against remote-access services such as SSH and remote desktop. Those connections never reach a web application, so a request filter does not see them; they are protected with keys instead of passwords, network restrictions and the service's own attempt limits.

Questions

What is a brute force attack?

A brute force attack is an attempt to break into an account by trying passwords until one works. It targets sign-in forms and authentication APIs and relies on the service answering every attempt.

What is a dictionary attack?

A dictionary attack is a brute force attack that tries likely passwords first, from lists of common and leaked passwords, instead of every possible combination.

How do I stop brute force attacks on my login page?

Add a second factor, throttle failed attempts per account and per source, refuse known-bad passwords, and give the same response for every failure. Avoid hard lockouts that let anyone lock an owner out.

Is brute force the same as credential stuffing?

No. Brute force guesses passwords for an account; credential stuffing tries username and password pairs leaked from other sites. They are caught by different limits.