Add email auto-forwarding hunting queries (exfiltration) - #15026
Conversation
Adds four hunting queries using the EmailEvents table that surface automatic external email forwarding (mailbox rule and SMTP forwarding): overview by type, top internal users forwarding externally, top external domains, and top external recipients.
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Pull request overview
Adds new Advanced Hunting queries to help identify automatic external email forwarding activity (mailbox rule and SMTP forwarding) as a potential data exfiltration technique.
Changes:
- Adds an overview query summarizing external auto-forwarding volume by forwarding type.
- Adds three “top N” queries to rank internal forwarders, external recipient domains, and external recipient addresses.
- Duplicates each query into both the Hunting Queries area and the Microsoft Defender XDR solution location with unique IDs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Solutions/Microsoft Defender XDR/Hunting Queries/Email and Collaboration Queries/Mailflow/Automatic External Email Forwarding by Type.yaml | Adds tenant-level aggregation of auto-forwarded outbound email by forwarding type. |
| Solutions/Microsoft Defender XDR/Hunting Queries/Email and Collaboration Queries/Mailflow/Top Users Auto-forwarding Email Externally.yaml | Adds ranking of internal users auto-forwarding to external recipients by type. |
| Solutions/Microsoft Defender XDR/Hunting Queries/Email and Collaboration Queries/Mailflow/Top External Domains Receiving Auto-forwarded Email.yaml | Adds ranking of external recipient domains receiving auto-forwarded mail by type. |
| Solutions/Microsoft Defender XDR/Hunting Queries/Email and Collaboration Queries/Mailflow/Top External Recipients Receiving Auto-forwarded Email.yaml | Adds ranking of external recipient addresses receiving auto-forwarded mail by type. |
| Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/Mailflow/Automatic External Email Forwarding by Type.yaml | Same overview query as above for the non-solution hunting queries location (unique id). |
| Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/Mailflow/Top Users Auto-forwarding Email Externally.yaml | Same “top users” query as above for the non-solution location (unique id). |
| Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/Mailflow/Top External Domains Receiving Auto-forwarded Email.yaml | Same “top domains” query as above for the non-solution location (unique id). |
| Hunting Queries/Microsoft 365 Defender/Email and Collaboration Queries/Mailflow/Top External Recipients Receiving Auto-forwarded Email.yaml | Same “top recipients” query as above for the non-solution location (unique id). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
v-atulyadav On the KqlValidations failure (KS142 on ForwardingInformation): this is a valid, current EmailEvents column (it backs the Inbox-rule / SMTP external-forwarding insights) that isn't in the offline validation schema bundled with the tests yet, so the analyzer flags it as unknown. The queries run correctly against a live tenant. |
…iew feedback Add the 4 forwarding templates (8 IDs, Hunting + Solution copies) to SkipValidationsTemplates.json: ForwardingInformation is a valid EmailEvents column not yet in the offline validation schema, verified against a live tenant. Parse ForwardingInformation once per row across the 4 queries. Top Users now filters isnotempty(ForwardingUser) to drop blank forwarders.
…g queries Exclude phishing-simulation and SecOps mailbox traffic, and de-duplicate each delivery (NetworkMessageId + recipient) before counting so re-scanned messages are counted once. Aligns the counts with the source workbook.
# Conflicts: # .script/tests/KqlvalidationsTests/SkipValidationsTemplates.json
7e7d964
Adds four hunting queries using the EmailEvents table that surface automatic external email forwarding (mailbox rule and SMTP forwarding), a common data-exfiltration technique after mailbox compromise:
Each query is added in both the Hunting Queries area and the Microsoft Defender XDR solution with its own unique id.
Change(s):
Reason for Change(s):
Version Updated:
Testing Completed:
Checked that the validations are passing and have addressed any issues that are present: