T1564.008

Email Hiding Rules

Adversaries may use email inbox rules to hide inbound emails in a compromised user's mailbox. Rules can automatically move messages to less-visible folders, mark them as read, or permanently delete them — preventing users and defenders from seeing security alerts, C2 communications, or replies to spearphishing emails sent from the compromised account. Attackers commonly filter on keywords such as 'malware', 'phish', 'hack', 'suspicious', and 'security' in subject lines and message bodies. Rules can be created through email clients (Outlook, OWA), Exchange PowerShell cmdlets (New-InboxRule, Set-InboxRule), Microsoft Graph API, or organization-wide Exchange transport rules. Real-world threat actors including Scattered Spider (OCTO TEMPEST) and FIN4 have used this technique to suppress security alerts and delay incident detection. Malicious rules targeting security personnel inboxes are particularly dangerous as they can suppress vendor security product notifications and SOC escalation emails.

Microsoft Sentinel / Defender
kusto
let SuspiciousFilterTerms = dynamic([
  "malware", "phish", "phishing", "hack", "hacked", "suspicious",
  "security alert", "breach", "incident", "infected", "virus", "ransomware",
  "compromise", "unauthorized", "unusual sign-in", "unusual signin",
  "password reset", "account locked", "mfa", "multi-factor",
  "alert", "threat", "SOC", "SIEM", "security team", "IT security",
  "helpdesk", "abuse", "fraud", "intrusion", "vulnerability"
]);
// Detection path 1: Office 365 Unified Audit Log via OfficeActivity
let OfficeRuleEvents = OfficeActivity
| where TimeGenerated > ago(24h)
| where Operation in~ ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules",
                       "New-TransportRule", "Set-TransportRule", "Enable-TransportRule")
| extend ParametersStr = tostring(Parameters)
| extend HasSecurityKeywords = ParametersStr has_any (SuspiciousFilterTerms)
| extend HasDeleteAction = ParametersStr has_any ("DeleteMessage", "PermanentDelete", "MoveToDeletedItems")
| extend HasMoveAction = ParametersStr has_any ("MoveToFolder", "MoveToOtherFolder")
| extend HasMarkRead = ParametersStr has "MarkAsRead"
| extend HasBodyFilter = ParametersStr has_any ("BodyContainsWords", "SubjectOrBodyContainsWords", "SubjectContainsWords")
| extend HasFromFilter = ParametersStr has_any ("FromAddressContainsWords", "From", "SenderDomainIs")
| extend SuspicionScore = toint(HasSecurityKeywords) + toint(HasDeleteAction) + toint(HasMoveAction) + toint(HasMarkRead)
| where SuspicionScore >= 1 or HasBodyFilter
| project TimeGenerated, UserAccount = UserId, Source = "OfficeActivity",
          Operation, ClientIP, UserAgent,
          SuspicionScore, HasSecurityKeywords, HasDeleteAction,
          HasMoveAction, HasMarkRead, HasBodyFilter, HasFromFilter,
          RuleDetails = ParametersStr;
// Detection path 2: PowerShell-based inbox rule creation via MDE
let PowerShellRuleEvents = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has_any ("New-InboxRule", "Set-InboxRule")
| extend HasSecurityKeywords = ProcessCommandLine has_any (SuspiciousFilterTerms)
| extend HasDeleteAction = ProcessCommandLine has_any ("-DeleteMessage", "-PermanentDelete", "-MoveToDeletedItems")
| extend HasMoveAction = ProcessCommandLine has_any ("-MoveToFolder", "-MoveToOtherFolder")
| extend HasMarkRead = ProcessCommandLine has "-MarkAsRead"
| extend HasBodyFilter = ProcessCommandLine has_any ("-BodyContainsWords", "-SubjectOrBodyContainsWords", "-SubjectContainsWords")
| extend SuspicionScore = toint(HasSecurityKeywords) + toint(HasDeleteAction) + toint(HasMoveAction) + toint(HasMarkRead) + 1
| project TimeGenerated = Timestamp, UserAccount = AccountName, Source = "DeviceProcessEvents",
          Operation = "PowerShell-InboxRule", ClientIP = DeviceName, UserAgent = InitiatingProcessFileName,
          SuspicionScore, HasSecurityKeywords, HasDeleteAction,
          HasMoveAction, HasMarkRead, HasBodyFilter, HasFromFilter = false,
          RuleDetails = ProcessCommandLine;
union OfficeRuleEvents, PowerShellRuleEvents
| sort by TimeGenerated desc
high severity high confidence

Data Sources

Application Log: Office 365 Unified Audit Log Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint Microsoft Sentinel OfficeActivity

Required Tables

OfficeActivity DeviceProcessEvents

False Positives

  • IT administrators creating legitimate mail flow rules for routing, compliance archiving, or spam filtering via PowerShell automation scripts
  • Help desk and support staff who create inbox rules for ticket system notifications or automated routing of service alerts
  • Legal and compliance teams creating retention rules or litigation hold configurations that move emails to specific folders
  • Users creating personal organization rules with common words like 'alert' or 'notification' that overlap with security keyword lists
  • Automated onboarding scripts that create standard inbox rules for new user accounts (e.g., move newsletters to a folder)

Unlock Pro Content

Get the full detection package for T1564.008 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections