Detection rules › Splunk
O365 Multiple Mailboxes Accessed via API
The following analytic detects when a high number of Office 365 Exchange mailboxes are accessed via API (Microsoft Graph API or Exchange Web Services) within a short timeframe. It leverages 'MailItemsAccessed' operations in Exchange, using AppId and regex to identify API interactions. This activity is significant as it may indicate unauthorized mass email access, potentially signaling data exfiltration or account compromise. If confirmed malicious, attackers could gain access to sensitive information, leading to data breaches and further exploitation of compromised accounts. The threshold is set to flag over five unique mailboxes accessed within 10 minutes, but should be tailored to your environment.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Collection | T1114.002 Email Collection: Remote Email Collection |
Rules detecting the same action
Other rules on this platform that filter on the same API call or operation.
Rule body splunk
name: O365 Multiple Mailboxes Accessed via API
id: 7cd853e9-d370-412f-965d-a2bcff2a2908
version: 11
creation_date: '2024-02-14'
modification_date: '2026-05-13'
author: Mauricio Velazco, Splunk
status: production
type: TTP
description: The following analytic detects when a high number of Office 365 Exchange mailboxes are accessed via API (Microsoft Graph API or Exchange Web Services) within a short timeframe. It leverages 'MailItemsAccessed' operations in Exchange, using AppId and regex to identify API interactions. This activity is significant as it may indicate unauthorized mass email access, potentially signaling data exfiltration or account compromise. If confirmed malicious, attackers could gain access to sensitive information, leading to data breaches and further exploitation of compromised accounts. The threshold is set to flag over five unique mailboxes accessed within 10 minutes, but should be tailored to your environment.
data_source:
- O365 MailItemsAccessed
search: |-
`o365_management_activity` Workload=Exchange Operation=MailItemsAccessed AppId=* ClientAppId=*
| bucket span=10m _time
| eval matchRegex=if(match(ClientInfoString,"^Client=WebServices;ExchangeWebServices"), 1, 0)
| search (AppId="00000003-0000-0000-c000-000000000000" OR matchRegex=1)
| fillnull
| stats values(ClientIPAddress) as src dc(user) as unique_mailboxes values(user) as user
BY _time ClientAppId ClientInfoString
vendor_account vendor_product dest
signature
| where unique_mailboxes > 5
| `o365_multiple_mailboxes_accessed_via_api_filter`
how_to_implement: You must install the Splunk Microsoft Office 365 Add-on and ingest Office 365 management activity events.
known_false_positives: Legitimate applications may access multiple mailboxes via an API. You can filter by the ClientAppId or the CLientIpAddress fields.
references:
- https://attack.mitre.org/techniques/T1114/002/
- https://learn.microsoft.com/en-us/troubleshoot/azure/active-directory/verify-first-party-apps-sign-in
- https://learn.microsoft.com/en-us/graph/permissions-reference
- https://attack.mitre.org/techniques/T1114/002/
- https://www.microsoft.com/en-us/security/blog/2024/01/25/midnight-blizzard-guidance-for-responders-on-nation-state-attack/
- https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/ews-applications-and-the-exchange-architecture
drilldown_searches:
- name: View the detection results for - "$user$"
search: '%original_detection_search% | search user = "$user$"'
earliest_offset: $info_min_time$
latest_offset: $info_max_time$
- name: View risk events for the last 7 days for - "$user$"
search: '| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$user$") | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`'
earliest_offset: 7d
latest_offset: "0"
finding:
title: An Oauth application identified with id $ClientAppId$ accessed multiple mailboxes in a short period of time via an API.
entity:
field: user
type: user
score: 50
analytic_story:
- Office 365 Collection Techniques
- NOBELIUM Group
asset_type: O365 Tenant
mitre_attack_id:
- T1114.002
product:
- Splunk Enterprise
- Splunk Enterprise Security
- Splunk Cloud
category: cloud
security_domain: threat
tests:
- name: True Positive Test
attack_data:
- data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1114.002/o365_multiple_mailboxes_accessed_via_api/o365_multiple_mailboxes_accessed_via_api.log
source: o365
sourcetype: o365:management:activity
test_type: unit
Stages and Predicates
Stage 1: search
`o365_management_activity` Workload=Exchange Operation=MailItemsAccessed AppId=* ClientAppId=*
Stage 2: bucket
| bucket span=10m _time
Stage 3: eval
| eval matchRegex=if(match(ClientInfoString,"^Client=WebServices;ExchangeWebServices"), 1, 0)
matchRegex =match(ClientInfoString, "^Client=WebServices;ExchangeWebServices")10Stage 4: search
| search (AppId="00000003-0000-0000-c000-000000000000" OR matchRegex=1)
Stage 5: fillnull
| fillnull
Stage 6: stats
| stats values(ClientIPAddress) as src dc(user) as unique_mailboxes values(user) as user
BY _time ClientAppId ClientInfoString
vendor_account vendor_product dest
signature
Stage 7: where
| where unique_mailboxes > 5
Stage 8: search
| `o365_multiple_mailboxes_accessed_via_api_filter`
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
AppId | eq |
|
ClientAppId | eq |
|
Operation | eq |
|
Workload | eq |
|
matchRegex | eq |
|
sourcetype | eq |
|
unique_mailboxes | gt |
|