Brute-force attack
| Class | Authentication |
|---|---|
| Also known as | Password guessing (ATT&CK name) |
| CWE | CWE-307: Improper Restriction of Excessive Authentication Attempts; CWE-521: Weak Password Requirements |
| OWASP Top 10 | A07:2025 Authentication Failures |
| MITRE ATT&CK | T1110.001 Brute Force: Password Guessing |
| Affects | Sign-in, password-reset and one-time-code routes; SSH, RDP, VNC, MySQL and MSSQL logins |
A brute-force attack finds a password or code by trying many values in turn against a sign-in, usually against one account, with candidates taken from a dictionary or a list of common passwords.12 It works where the sign-in does too little to stop repeated failures in a short period and lets automated attempts run without quickly blocking them.34 Weak password requirements shorten the search.4
Description
Three attacks test passwords at scale, and they differ in what is held fixed.
| Attack | What is tried |
|---|---|
| Brute force | Many passwords from a dictionary or other source against one account |
| Credential stuffing | Username and password pairs from the breach of another site |
| password spraying | One weak password against many accounts |
Guesses follow patterns: Password1!, Password2!, Password3! and so on, or Winter2025 changed to Winter2026.4 The targets include SSH (port 22), RDP (3389), MySQL (3306), MSSQL (1433), VNC (5900), HTTP management services, single sign-on and Office 365. APT28 tooling in brute-force mode typically sent over 300 attempts per hour per targeted account, for hours or days.2
Mechanism
A login route compares the submitted password with the stored one and answers yes or no. If it answers every request at full speed, a script can send candidates from a list for anna@example.com until one succeeds. How long that takes depends on how many attempts the server allows and how many values the secret could have; a six-digit code has one million. NIST caps consecutive failures per authenticator at 100, a figure chosen to balance the chance of a correct guess, for example 100 attempts against a six-digit one-time code, against the need to recover accounts that the cap locks.5
Notable incidents
Twitter administrative panel (January 2009)
An 18-year-old who used the handle GMZ pointed an automated password guesser at the account of a Twitter support staff member, whose password was "happiness". Twitter allowed an unlimited number of rapid log-in attempts. His own tool tried English words and ran overnight; by his account he was in at about 11:00 a.m. Eastern on Monday. Twitter co-founder Biz Stone confirmed a dictionary attack. The panel let him reset any account holder's password, and Twitter put the number of high-profile accounts compromised at 33.6 CWE-307 uses the case as its first example, a server that placed no limit on how many times someone could try to log in.3
Detection
Every failed sign-in belongs in the log, with an alert to administrators when brute force is detected or suspected.4 One signal is a single IP address that has tried to sign in to several accounts.7
Prevention
No single defence protects completely; several together reach a reasonable level.1
Multi-factor authentication
A Microsoft analysis found that Multi-factor authentication would have stopped 99.9% of account compromises, which makes it by far the best defence against most password attacks.1
Limits per account
Count failed logins against the account, not the source address, so that sending from many addresses does not avoid the limit. A lockout has a threshold, an observation window and a duration; an exponential lockout starts at one second, for example, and doubles after each failure.1 A lockout can also be turned against other people: a policy that is too strict locks every account the attacker tried.2 The owner can still get in if the forgotten-password flow signs them in while the account is locked.1 NIST adds a bot-detection challenge, a wait that grows from 30 seconds up to an hour, and checks on address, location, timing and browser.5
Limits per address
A rate limit on the sign-in route slows an attacker with one address. Blocking IP addresses can be enough against less sophisticated attacks, but it is easy to get around and makes a poor main defence.7 The Express package express-rate-limit counts requests per IP address by default and answers 429; skipSuccessfulRequests uncounts 1xx to 3xx responses. The README applies one limiter to all routes with app.use(limiter); here it is passed to the sign-in route alone, with example values:8
import { rateLimit } from 'express-rate-limit'
const loginLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
limit: 10, // sign-in requests per address in the window
skipSuccessfulRequests: true,
standardHeaders: 'draft-8',
legacyHeaders: false,
})
app.post('/login', loginLimiter, loginHandler)On serverless hosting, @upstash/ratelimit keeps the count in Redis. Its identifier can be a user ID, an API key or an IP address; here it is the submitted email address, which counts per account.9
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
const ratelimit = new Ratelimit({
redis: Redis.fromEnv(), // UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN
limiter: Ratelimit.slidingWindow(10, "10 s"), // the docs' example; lower for sign-in
prefix: "@upstash/ratelimit",
});
const { success } = await ratelimit.limit(email);
if (!success) { return "Unable to process at this time"; }Supabase
Supabase Auth limits its token endpoint, which handles the PKCE, password, ID-token and refresh-token grants, to 150 requests per 5 minutes per IP address, with bursts up to 30, and answers 429 beyond that. The limits are under Authentication > Rate Limits. Behind a server-side framework, the user's address must be forwarded in the Sb-Forwarded-For header, with a secret API key, or Supabase counts the server's address.10 For a CAPTCHA, open Settings > Authentication > Bot and Abuse Protection > Enable CAPTCHA protection, choose hCaptcha or Cloudflare Turnstile, paste the secret key and press Save; the client then passes options: { captchaToken }.11
Vercel
WAF rate limiting is available on all plans. Open the project, choose Firewall, then Configure and + New Rule. Match the request path of the sign-in route, choose the action Rate Limit, then Review Changes and Publish. The default is 100 requests per 60 seconds, and Log shows the effect before a rule is enforced.12
Passwords
With multi-factor authentication, a password under 8 characters counts as weak; without it, one under 15 does. The maximum length should allow at least 64 characters, and common and previously breached passwords should be refused.1
Prompt for a coding agent
Find every sign-in, sign-up, password-reset and one-time-code route in this project. For each one, add a rate limit: count failed attempts per account as well as per IP address, allow only a small number in a 15 minute window, and return 429 when it is exceeded. Return the same error text whether or not the account exists. Keep the counters in a shared store such as Redis if the app runs on serverless hosting. List each file you changed and any route you left alone.
In SecFlash
SF-SEC-727 on the Security page reports a sign-in, sign-up, password-reset or one-time-code route that nothing limits. The Cloud page shows SF-CLD-533 for Supabase sign-up and login without a captcha, SF-CLD-307 for a Cloudflare zone with no rate limiting rule and SF-CLD-407 for a Vercel firewall that is off. An SSH server that accepts password logins appears as SF-SRV-201 on the Server page (see SSH brute-force attack). The Detections page flags many failed SSH logins from one address (SF-DET-401), SSH logins tried for many user names (SF-DET-402) and a login that succeeds after many failed tries (SF-DET-405).
See also
- Common types of attack on web applications
- Credential stuffing
- SSH brute-force attack
- Rate limiting
- Multi-factor authentication
- Category: Authentication
References
- a b c d e f "Authentication Cheat Sheet". OWASP Cheat Sheet Series.
- a b c "Brute Force: Password Guessing, T1110.001". MITRE ATT&CK. MITRE.
- a b "CWE-307: Improper Restriction of Excessive Authentication Attempts". Common Weakness Enumeration. MITRE.
- a b c d "A07:2025 Authentication Failures". OWASP Top 10:2025. OWASP Foundation.
- a b "NIST SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management". NIST.
- back Zetter, Kim (January 2009). "Weak Password Brings 'Happiness' to Twitter Hacker". Wired.
- a b "Credential Stuffing Prevention Cheat Sheet". OWASP Cheat Sheet Series.
- back "express-rate-limit". GitHub.
- back "Ratelimit: Getting started". Upstash Docs. Upstash.
- back "Rate limits". Supabase Docs. Supabase.
- back "Enable CAPTCHA Protection". Supabase Docs. Supabase.
- back "WAF Rate Limiting". Vercel Docs. Vercel.
External links
- Authentication Cheat Sheet, OWASP Cheat Sheet Series