Inbound Sender Domains Failing Email Authentication


Description

This query lists inbound sender domains with the most email authentication failures (DMARC, DKIM, SPF, and Composite Authentication), using the EmailEvents table.

Query · kql

// Inbound sender domains with the most email authentication failures (DMARC, DKIM, SPF, Composite Authentication).
EmailEvents
| where Timestamp > ago(30d)
| where OrgLevelPolicy !in ("Phishing simulation", "SecOps Mailbox")
| where EmailDirection == "Inbound"
| extend Key = strcat(NetworkMessageId, '-', RecipientEmailAddress)
| summarize arg_max(Timestamp, *) by Key
| extend Auth = parse_json(AuthenticationDetails)
| summarize TotalInbound = count(), MessagesFailingAnyAuth = countif(tostring(Auth.DMARC) == "fail" or tostring(Auth.DKIM) == "fail" or tostring(Auth.SPF) == "fail" or tostring(Auth.CompAuth) == "fail"), DMARCFail = countif(tostring(Auth.DMARC) == "fail"), DKIMFail = countif(tostring(Auth.DKIM) == "fail"), SPFFail = countif(tostring(Auth.SPF) == "fail"), CompAuthFail = countif(tostring(Auth.CompAuth) == "fail") by SenderDomain = SenderFromDomain
| where MessagesFailingAnyAuth > 0
| top 20 by MessagesFailingAnyAuth
| project SenderDomain, MessagesFailingAnyAuth, DMARCFail, DKIMFail, SPFFail, CompAuthFail, TotalInbound
Raw source Inbound Sender Domains Failing Email Authentication · KQL
Esc
Published by Azure/Azure-Sentinel ↗, licensed under MIT ↗. Reproduced here unmodified.
id: 5722f6ce-0ac1-4783-9e15-3f7e390abe01
name: Inbound Sender Domains Failing Email Authentication
description: |
  This query lists inbound sender domains with the most email authentication failures (DMARC, DKIM, SPF, and Composite Authentication), using the EmailEvents table.
description-detailed: |
  Email authentication failures (DMARC, DKIM, SPF, and Composite Authentication) are a leading indicator of spoofing and Business Email Compromise (BEC). This query counts inbound messages that failed each authentication check, grouped by sender domain, and ranks domains by the number of messages that failed any check, with the total inbound volume for context. Persistent authentication failures from a domain that should be sending legitimate mail warrant investigation, and confirmed external spoofers are candidates for blocking.
  This query is part of the Microsoft Defender for Office 365 Detections and Insights workbook in Microsoft Sentinel: https://techcommunity.microsoft.com/blog/microsoftdefenderforoffice365blog/part-3-build-custom-email-security-reports-with-power-bi-and-workbooks-in-micros/4490127
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - EmailEvents
tactics:
  - InitialAccess
relevantTechniques:
  - T1566
query: |
  // Inbound sender domains with the most email authentication failures (DMARC, DKIM, SPF, Composite Authentication).
  EmailEvents
  | where Timestamp > ago(30d)
  | where OrgLevelPolicy !in ("Phishing simulation", "SecOps Mailbox")
  | where EmailDirection == "Inbound"
  | extend Key = strcat(NetworkMessageId, '-', RecipientEmailAddress)
  | summarize arg_max(Timestamp, *) by Key
  | extend Auth = parse_json(AuthenticationDetails)
  | summarize TotalInbound = count(), MessagesFailingAnyAuth = countif(tostring(Auth.DMARC) == "fail" or tostring(Auth.DKIM) == "fail" or tostring(Auth.SPF) == "fail" or tostring(Auth.CompAuth) == "fail"), DMARCFail = countif(tostring(Auth.DMARC) == "fail"), DKIMFail = countif(tostring(Auth.DKIM) == "fail"), SPFFail = countif(tostring(Auth.SPF) == "fail"), CompAuthFail = countif(tostring(Auth.CompAuth) == "fail") by SenderDomain = SenderFromDomain
  | where MessagesFailingAnyAuth > 0
  | top 20 by MessagesFailingAnyAuth
  | project SenderDomain, MessagesFailingAnyAuth, DMARCFail, DKIMFail, SPFFail, CompAuthFail, TotalInbound
version: 1.0.0

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.