← Back to SOC feed Coverage →

Impersonation and Spoof Detections by Sender Country

kql MEDIUM Azure-Sentinel
T1566
EmailEvents
huntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-09-03T23:00:00Z · Confidence: medium

Hunt Hypothesis

This hypothesis targets Business Email Compromise (BEC) attacks where adversaries leverage geographically inconsistent sender locations to impersonate trusted entities, aligning with MITRE technique T1566. Proactively hunting for these anomalies in Azure Sentinel allows the SOC to identify suspicious inbound communications that bypass standard authentication checks, reducing the risk of successful social engineering and credential theft.

KQL Query

// Inbound impersonation and spoof (BEC) detections by sender-IP country. Country is from IP geolocation and is approximate.
EmailEvents
| where Timestamp > ago(30d)
| where OrgLevelPolicy !in ("Phishing simulation", "SecOps Mailbox")
| where (DetectionMethods has "Impersonation" or DetectionMethods has "Spoof") and isnotempty(SenderIPv4)
| extend Key = strcat(NetworkMessageId, '-', RecipientEmailAddress)
| summarize arg_max(Timestamp, *) by Key
| extend Country = tostring(geo_info_from_ip_address(SenderIPv4).country)
| where isnotempty(Country)
| summarize ImpersonationEmails = countif(DetectionMethods has "Impersonation"), SpoofEmails = countif(DetectionMethods has "Spoof"), SenderIPs = dcount(SenderIPv4) by Country
| extend TotalBEC = ImpersonationEmails + SpoofEmails
| top 20 by TotalBEC
| project Country, ImpersonationEmails, SpoofEmails, SenderIPs, TotalBEC

Analytic Rule Definition

id: 0863f418-5681-4532-a097-033f6332d353
name: Impersonation and Spoof Detections by Sender Country
description: |
  This query summarizes inbound impersonation and spoof (BEC) detections by the geographic country of the sending IP address, using the EmailEvents table.
description-detailed: |
  Mapping impersonation and spoof (BEC) detections to the country of the sending IP address helps identify the regions and sending infrastructure behind targeted email attacks. This query resolves the sender IPv4 address to a country and counts inbound impersonation and spoof detections per country, with the number of distinct sending IPs. Use it to spot high-risk sending regions for targeted mitigation. Country is derived from IP geolocation and is approximate.
  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 impersonation and spoof (BEC) detections by sender-IP country. Country is from IP geolocation and is approximate.
  EmailEvents
  | where Timestamp > ago(30d)
  | where OrgLevelPolicy !in ("Phishing simulation", "SecOps Mailbox")
  | where (DetectionMethods has "Impersonation" or DetectionMethods has "Spoof") and isnotempty(SenderIPv4)
  | extend Key = strcat(NetworkMessageId, '-', RecipientEmailAddress)
  | summarize arg_max(Timestamp, *) by Key
  | extend Country = tostring(geo_info_from_ip_address(SenderIPv4).country)
  | where isnotempty(Country)
  | summarize ImpersonationEmails = countif(DetectionMethods has "Impersonation"), SpoofEmails = countif(DetectionMethods has "Spoof"), SenderIPs = dcount(SenderIPv4) by Country
  | extend TotalBEC = ImpersonationEmails + SpoofEmails
  | top 20 by TotalBEC
  | project Country, ImpersonationEmails, SpoofEmails, SenderIPs, TotalBEC
version: 1.0.0

Required Data Sources

Sentinel TableNotes
EmailEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/Spoof and Impersonation/Impersonation and Spoof Detections by Sender Country.yaml