Brute Force Followed by Success
A burst of failed sign-ins is an attempt. A burst of failed sign-ins followed by a success from the same place is, far more often, a compromise. That difference is why "brute force then success" is one of the first correlation rules every SOC writes: the threshold rule alone fires on every attack the defences already stopped, while the sequence rule fires on the ones that worked. This lesson tunes the window and thresholds in the lab, then writes the sequence rule in pandas for both per-account guessing and password spraying. The attacks themselves are described in Brute Force and Password Spraying and, for Active Directory, Password Spraying Against a Domain.
Tuning the threshold rules first
The lab runs the two building blocks on one hour of synthetic sign-ins: per account (at least A failures on one account within W minutes) and per source (failures on at least D distinct accounts from one source within W). Each alert suppresses repeats for the same key for W minutes.
Things to try:
- Defaults (W = 5, A = 10, D = 5): 4 alerts, 3 true positives (two alerts on the brute force against
admin, the first at 20.9 min, and one on the spray at 42.0 min) and 1 false positive on the VPN gateway, where four users mistyped at once; precision 75 %, recall 69 %. - W = 2: the spray, one guess every 30 s, never puts 5 accounts into 2 minutes, so it is missed (recall 50 %). Slow attacks hide under short windows.
- D = 3: the spray is caught a minute earlier (41.0 min), but the VPN gateway now produces two false alarms (precision 60 %).
- A = 5: the brute force is caught at 20.4 min, but heidi's forgotten password (8 failures in 3 minutes) becomes a false positive.
In the timeline, notice the ● right after the burst of ✕ on admin at minute 23: the attacker's successful sign-in. The threshold rules say nothing about it. That is the job of the sequence rule.
The sequence rule
Alert when an account has at least N failures and then a success within W minutes, from the same source; and when a source fails on at least D accounts and then any success follows from it within W.
import pandas as pd
rows = []
add = lambda m, user, src, ok: rows.append((pd.Timestamp("2026-01-15 09:00") + pd.Timedelta(minutes=m), user, src, ok))
for k in range(30): # brute force on admin, then success
add(20 + k * 0.1, "admin", "203.0.113.50", False)
add(23.1, "admin", "203.0.113.50", True)
for k in range(8): # heidi forgot her password, then reset it
add(32 + k * 0.4, "heidi", "192.0.2.10", False)
add(35.6, "heidi", "192.0.2.10", True)
for k, u in enumerate(["admin", "alice", "bob", "carol", "dave", "erin", "frank", "grace", "ivan", "judy"]):
add(40 + k * 0.5, u, "198.51.100.23", False) # spray: one guess per account ...
add(45.2, "ken", "198.51.100.23", True) # ... and ken's password was 'Winter2026'
for u in ["bob", "dave", "frank", "judy"]: # typos through the VPN, then success
add(10, u, "192.0.2.10", False); add(10.4, u, "192.0.2.10", True)
ev = pd.DataFrame(rows, columns=["time", "user", "src", "ok"]).sort_values("time", ignore_index=True)
W = pd.Timedelta(minutes=10)
def account_sequence(e, n=5):
out = []
for r in e[e.ok].itertuples(): # every success ...
prior = e[(e.user == r.user) & (e.src == r.src) & ~e.ok & (e.time < r.time) & (e.time >= r.time - W)]
if len(prior) >= n: # ... preceded by n failures
out.append((r.time, "brute force then success", r.user, r.src, f"{len(prior)} failures first"))
return out
def spray_sequence(e, d=5):
out = []
for r in e[e.ok].itertuples():
prior = e[(e.src == r.src) & ~e.ok & (e.time < r.time) & (e.time >= r.time - W)]
if prior.user.nunique() >= d:
out.append((r.time, "spray then success", r.user, r.src, f"{prior.user.nunique()} accounts failed first"))
return out
alerts = pd.DataFrame(account_sequence(ev) + spray_sequence(ev), columns=["time", "rule", "user", "src", "why"])
print(f"{len(ev)} sign-ins, {ev.ok.sum()} successes")
print(alerts.assign(time=alerts.time.dt.strftime("%H:%M:%S")).to_string(index=False))59 sign-ins, 7 successes
time rule user src why
09:23:06 brute force then success admin 203.0.113.50 30 failures first
09:35:36 brute force then success heidi 192.0.2.10 8 failures first
09:45:12 spray then success ken 198.51.100.23 10 accounts failed first
Three alerts from 59 sign-ins. Two are the attacks that worked: admin signed in from 203.0.113.50 after 30 failures, and ken signed in from the spraying source after ten other accounts had failed from it, so the spray found a weak password even though no single account had more than one failure. The VPN typos (one failure, then success) correctly stay silent. The third alert is heidi: 8 failures and then a success from the VPN gateway is exactly the pattern of a guessed password, and also of a user who forgot hers and reset it. The rule cannot tell them apart from sign-in events alone; the help desk's password-reset event between the failures and the success can. Joining that context is better than raising N until heidi disappears, because a real attacker needs no more failures than heidi did.
How it is detected in a SIEM
In Elastic EQL the account version is a direct sequence (sequence by user.name, source.ip with maxspan=10m [authentication where event.outcome == "failure"] with runs=5 [authentication where event.outcome == "success"]); in SPL a transaction or streamstats by user and source; in Sentinel KQL a join of failure counts with later successes on the same UserPrincipalName and IPAddress. Whatever the language, test it on the cases above: the brute force and the spray must alert, heidi and the VPN typos must not.
How the weakness is fixed
The sequence rule is the alarm for when prevention has already failed. Prevention:
- MFA, ideally phishing-resistant, on every externally reachable sign-in (VPN, mail, remote desktop gateways, SaaS). A guessed password alone then gets nothing, and the rule becomes "failures, then a success, then an MFA prompt the user didn't expect": still worth an alert, since the password is known.
- Rate limiting and smart lockout: slow down or temporarily block a source after repeated failures, and lock an account against unfamiliar sources only, so an attacker cannot lock users out deliberately.
- Banned-password lists: reject seasonal and company-name passwords (
Winter2026) at password change; spraying depends on them. - Remove exposure: no SSH or RDP open to the Internet; put remote administration behind a VPN or bastion (Insecure Remote Administration).
- Response: on a true positive, disable or reset the account, revoke its sessions, block the source, and look at everything the account did after the success.
Pitfalls
- Counting failures across sources for the account rule. Several users behind one NAT and an attacker elsewhere mix together; key the sequence on account and source, and run the spray rule separately.
- Ignoring successes via other protocols. The attacker may fail on the web portal and succeed over IMAP or an old API without MFA. Normalise all authentication sources into one table first.
- Lockout as the only control. It turns brute force into denial of service against your own users.
Practice
1. Move ken's successful sign-in to minute 52. Does the spray rule still fire with W = 10 minutes?
Yes. The look-back from 52.0 starts at 42.0 (inclusive) and contains the failures of dave (42.0), erin, frank, grace, ivan and judy (44.5): 6 distinct accounts, so it fires. At 52.5 it still sees 5 (erin to judy); a success after that leaves at most 4 accounts in the window, so the rule misses a sprayer who waits more than about 8 minutes after the last guess before using the password it found. Keep a second, longer window (hours) for the spray part, with a higher threshold.
2. Remove heidi's false positive without raising N. What data do you need, and what does the rule check?
The identity system's password-reset or unlock event (self-service reset, help-desk unlock). Rule: skip the alert if a reset or unlock event for the same user lies between the last failure and the success. Add a test case where the reset is missing, so that an attacker who simply guesses heidi's password still alerts.
3. Write the sequence rule's test cases as a table: event stream and expected result.
(a) 30 failures then success from one external source on admin: alert. (b) 10 accounts × 1 failure then a success on an 11th from the same source: spray alert. (c) 1 failure then success (typo): no alert. (d) 8 failures, a password-reset event, then success: no alert (with reset-awareness). (e) 5 failures on web then success on IMAP from the same source: alert (cross-protocol).
Practice problem in 21 languages: Brute-Force Login Alerts.
Test yourself
Why is 'failures followed by a success' more urgent than 'many failures'?
- It is not
- The success usually means the guessing worked: a likely compromise rather than an attempt
- Successes are rarer in logs
- It is easier to compute
In the lab with W = 2 minutes, why is the password spray missed?
- The spray stops
- One guess every 30 s puts at most 4 accounts in a 2-minute window, below D = 5
- The source is allow-listed
- The VPN hides it
Which key should the per-account sequence rule use?
- Only the user
- The user and the source address
- Only the time
- The password
Which control lets you stop sprays without letting attackers lock users out on purpose?
- Permanent lockout after 3 failures
- Smart lockout and rate limiting against unfamiliar sources, plus banned-password lists
- Disabling logging
- Longer usernames