Detection rules › Splunk

O365 Multiple Mailboxes Accessed via API

Status
production
Severity
medium
Group by
ClientAppId, _time, aws::recipientAccountId, dest, m365::ClientInfoString, signature, vendor_product
Author
Mauricio Velazco, Splunk
Source
github.com/splunk/security_content

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.

Known false positives

  • Legitimate applications may access multiple mailboxes via an API. You can filter by the ClientAppId or the CLientIpAddress fields.

MITRE ATT&CK coverage

Telemetry coverage

PlatformRecord / event type
Microsoft 365MailItemsAccessed

Rules detecting the same action

These rules filter on the same operation.

Rule body

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
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

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 =
ifmatch(ClientInfoString, "^Client=WebServices;ExchangeWebServices")1
else0

Stage 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

These rows show field, operator, and value matches.