Alright class.
Today it is "Distributed password cracking attempts in Microsoft Entra ID". The rule counts failed password attempts per user across the sign-in logs and fires when one account crosses thirty failures from three or more locations. The intent is right, a single account being hammered from many places is a real attack. Two choices undermine it: what the rule treats as a location, and which failures it agrees to count. Fix those and add weighting, and the noise drops away.
Three Cities Is Not Distributed
The rule builds a location string from country, state and city, and the gate is three distinct ones. The problem is that three distinct cities is not distributed activity, it is a Tuesday (or sometimes Thursday)
IP geolocation at city level is noisy, especially on mobile. A single phone on cellular can geolocate to several cities in a day as it moves between carrier exit points, without the user going anywhere. A VPN user surfaces in whatever cities their provider's nodes sit in. A normal person on office wifi, home broadband and a phone is already three locations with no travel at all. So the gate is satisfied constantly by ordinary multi-device life, and if one of those devices is holding a stale password and retrying, the failure count climbs too.
The thing that actually measures distribution is the number of distinct source IPs, and to a lesser degree the number of distinct countries. The original even computes the IP count, then never gates on it. A handful of IPs is a person with a few devices. Ten, thirty, a hundred distinct IPs failing against one account is a botnet or a proxy pool. Count the sources, not the cities.
Expired Is Not Cracked
The rule counts four error codes as password cracking: 50126, 50053, 50056 and 50055. Three of those belong. The fourth does not.
50055 is an expired password. It means the password was correct and has aged out, which is the legitimate user, or more often their device, hitting the wall at a rotation deadline. It clusters benignly every time a password policy forces a change and a phone keeps trying the old one until someone updates it. Counting it as cracking guarantees a wave of false positives timed to your rotation schedule. Drop it. What is left is the real signal: 50126 the wrong password, 50056 a null or invalid password, and 50053 the account being locked because too many wrong passwords were tried.
Weight the Distribution, Do Not Flat-Threshold It
The original's whole decision is two flat numbers, thirty failures and three locations. Flat thresholds cannot tell a wide attack from a busy mailbox, and the right number is different in every tenant. Weight the evidence instead, so the degree of the attack drives the result. Each signal adds to a score, nothing short-circuits, and the rule fires above a threshold:
- The failures come from a moderately wide set of IPs, ten or more: weight 3
- They come from a very wide set, thirty or more: a further weight 2, so a large spread stands on its own.
- They span three or more countries: weight 3.
- The account was locked by the attempts (50053): weight 2.
- Entra ID Protection scored one of the failed sign-ins medium or high: weight 3.
- The targeted account is privileged: weight 2.
- The account is a guest: weight 1.
A modest gate, enough failures from at least a few IPs, sets candidacy. The score then decides what pages. A handful of IPs from one country with nothing else stays quiet, the VPN user with a stale password does not clear the bar, and a spread across ten or thirty IPs, or across countries with a lockout, climbs straight to the top.
The RiskIndicators Field and the Score
The query carries both. The numeric Score drives firing, severity and sort order. The RiskIndicators string carries the same signals for the analyst:
WideIPSpread | IPSpread | CountrySpread | AccountLockout | HighRiskSignIn | PrivilegedTarget | GuestTarget
The combination to chase is WideIPSpread with CountrySpread and AccountLockout, or any of those against a PrivilegedTarget: one account taking a sustained beating from a wide, geographically spread set of sources.
The Blind Spot You Should Know About
This detects distribution. A determined brute force from a single IP will not surface here, that is a concentrated-failure rule on its own. A slow and low attack that stays under the failure floor also slips by, so if you want those, lower the floor and accept more noise.
And this rule does not claim the cracking succeeded. A success mixed in among the failures is not asserted as compromise, because the benign case, a user fixing a stale password on their own device so it finally signs in, looks identical to an attacker IP that guessed right. Telling those apart needs a baseline of the user's known-good IPs, which is a different detection. This rule stops at the attempt (as the name implies) so you can decide if you need to do anything to harden your environment.
MITRE Mappings for the Updated Rule
Tactic: Credential Access, under T1110 Brute Force.
T1110.001 Password Guessing. Many password attempts against one known account, which is the core of the rule.
T1110.004 Credential Stuffing. The distributed shape, breached username and password pairs replayed against the account from many sources at once.
Rule Settings
Run query every 60 minutes. Lookup data from the last 14 days.
Alert per result. Group by Account entity with a 6 hour lookback, so the hourly re-evaluation of an attack still in progress collapses into one updating incident rather than a new one each run.
Entity mapping:
- Name to Account (Name), UPNSuffix to Account (UPNSuffix)
Custom details to surface in the incident: RiskIndicators, Score, FailedCount, DistinctFailIPs, DistinctCountries, LockoutCount, Countries, FailResultTypes, Apps, AssignedRoles, UserType.
KQL
// =====================================================================
// Distributed Password Cracking Attempts - Entra ID
// =====================================================================
// Description : One account taking credential-failure attempts (50126 / 50056 / 50053) from a
// distributed set of sources. Distribution is measured by distinct source IPs and
// countries rather than by city-level geolocation, the expired-password code 50055
// is excluded because it indicates a correct-but-expired credential, and the spread,
// lockout, sign-in risk and target privilege are weighted into a score.
// Type : Detection
//
// Tables : SigninLogs, AADNonInteractiveUserSignInLogs, IdentityInfo
// Connectors : Microsoft Entra ID (SignInLogs, NonInteractiveUserSignInLogs),
// Microsoft Sentinel UEBA (IdentityInfo)
// License : Microsoft Sentinel; Microsoft Entra ID P1 (sign-in logs),
// P2 recommended (sign-in risk, UEBA)
//
// Tuning : - DetectionWindow - the failure accumulation window; align to run frequency
// - VolumeFloor / IPFloorGate - candidacy floors for total failures and distinct IPs
// - ModerateIPThreshold / WideIPThreshold - the two IP-spread tiers
// - CountryThreshold - distinct countries that count as geographic spread
// - W_* weights and ScoreThreshold - shift these to fit your environment
// - SensitiveRoles - roles that mark the target as privileged
//
// Known FPs : - A multi-device user retrying a stale password - few IPs, no spread, scores below threshold
// - VPN users surfacing in several countries - needs a second signal to fire
// - Password rotation churn - excluded by dropping the expired-password code 50055
//
// Author : Bartosz Wysocki | https://www.itprofessor.cloud
// Version : 1.0 | 2026-06-17
// =====================================================================
let DetectionWindow = 1d;
let IdentityLookback = 14d; // full directory resync cycle; guarantees complete identity enrichment
let CredFailures = dynamic(["50126", "50053", "50056"]); // wrong password, locked by bad passwords, null password (50055 expired deliberately excluded)
let VolumeFloor = 20; // total credential failures to qualify as a candidate
let IPFloorGate = 3; // minimum distinct source IPs to be considered distributed
let ModerateIPThreshold = 10; // moderately wide IP spread
let WideIPThreshold = 30; // very wide IP spread
let CountryThreshold = 3; // distinct countries that count as geographic spread
let SensitiveRoles = dynamic([
"Global Administrator",
"Privileged Role Administrator",
"Privileged Authentication Administrator",
"Security Administrator",
"Exchange Administrator",
"SharePoint Administrator",
"User Administrator",
"Intune Administrator",
"Application Administrator",
"Hybrid Identity Administrator"
]);
// Scoring weights - the degree of distribution and the hard outcomes carry the most
let W_ModerateSpread = 3;
let W_WideSpread = 2;
let W_CountrySpread = 3;
let W_AccountLockout = 2;
let W_HighRisk = 3;
let W_Privileged = 2;
let W_Guest = 1;
let ScoreThreshold = 5;
// Credential failures (and successes, for context) from a sign-in table
let SignInActivity = (tableName:string) {
table(tableName)
| where TimeGenerated > ago(DetectionWindow)
| where ResultType == "0" or ResultType in~ (CredFailures)
| project TimeGenerated, UserPrincipalName = tolower(UserPrincipalName), IPAddress,
ResultType,
Country = tostring(LocationDetails.countryOrRegion),
AppDisplayName, RiskLevel = tostring(RiskLevelDuringSignIn)
| extend IsFailure = ResultType in~ (CredFailures)
};
let SignIns = union isfuzzy=true
SignInActivity("SigninLogs"),
SignInActivity("AADNonInteractiveUserSignInLogs");
// Identity context (privilege / guest), keyed on UPN
let IdentityContext = IdentityInfo
| where TimeGenerated > ago(IdentityLookback)
| summarize arg_max(TimeGenerated, AccountDisplayName, Department, JobTitle, AssignedRoles, UserType, IsAccountEnabled) by AccountUPN = tolower(AccountUPN);
SignIns
| summarize
StartTime = min(TimeGenerated),
EndTime = max(TimeGenerated),
FailedCount = countif(IsFailure),
DistinctFailIPs = dcountif(IPAddress, IsFailure),
DistinctCountries = dcountif(Country, IsFailure and isnotempty(Country)),
LockoutCount = countif(ResultType == "50053"),
HighRiskCount = countif(IsFailure and RiskLevel in ("high", "medium")),
FailIPs = make_set_if(IPAddress, IsFailure, 200),
Countries = make_set_if(Country, IsFailure, 50),
Apps = make_set_if(AppDisplayName, IsFailure, 50),
FailResultTypes = make_set_if(ResultType, IsFailure, 5)
by UserPrincipalName
| where FailedCount >= VolumeFloor and DistinctFailIPs >= IPFloorGate
| join kind=leftouter IdentityContext on $left.UserPrincipalName == $right.AccountUPN
| extend ModerateSpread = DistinctFailIPs >= ModerateIPThreshold
| extend WideSpread = DistinctFailIPs >= WideIPThreshold
| extend CountrySpread = DistinctCountries >= CountryThreshold
| extend AccountLockout = LockoutCount > 0
| extend HighRiskSignIn = HighRiskCount > 0
| extend IsPrivileged = tostring(AssignedRoles) has_any (SensitiveRoles)
| extend IsGuest = tostring(UserType) =~ "Guest"
| extend Score = toint(ModerateSpread) * W_ModerateSpread
+ toint(WideSpread) * W_WideSpread
+ toint(CountrySpread) * W_CountrySpread
+ toint(AccountLockout) * W_AccountLockout
+ toint(HighRiskSignIn) * W_HighRisk
+ toint(IsPrivileged) * W_Privileged
+ toint(IsGuest) * W_Guest
| where Score >= ScoreThreshold
| extend AlertSeverity = case(Score >= 9, "High", Score >= 6, "Medium", "Low") // Testing but feel free to use to figure out priorities (not that important)
| extend RiskIndicators = trim(@"\s\|\s*$", strcat(
iff(WideSpread, "WideIPSpread | ", iff(ModerateSpread, "IPSpread | ", "")),
iff(CountrySpread, "CountrySpread | ", ""),
iff(AccountLockout, "AccountLockout | ", ""),
iff(HighRiskSignIn, "HighRiskSignIn | ", ""),
iff(IsPrivileged, "PrivilegedTarget | ", ""),
iff(IsGuest, "GuestTarget | ", "")
))
| extend Name = tostring(split(UserPrincipalName, "@", 0)[0]), UPNSuffix = tostring(split(UserPrincipalName, "@", 1)[0])
| project
StartTime, EndTime, Score, AlertSeverity, RiskIndicators,
UserPrincipalName, Name, UPNSuffix,
FailedCount, DistinctFailIPs, DistinctCountries, LockoutCount, HighRiskCount,
Countries, FailIPs, Apps, FailResultTypes,
AccountDisplayName, Department, JobTitle, AssignedRoles, UserType
| sort by Score desc
Follow my repo - GitHub
What You Should Do Next
- Run it over in Logs blade and read what scores highest. Tune the floors, the spread tiers, and the weights down until the output is only real attacks. For testing you can widen DetectionWindow past the rule's limit in Logs, the deployed rule still caps at the lookup period.
- Set the IP floors to your size. A small tenant where ten source IPs against one account is extraordinary wants lower tiers than a large estate with heavy VPN and mobile use.
- Decide whether slow and low matters to you. The volume floor is there to keep the candidate set sane. Lower it to catch patient attacks, and watch the noise it brings before you commit.
Class dismissed