Detect Clear Mailbox Data in Splunk
Adversaries may modify mail and mail application data to remove evidence of their activity. Email applications allow users and other programs to export and delete mailbox data via command line tools or use of APIs. Adversaries may use Exchange PowerShell cmdlets (e.g., Remove-MailboxExportRequest, Search-Mailbox with DeleteContent), O365/Graph API calls, or command-line mail utilities on Linux/macOS to delete emails, purge Deleted Items, remove sent items, wipe transport rules, or remove export request logs. This covers tracks from phishing delivery, internal spearphishing, email-based C2, and email exfiltration.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Technique
- T1070 Indicator Removal
- Sub-technique
- T1070.008 Clear Mailbox Data
- Canonical reference
- https://attack.mitre.org/techniques/T1070/008/
SPL Detection Query
( sourcetype="WinEventLog:Security" EventCode=4688 ) OR
( sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 )
| eval CommandLine=coalesce(CommandLine, Process_Command_Line, NewProcessName)
| eval Image=coalesce(Image, NewProcessName, ParentProcessName)
| where (Image LIKE "%powershell.exe" OR Image LIKE "%pwsh.exe")
| eval CmdLower=lower(CommandLine)
| eval RemoveExportReq=if(match(CmdLower, "remove-mailboxexportrequest"), 1, 0)
| eval SearchMailboxDelete=if(match(CmdLower, "search-mailbox") AND match(CmdLower, "-deletecontent"), 1, 0)
| eval RemoveTransportRule=if(match(CmdLower, "(remove-transportrule|disable-transportrule|new-transportrule)"), 1, 0)
| eval InboxRuleManip=if(match(CmdLower, "(remove-inboxrule|set-inboxrule|new-inboxrule)"), 1, 0)
| eval PurgeContent=if(match(CmdLower, "(-purgetype\s+harddelete|-purgetype\s+softdelete|harddelete|purgeallitems)"), 1, 0)
| eval RemoveMoveRequest=if(match(CmdLower, "remove-moverequest"), 1, 0)
| eval NewComplianceSearch=if(match(CmdLower, "(new-compliancesearchaction|remove-compliancesearch)"), 1, 0)
| eval SuspicionScore=RemoveExportReq + SearchMailboxDelete + RemoveTransportRule + InboxRuleManip + PurgeContent + RemoveMoveRequest + NewComplianceSearch
| where SuspicionScore > 0
| eval User=coalesce(User, SubjectUserName, user)
| eval host=coalesce(host, ComputerName)
| table _time, host, User, Image, CommandLine, RemoveExportReq, SearchMailboxDelete, RemoveTransportRule, InboxRuleManip, PurgeContent, RemoveMoveRequest, NewComplianceSearch, SuspicionScore
| sort - SuspicionScore, - _time Detects Exchange PowerShell cmdlets associated with clearing mailbox data, removing export requests, manipulating transport rules, or purging mailbox contents. Uses Sysmon Event ID 1 (Process Creation) or Windows Security Event ID 4688 (with command-line auditing) to catch PowerShell invocations of known mailbox-clearing cmdlets. Each category is scored independently allowing analysts to triage based on combined indicators.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Exchange administrators running scheduled cleanup scripts that invoke Remove-MailboxExportRequest on completed jobs
- Compliance team running Search-Mailbox -DeleteContent as part of approved legal hold or data subject access request workflows
- IT automation or runbooks using Remove-InboxRule to remove organization-wide malicious inbox rules after an incident
- Retention policy automation using compliance search actions to enforce data lifecycle management
Other platforms for T1070.008
Testing Methodology
Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Remove Mailbox Export Request via Exchange PowerShell
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing 'Remove-MailboxExportRequest'. Office 365 Unified Audit Log: RecordType=ExchangeAdmin, Operation=New-MailboxExportRequest followed by Remove-MailboxExportRequest from same UserId. Exchange Admin Audit Log entries for both operations. PowerShell ScriptBlock Log (Event ID 4104) with full cmdlet invocation.
- Test 2Search-Mailbox with DeleteContent to Purge Emails
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing 'Search-Mailbox' and '-DeleteContent'. Windows Security Event ID 4688 (if enabled) with same details. PowerShell ScriptBlock Log (Event ID 4104) capturing full cmdlet with all parameters. Exchange Admin Audit Log entry with full command details.
- Test 3Create Suppression Transport Rule to Delete Security Notifications
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing 'New-TransportRule' and 'DeleteMessage'. Office 365 Unified Audit Log / Exchange Admin Audit Log: RecordType=ExchangeAdmin, Operation=New-TransportRule with full rule parameters. PowerShell ScriptBlock Log (Event ID 4104) with complete rule definition including -DeleteMessage flag.
- Test 4Delete Emails via Linux mail Command
Expected signal: Linux auditd: execve syscall for 'mail' binary with arguments containing 'd' (delete) flag. Syslog: process invocation of /usr/bin/mail or /bin/mail. If Sysmon for Linux is deployed: ProcessCreate event with Image=/usr/bin/mail and CommandLine containing delete arguments.
- Test 5Remove Inbox Rule to Cover Tracks After Rule-Based Exfiltration
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing 'Remove-InboxRule'. Exchange Admin Audit Log and O365 Unified Audit Log: Operations New-InboxRule then Remove-InboxRule from same account. PowerShell ScriptBlock Log (Event ID 4104) capturing both rule creation and removal. If alerting on New-InboxRule, the forwarding rule creation would also trigger separately.
References (13)
- https://attack.mitre.org/techniques/T1070/008/
- https://www.volexity.com/blog/2020/12/14/dark-halo-leverages-solarwinds-compromise-to-breach-organizations/
- https://cdn2.hubspot.net/hubfs/3354902/Cybereason%20Labs%20Analysis%20Operation%20Cobalt%20Kitty.pdf
- https://man7.org/linux/man-pages/man1/mailx.1p.html
- https://docs.microsoft.com/en-us/powershell/module/exchange/?view=exchange-ps#mailboxes
- https://www.microsoft.com/en-us/security/blog/2022/09/22/malicious-oauth-applications-used-to-compromise-email-servers-and-spread-spam/
- https://www.mandiant.com/resources/blog/apt42-charms-cons-and-compromises
- https://www.welivesecurity.com/en/eset-research/to-the-moon-and-back-s-lunar-landing-in-diplomatic-missions/
- https://learn.microsoft.com/en-us/exchange/policy-and-compliance/mail-flow-rules/mail-flow-rules
- https://learn.microsoft.com/en-us/powershell/module/exchange/remove-mailboxexportrequest
- https://learn.microsoft.com/en-us/powershell/module/exchange/search-mailbox
- https://learn.microsoft.com/en-us/microsoft-365/compliance/search-the-audit-log-in-security-and-compliance
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1070.008/T1070.008.md
Unlock Pro Content
Get the full detection package for T1070.008 including response playbook, investigation guide, and atomic red team tests.