Query Details
id: a1f00009-0009-4009-9009-adfs00000009
name: HUNT-09 ADFS Auth to Mailbox Rule Correlation - BEC (14d)
description: |
Joins ADFS sign-ins with Office 365 Exchange mailbox rule creation events
(within 6 hours of the same user). Reveals BEC patterns where a federated
identity is compromised and an inbox forwarding / autoresponder rule is
created from that session.
severity: High
requiredDataConnectors:
- connectorId: AzureActiveDirectory
dataTypes:
- ADFSSignInLogs
- connectorId: Office365
dataTypes:
- OfficeActivity
tactics:
- Collection
- Exfiltration
relevantTechniques:
- T1114.003
- T1098.002
query: |
let RuleOps = dynamic([
"New-InboxRule", "Set-InboxRule", "New-TransportRule",
"Set-TransportRule", "Set-Mailbox"
]);
let Auths = ADFSSignInLogs
| invoke ExcludeAllowlistedIPs()
| where TimeGenerated > ago(14d)
| where ResultType == 0
| project AuthTime = TimeGenerated, UserPrincipalName, AuthIP = IPAddress, AuthCountry = Location;
OfficeActivity
| where TimeGenerated > ago(14d)
| where OfficeWorkload =~ "Exchange"
| where Operation in (RuleOps)
| extend Actor = tolower(coalesce(UserId, Caller))
| join kind=inner (Auths | extend UPN = tolower(UserPrincipalName)) on $left.Actor == $right.UPN
| where TimeGenerated between (AuthTime .. AuthTime + 6h)
| project
TimeGenerated, Actor, Operation, ClientIP, Parameters,
AuthTime, AuthIP, AuthCountry
| order by TimeGenerated desc
This query is designed to detect potential Business Email Compromise (BEC) incidents by correlating authentication events with mailbox rule creation activities. Here's a simplified summary:
Purpose: The query identifies cases where a user's federated identity might be compromised. It does this by checking if a user logs in via Active Directory Federation Services (ADFS) and subsequently creates or modifies mailbox rules in Office 365 Exchange within a 6-hour window.
Data Sources:
Operations Monitored: The query looks for specific operations such as creating or modifying inbox rules and transport rules, which are often used in BEC scenarios to forward emails or set up auto-responders.
Process:
Outcome: The result is a list of suspicious activities that might indicate a compromised account being used to set up unauthorized email rules, which is a common tactic in BEC attacks. The severity of these findings is considered high due to the potential impact of such compromises.

David Alonso
Released: May 13, 2026
Tables
Keywords
Operators