← Back to SOC feed Coverage →

Good emails from senders with bad patterns

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-05-10T23:00:00Z · Confidence: medium

Hunt Hypothesis

Adversaries may use legitimate email accounts with compromised credentials to send seemingly benign emails that mimic trusted internal communication, leveraging T1566 to evade detection. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential credential compromise and insider threat activity early.

KQL Query

//Good emails from senders with bad patterns
let PctPhishThreshold = 50;
let LookbackWindow = 1d;
 EmailEvents
| where Timestamp > ago (LookbackWindow) and EmailDirection == "Inbound"
| extend PhishMethods=tostring(parse_json(DetectionMethods).Phish)
| where PhishMethods contains ("File") or PhishMethods contains ("URL") or PhishMethods contains ("Filter")
| summarize PhishCount=count() by SenderMailFromAddress,AuthenticationDetails,PhishMethods
| join kind=inner (EmailEvents | where Timestamp > ago (LookbackWindow) and EmailDirection == "Inbound"
| summarize TotalCount=count() by SenderMailFromAddress,AuthenticationDetails) on SenderMailFromAddress,AuthenticationDetails
| project-away SenderMailFromAddress1,AuthenticationDetails1
| extend PctPhish = (PhishCount*100 / TotalCount)
| where PctPhish < 100 and PctPhish>= PctPhishThreshold
| join kind=inner (EmailEvents | where Timestamp > ago (LookbackWindow) and EmailDirection == "Inbound" and DeliveryLocation<> "Quarantine") on SenderMailFromAddress,AuthenticationDetails

Analytic Rule Definition

id: e6259b03-622e-4e11-9c54-94987dad7c14
name: Good emails from senders with bad patterns
description: |
  This query helps hunting for good emails from senders with bad patterns
description-detailed: |
  This query helps hunting for good emails from senders with bad patterns using Defender for Office 365 data.
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - EmailEvents
tactics:
  - InitialAccess
relevantTechniques:
  - T1566
query: |
    //Good emails from senders with bad patterns
    let PctPhishThreshold = 50;
    let LookbackWindow = 1d;
     EmailEvents
    | where Timestamp > ago (LookbackWindow) and EmailDirection == "Inbound"
    | extend PhishMethods=tostring(parse_json(DetectionMethods).Phish)
    | where PhishMethods contains ("File") or PhishMethods contains ("URL") or PhishMethods contains ("Filter")
    | summarize PhishCount=count() by SenderMailFromAddress,AuthenticationDetails,PhishMethods
    | join kind=inner (EmailEvents | where Timestamp > ago (LookbackWindow) and EmailDirection == "Inbound"
    | summarize TotalCount=count() by SenderMailFromAddress,AuthenticationDetails) on SenderMailFromAddress,AuthenticationDetails
    | project-away SenderMailFromAddress1,AuthenticationDetails1
    | extend PctPhish = (PhishCount*100 / TotalCount)
    | where PctPhish < 100 and PctPhish>= PctPhishThreshold
    | join kind=inner (EmailEvents | where Timestamp > ago (LookbackWindow) and EmailDirection == "Inbound" and DeliveryLocation<> "Quarantine") on SenderMailFromAddress,AuthenticationDetails
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/Hunting/Good emails from senders with bad patterns.yaml