Password spraying in Microsoft 365: detect it in sign-in logs
How to detect password spraying in Microsoft 365 from Entra ID sign-in logs: the error codes to filter, KQL that finds who got through, and what to do next.
Smart lockout started firing for a dozen users overnight, or a client forwarded a screenshot of failed sign-ins from countries they have never done business in. Nobody's account has the same pattern twice, and each user only failed two or three times. That shape is password spraying in Microsoft 365: one or two common passwords tried against many accounts, slowly enough to stay under the lockout threshold.
The failures themselves are not the problem. The problem is the one account in the list where the password was right. This guide shows how to find the spray in Entra ID sign-in logs, and more importantly, how to find who got through.
What does password spraying look like in Entra ID sign-in logs?
Open the Microsoft Entra admin center, go to Monitoring & health > Sign-in logs, filter Status to Failure and widen the date range to at least 7 days. A spray rarely stands out in a one-hour view. It stands out when you sort by IP address or user agent and see the same source touching 40 different users with one or two attempts each.
The signals that separate a spray from ordinary typos:
- Many users, few attempts each. A user who mistypes fails three times in a row and then succeeds. A spray fails once or twice per user and never comes back for that user that day.
- Usernames that do not exist. Error
50034means the account is not in your directory. A cluster of those means the attacker built the list from guesses or a scraped employee list, likej.smith@when your format isjohn.smith@. - Legacy or scripted clients. Client app values such as Authenticated SMTP, Exchange ActiveSync or Other clients, and user agents like
BAV2ROPCor a bare HTTP library string. Real users sign in with a browser or Outlook. - Regular timing. Attempts at a steady interval across the tenant, often one round per password, hours apart.
Which error codes matter?
The Error code column (ResultType in KQL) tells you more than the IP does. Some codes mean the attempt failed. Others mean the password was correct and something else stopped the attacker.
| Code | Meaning | Read it as |
|---|---|---|
50126 | Invalid username or password | The bulk of a spray. Wrong guess. |
50034 | User account does not exist in the directory | Attacker is guessing account names |
50053 | Account locked (smart lockout), or sign-in from a blocked IP | The spray hit the threshold for this user |
50057 | Account disabled | A leaver's account is on their list |
50076 / 50074 | Strong authentication (MFA) required | Password was correct. MFA stopped them. |
500121 | Strong authentication failed | Password was correct. They tried MFA. |
53003 | Blocked by Conditional Access | Password was correct. A policy stopped them. |
0 | Success | Compromised account. Start incident response. |
This is where people go wrong. They see 50076 next to a spray IP, read "failure", and close the ticket because MFA held. But that user's password is now known to the attacker, and the attacker will try it against anything that does not enforce MFA: legacy protocols, a VPN, a third-party app with its own login. Treat every one of those as a password reset.
Rule of thumb: after a spray, the list you act on is not the 400 failures. It is the handful of users with 0, 50074, 50076, 500121 or 53003 from the same sources.
How do I detect password spraying in Microsoft 365 with KQL?
If the tenant sends sign-in logs to Sentinel or a Log Analytics workspace, this query finds sources that failed against many distinct users. Start with a threshold of 10 users per hour and tune it after you see your own baseline.
SigninLogs
| where TimeGenerated > ago(7d)
| where ResultType in ("50126", "50034", "50053")
| summarize Attempts = count(),
Users = dcount(UserPrincipalName),
SampleUsers = make_set(UserPrincipalName, 20),
UserAgents = make_set(UserAgent, 5)
by IPAddress, bin(TimeGenerated, 1h)
| where Users >= 10
| order by Users desc
Then the query that matters, the one that finds the accounts the spray got through on:
let sprayIPs = SigninLogs
| where TimeGenerated > ago(7d)
| where ResultType in ("50126", "50034")
| summarize Users = dcount(UserPrincipalName) by IPAddress
| where Users >= 10
| project IPAddress;
SigninLogs
| where TimeGenerated > ago(7d)
| where IPAddress in (sprayIPs)
| where ResultType in ("0", "50074", "50076", "500121", "53003")
| project TimeGenerated, UserPrincipalName, IPAddress, ResultType,
ResultDescription, AppDisplayName, ClientAppUsed, UserAgent
| order by TimeGenerated asc
Run it against AADNonInteractiveUserSignInLogs as well if you collect that table. Depending on the client and protocol, some attempts land there instead of the interactive log, and a spray that only shows up in one table is easy to miss.
Why grouping by IP is not enough
Many sprays now come through residential proxy networks or rotating cloud IPs, so each address only tries a few users and never crosses your threshold. When the IP view looks clean but the lockouts keep coming, flip the grouping. Count distinct users failing with 50126 per hour across the whole tenant, or group by UserAgent instead of IPAddress. A tenant of 200 people that suddenly has 80 distinct users failing in the same hour is being sprayed, wherever the traffic comes from.
Also widen the window. A careful attacker tries one password per round and waits hours between rounds so smart lockout never triggers. In a one-day view that looks like scattered noise. Over a week, the same user agent hitting the same user list at the same few times each day is hard to miss.
If the tenant has Entra ID P2, check ID Protection's risk detections too. It has a dedicated Password spray detection, calculated offline, so it can show up after you have already started looking.
What should I do after a password spray?
- Reset the passwords of every user from the second query, including the MFA-blocked ones.
- Revoke their sessions so any token already issued stops working:
Connect-MgGraph -Scopes "User.ReadWrite.All" Revoke-MgUserSignInSession -UserId "anna.lee@contoso.com" - For any
0success, check what the session did: new MFA methods registered, inbox rules, OAuth consents, mail sent. The audit log entry for added security info is the one attackers rely on to keep access. The MFA fatigue guide covers what to do when a user approved a prompt they should not have. - Close the door the spray used. If the attempts came in over SMTP AUTH, ActiveSync or ROPC, follow blocking legacy authentication in Microsoft 365. Legacy protocols skip MFA, so a correct password there is a full compromise.
- Add a custom banned password list in Entra Password Protection with your company name, product names and city. Sprays almost always use seasonal and company-themed passwords.
Blocking the spray IPs with a named location in Conditional Access is fine as a short-term measure, but do not count on it. The next round will come from different addresses. Password resets and MFA coverage are what end it.
FAQ
Does smart lockout stop password spraying?
It slows it down. Smart lockout locks an account after a set number of failures (10 by default in the public cloud) and does not count the same wrong password twice. A spray that tries one or two passwords per user never reaches that limit, so lockout alone will not stop a patient attacker.
Why do I see failed sign-ins for users who have MFA?
The password check happens before MFA. An attacker can test passwords against any account and only meets the MFA prompt when the password is right. That is why 50076 next to a spray IP is bad news, not a success story.
How is this different from brute force?
Brute force is many passwords against one account, and lockout catches it quickly. Spraying is a few passwords against many accounts, which is why you have to look across users, not at one user's history. On-premises, the same pattern shows up in Windows failed logon events.
Can I find the password the attacker used?
No. Entra ID does not log attempted passwords, by design. What you can see is which users had the right password, and that is enough to act on.
M365 Sign-in Review flags password spraying, legacy auth, MFA fatigue and impossible travel from an Entra ID sign-in export, in your browser.
The Microsoft 365 Security Audit Kit has a control-by-control checklist covering MFA, Conditional Access, legacy authentication and mail security, plus an audit script. $39, one-time.
IOC Triage, our free browser extension: right-click a sign-in IP for a verdict from 15 threat-intel sources, then copy a ticket note.