Detection: O365 Email Send Attachments Excessive Volume

Description

The following analytic identifies when an O365 email account sends an excessive number of email attachments to external recipients within a short period (within 1 hour). This behavior may indicate a compromised account where the threat actor is attempting to exfiltrate data from the mailbox. Threat actors may attempt to transfer data through email as a simple means of exfiltration from the compromised mailbox. Some account owner legitimate behaviors can trigger this alert, however these actions may not be aligned with organizational expectations / best practice behaviors.

 1`o365_messagetrace` Status=Delivered
 2
 3| eval mailtime = _time
 4
 5| bin _time span=1hr
 6
 7| eval user = lower(SenderAddress), recipient = lower(RecipientAddress)
 8
 9| eval InternetMessageId = lower(MessageId)
10
11| join InternetMessageId, user, _time max=0
12  [
13  
14| search `o365_management_activity` Workload=Exchange Operation IN ("Send","SendAs","SendOnBehalf") 
15  
16| eval user = lower(UserId), sender = lower(CASE(isnotnull(SendAsUserSmtp),SendAsUserSmtp,isnotnull(SendOnBehalfOfUserSmtp),SendOnBehalfOfUserSmtp,true(),MailboxOwnerUPN)), subject = trim(CASE(Operation IN ("Send","SendAs","SendOnBehalf"),'Item.Subject',Operation IN ("SoftDelete","HardDelete"),'AffectedItems{}.Subject')), -time = _time,file_name = trim(CASE(Operation IN ("Send","SendAs","SendOnBehalf"),split('Item.Attachments',"; "),Operation IN ("SoftDelete","HardDelete"),split('AffectedItems{}.Attachments',"; "))), file_size = CASE(Operation IN ("Send","SendAs","SendOnBehalf"),round(tonumber('Item.SizeInBytes')/1024/1024,2),true(),round(tonumber(replace(file_name, "(.+)\s\((\d+)(b\)$)", "\2"))/1024/1024,2)), InternetMessageId = lower('Item.InternetMessageId')
17  
18| bin _time span=1hr
19  
20| eval file_name = mvfilter(NOT match(file_name, "\.jpg 
21|\.png 
22|\.jpeg 
23|\.gif "))
24  
25| search file_name=*
26  
27| stats values(sender) as sender, values(ClientIPAddress) as src, values(ClientInfoString) as http_user_agent, values(Operation) as signature, values(file_name) as file_name, sum(file_size) as file_size, values(Folder.Path) as file_path, min(-time) as firstTime, max(-time) as lastTime, dc(file_name) as count by _time,user,InternetMessageId
28  
29| where count > 25
30  
31| eval file_name = mvjoin(file_name,"
32|
33|")
34  ]
35
36| eval file_name = split(file_name,"
37|
38|")
39
40| stats values(sender) as sender, values(recipient) as recipient, values(http_user_agent) as http_user_agent, values(signature) as signature, values(file_name) as file_name, max(file_size) as file_size, min(firstTime) as firstTime, max(lastTime) as lastTime max(count) as count by subject,user,Organization,InternetMessageId
41
42| eval recipient = mvmap(recipient, if(match(mvindex(split(lower(recipient),"@"),1),mvindex(split(lower(user),"@"),1)), null(),recipient))
43
44| search recipient = *
45
46| `security_content_ctime(firstTime)` 
47
48| `security_content_ctime(lastTime)`
49
50| `o365_email_send_attachments_excessive_volume_filter`

Data Source

Name Platform Sourcetype Source
Office 365 Universal Audit Log N/A 'o365:management:activity' 'o365'

Macros Used

Name Value
o365_management_activity sourcetype=o365:management:activity
o365_email_send_attachments_excessive_volume_filter search *
o365_email_send_attachments_excessive_volume_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1070.008 Clear Mailbox Data Defense Evasion
T1485 Data Destruction Impact
Actions on Objectives
Exploitation
DE.AE
CIS 10

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Risk Event True
This configuration file applies to all detections of type anomaly. These detections will use Risk Based Alerting.

Implementation

You must install the Splunk Microsoft Office 365 Add-on and ingest Office 365 management activity events AND Message Trace events.

Known False Positives

Users or processes that are send a large number of attachments may trigger this alert, adjust thresholds accordingly.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message:

The user $user$ sent an excessive number of email attachments [$count$] to external recipient(s) within a short timeframe

Risk Object Risk Object Type Risk Score Threat Objects
user user 20 recipient

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset o365 o365:management:activity
Integration ✅ Passing Dataset o365 o365:management:activity

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub | Version: 1