Join our Newsletter — 33% off our NHI Course
Home› Guides› How to detect password spraying in Entra ID…
Guide Identity Visibility, Posture & Threat Detection

How to detect password spraying in Entra ID sign-in logs with KQL: Queries, error codes and risk signals that catch a spray

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 15 November 2026 13 min read
On this page

A password spray tries one or two common passwords against hundreds of accounts, so no single account fails often enough to lock, and per-user alerts stay silent. The evidence is still in Microsoft Entra ID: it sits across accounts, in the sign-in logs, as clusters of the same error code from the same network, user agent or application. This guide is the detection engineering runbook for Entra ID: which log tables to query, which ResultType codes mean a guessed password versus a wrong one, KQL you can adapt for Microsoft Sentinel or Log Analytics, the Identity Protection signals that confirm a hit, and how to tune the rules. It is for SOC analysts and detection engineers. Prevention and the wider attack are covered in the Password Spraying and Credential Stuffing Defence Guide, and what to do once a spray is confirmed is in the Password Spraying Attack Response Playbook.

This is an independent guide from NHI Mgmt Group, based on Microsoft's public documentation as of November 2026. It is not sponsored or reviewed by Microsoft. Product features change, so confirm settings against Microsoft's current documentation.

Key takeaways

  • Count accounts, not attempts: the signal is many distinct user principal names failing from one IP address, autonomous system or user agent in a short window. Microsoft's Sentinel rule alerts at five accounts failing from one IP against one application within 20 minutes.
  • Query both sign-in tables: sprays against legacy protocols and token endpoints often land in AADNonInteractiveUserSignInLogs, not only SigninLogs. A rule that reads one table misses half the attack.
  • Some "failures" mean the password was right: ResultType 50074, 50076, 50079 and 53003 occur after the password has been accepted. From a spraying source, they mean a password compromise, even though no token was issued.
  • Identity Protection fires on success only: the passwordSpray risk detection needs Microsoft Entra ID P2 and is raised when the attacker validates a password, not for failed attempts, so you still need your own failure-pattern rule.
  • Low and slow sprays defeat IP rules: residential proxies rotate addresses, so aggregate by autonomous system number, user agent and application over days, and look for regular timing and address-book ordering.

What a spray looks like in the logs

Microsoft's password spray investigation playbook lists the patterns to look for. Turn each into a field you can group by:

Indicator (Microsoft playbook)Sign-in log fieldHow to use it
Large number of failed sign-ins across accountsResultType, UserPrincipalNamedcount(UserPrincipalName) per source and time bin
Repetitive user agent, target application, IP block or locationUserAgent, AppDisplayName, IPAddress, AutonomousSystemNumber, LocationDetailsGroup by each; a spray tool tends to reuse one user agent and one application
Failures in address-book (GAL) orderUserPrincipalName sorted by TimeGeneratedAlphabetical progression through accounts from one source
Regular timing between attemptsTimeGeneratedLow variance in the gap between attempts from one source
Correct password followed by failed MFAResultType 50074 or 50076, AuthenticationRequirementPassword compromise: high priority
Quick sign-in and sign-out in the same secondSuccess followed by sign-outA guessed password being tested
Legacy protocol useClientAppUsedAny value other than Browser or Mobile Apps and Desktop clients deserves scrutiny

Legacy authentication matters most: Microsoft's Conditional Access documentation states that more than 99% of password spray attacks it analysed use legacy authentication protocols, which cannot do MFA. Federated tenants are different: for a domain federated to AD FS, failed passwords stay in the identity provider and only successful sign-ins appear in Entra, so collect AD FS events 411 and 342 (bad credentials), 516 (extranet lockout) and, on AD FS 2016 and later, 1203 (fresh credential validation error), with the audit level set to Verbose.

ResultType codes that drive the rules

ResultType is a string column in SigninLogs; 0 is success. Group the codes by what they tell you about the guessed password:

CodeMicrosoft meaningPassword correct?Use in spray detection
50126InvalidUserNameOrPasswordNoCore failure code; some volume is normal from user typos
50053IdsLocked (smart lockout), or sign-in blocked from an IP with malicious activityUnknownCheck the Failure reason: a malicious-IP block is Microsoft already seeing the source
50034UserAccountNotFoundNot applicableSprays built from guessed or scraped name lists hit accounts that do not exist
50055 / 50144Password expired (cloud / on-premises AD)Yes, but expiredCounts as a guessed password on a stale account
50057UserDisabledUnknownDisabled accounts in the target list suggest an old directory dump
50074 / 50076Strong authentication required; user did not pass, or must use MFAYesPassword compromise stopped by MFA: reset the password
50079Strong authentication enrolment requiredYesWorst case: attacker may be offered MFA registration
53003BlockedByConditionalAccessYes (Conditional Access runs after first factor)Password compromise stopped by policy
0SuccessYesAccount compromise: escalate immediately

Microsoft's own Sentinel rule treats 50053, 50126 and 50055 as the failure set and a long list including 50074, 50076, 50079, 50158 and 53003 as "success" codes for the same reason: each shows the password was accepted. The codes behind conditional blocks are covered in the Conditional Access Block Troubleshooting Guide (AADSTS53003), and the wider code set in the Entra ID Sign-In and Audit Log Detection Guide.

Step 1: get the right data in

  1. Stream both user sign-in tables: in Entra diagnostic settings, send SignInLogs and NonInteractiveUserSignInLogs to the Log Analytics workspace behind Sentinel. Add RiskyUsers and UserRiskEvents if you have P2.
  2. Keep at least 30 days, ideally 90: low and slow sprays stretch over weeks, and a baseline of normal failure rates per application needs history.
  3. Add AD FS if federated: forward the AD FS Security log events listed above, or the failures will never reach Entra.
  4. Test ingestion: fail a sign-in on a test account through a browser and once through a non-interactive client, and confirm each arrives in the table you expect with ResultType 50126.

Step 2: the core KQL detections

These are starting points. Column names follow the Azure Monitor table reference; confirm them and the values in your own workspace before enabling, since connectors and schemas change.

Many accounts failing from one IP

let window = 20m;
let accountThreshold = 5;
union isfuzzy=true SigninLogs, AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(1d)
| where ResultType in ("50126", "50053", "50034")
| summarize Accounts = dcount(UserPrincipalName), Attempts = count(),
    Apps = make_set(AppDisplayName, 10), Agents = make_set(UserAgent, 5),
    ClientApps = make_set(ClientAppUsed, 5)
    by IPAddress, bin(TimeGenerated, window), Type
| where Accounts >= accountThreshold
| order by Accounts desc

The thresholds mirror the defaults in Microsoft's "Password spray attack against Microsoft Entra ID application" analytics rule (five accounts, 20 minute window). That rule also discards IPs where more accounts succeed than fail, which removes busy shared egress points such as your own proxies.

Low and slow: aggregate by network and user agent

union isfuzzy=true SigninLogs, AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(7d)
| where ResultType in ("50126", "50053", "50034")
| summarize Accounts = dcount(UserPrincipalName), Attempts = count(),
    IPs = dcount(IPAddress), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
    by AutonomousSystemNumber, UserAgent
| extend AttemptsPerAccount = round(todouble(Attempts) / Accounts, 1)
| where Accounts >= 20 and AttemptsPerAccount <= 3
| order by Accounts desc

Many accounts, few attempts each and many IPs within one network or user agent is the shape of a spray through rotating proxies. Microsoft's Midnight Blizzard guidance for responders makes the point directly: with residential proxies, blocking indicator IP addresses is not enough. The 20-account threshold is ours; set it from your baseline.

Did the spray work?

let sprayIPs =
    union isfuzzy=true SigninLogs, AADNonInteractiveUserSignInLogs
    | where TimeGenerated > ago(1d)
    | where ResultType in ("50126", "50053", "50034")
    | summarize Accounts = dcount(UserPrincipalName) by IPAddress
    | where Accounts >= 5
    | project IPAddress;
union isfuzzy=true SigninLogs, AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(1d)
| where IPAddress in (sprayIPs)
| where ResultType in ("0", "50074", "50076", "50079", "53003", "50055", "50144")
| project TimeGenerated, UserPrincipalName, IPAddress, ResultType, AppDisplayName,
    ClientAppUsed, ConditionalAccessStatus, AuthenticationRequirement, Type

Every row is either a compromised account (ResultType 0) or a compromised password. This query is the one to page on. Microsoft's playbook orders the follow-up the same way: successful sign-ins from attacker IPs first, then interrupted sign-ins (MFA challenges), then failures, then successes from other unknown IPs.

Legacy protocol sprays

union isfuzzy=true SigninLogs, AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(1d)
| where ClientAppUsed !in ("Browser", "Mobile Apps and Desktop clients", "")
| summarize Failures = countif(ResultType != "0"), Successes = countif(ResultType == "0"),
    Accounts = dcount(UserPrincipalName) by ClientAppUsed, IPAddress
| where Accounts >= 5

If a Conditional Access policy already blocks legacy authentication, these attempts show 53003 with the password evaluated first, so they still tell you which passwords are known. See the Legacy Authentication and ROPC Retirement Guide.

Step 3: add Identity Protection signals

Microsoft Entra ID Protection adds detections built on Microsoft's own telemetry. The ones that matter for spraying:

DetectionriskEventTypeTimingLicence (Microsoft docs)
Password spraypasswordSprayReal-time or offlineP2
Microsoft Entra threat intelligenceinvestigationsThreatIntelligenceReal-time or offlineFree or P1
Anonymous IP addressanonymizedIPAddressReal-timeFree or P1
Unfamiliar sign-in propertiesunfamiliarFeaturesReal-timeP2
Malicious IP addressmaliciousIPAddressOfflineP2
Atypical travelunlikelyTravelReal-timeP2

Availability: Microsoft documents that without P2, premium detections appear as "Additional risk detected" (generic) without detail.

AADUserRiskEvents
| where TimeGenerated > ago(7d)
| where RiskEventType in ("passwordSpray", "investigationsThreatIntelligence", "unfamiliarFeatures")
| project TimeGenerated, UserPrincipalName, RiskEventType, RiskLevel, RiskState,
    DetectionTimingType, IpAddress, CorrelationId

Join on CorrelationId back to the sign-in to see which application and client the attacker used. Because passwordSpray fires only when the password was validated, treat every instance as at least a password compromise. Offline detections can arrive hours later, so do not close a spray incident until the offline window has passed.

Step 4: tune before you page anyone

  • Known shared egress: VPN concentrators, secure web gateways and office NAT addresses show many users failing on a Monday morning. Keep them in a watchlist and raise their threshold rather than excluding them: attackers spray through compromised internal hosts too.
  • Smart lockout noise: smart lockout locks after 10 failures in commercial tenants (3 in US Government) for 60 seconds at first, tracks familiar and unfamiliar locations separately, and ignores repeats of the last three bad passwords. Expect 50053 bursts from real users after a password change; they come from familiar locations and one account at a time.
  • Applications with stale stored passwords: a mail client or script retrying an old password produces steady 50126 for one account from one device. One account is not a spray; route it to the help desk view, not the SOC.
  • Penetration tests: agree source IPs and a time window in advance, and tag them rather than suppress the rule.
  • Run in report mode for two weeks: create the analytics rules with incidents off, review every result with the identity team, then enable incident creation for the "did it work" rule first.

Triage a spray alert

  1. Scope the source: list every account the IP, ASN or user agent touched, with the ResultType for each. Those with 0, 50074, 50076, 50079, 53003, 50055 or 50144 go on the compromised-password list.
  2. Check privilege: any privileged role holder, break-glass account or user-based service account on that list is a major incident.
  3. Follow successes: for ResultType 0, pull the session's later activity: audit log changes, new authentication methods, mailbox rules, OAuth consents.
  4. Hand over: containment, password resets and blocking follow the Password Spraying Attack Response Playbook; this guide stops at detection.

Where identity fits: service accounts in a spray

User accounts used as service accounts are the usual winners of a spray: they rarely have MFA, are often excluded from Conditional Access and keep the same password for years. Microsoft's Conditional Access guidance notes that user-scoped policies do not block service principal calls and recommends Conditional Access for workload identities and managed identities instead. Run the "did it work" query filtered to your service account watchlist and treat any hit as critical. To find the accounts first, see How to Find Accounts Excluded From MFA and Conditional Access.

Measures that show it is working

  • Coverage: share of user sign-in volume from both tables, plus AD FS where federated, reaching the SIEM (target 100%).
  • Time to detect: minutes from the first failure in a spray to an incident, measured on a planned test.
  • Compromised passwords per spray: accounts with a password-accepted code from a spraying source; trend it after blocking legacy authentication and banning common passwords.
  • False positive rate: share of spray incidents closed as benign; when it rises above the target you agreed, retune thresholds or egress watchlists.
  • Legacy authentication attempts: volume of non-browser, non-modern client sign-ins, which should fall to near zero.

Common failure patterns

  • Interactive table only: the rule reads SigninLogs while the spray hits a non-interactive or legacy endpoint.
  • Treating 53003 and 50076 as blocked, so safe: the password worked. Without a reset, the attacker keeps it for a weaker path, such as an excluded account or legacy protocol.
  • Relying on Identity Protection alone: it raises passwordSpray only on a validated password and needs P2, so failed sprays and the early phase go unseen.
  • IP blocklists as the main control: residential proxy sprays rotate addresses faster than lists update.
  • Federated tenant, no AD FS logs: Entra shows only successes, so the spray looks like a handful of normal sign-ins.
  • Per-account thresholds: "more than 10 failures for one user" is a brute-force rule and will never fire on a spray.

Framework mapping

FrameworkReferenceRelevance
MITRE ATT&CKT1110.003 Password Spraying; T1078.004 Valid Accounts: Cloud AccountsThe technique detected, and the use of the account it yields
MITRE ATT&CK mitigationsM1032 Multi-factor Authentication; M1036 Account Use Policies; M1027 Password PoliciesControls that turn a guessed password into a blocked one
NIST SP 800-53 Rev 5AC-7 Unsuccessful Logon Attempts; SI-4 System Monitoring; AU-6 Audit Record Review, Analysis, and ReportingLockout, monitoring and log review
NIST CSF 2.0DE.CM-03; DE.AE-02Monitoring account activity and analysing adverse events
CIS Controls v8.1Control 8 Audit Log Management; Safeguard 6.3 Require MFA for Externally-Exposed ApplicationsCollection and the control that blunts a spray
ISO/IEC 27001:2022 Annex AA.8.15 Logging; A.8.16 Monitoring activities; A.5.17 Authentication informationLogging, monitoring and password quality

Practitioner checklist

  • Stream SignInLogs and NonInteractiveUserSignInLogs to the SIEM and keep 90 days.
  • Forward AD FS events 411, 342, 516 and 1203 at Verbose audit level if any domain is federated.
  • Deploy a distinct-accounts-per-IP rule across both tables (start at five accounts in 20 minutes).
  • Add a seven-day ASN and user agent rule for low and slow sprays.
  • Page on any password-accepted code (0, 50074, 50076, 50079, 53003) from a spraying source.
  • Ingest AADUserRiskEvents and alert on passwordSpray where P2 is licensed.
  • Watchlist shared egress IPs and raise their thresholds instead of excluding them.
  • Block legacy authentication with Conditional Access and trend the remaining attempts.
  • Test the rules with a planned, authorised exercise and record time to detect.

Standards and references

Related NHI Mgmt Group resources: Password Spraying and Credential Stuffing Defence Guide · Account Lockout and Brute-Force Protection Guide · KQL for Threat Hunting Guide · Microsoft Sentinel Guide · Entra ID Sign-In and Audit Log Detection Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 15 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.