Detection rules › Splunk

O365 Mail Permissioned Application Consent Granted by User

Status
production
Severity
medium
Group by
ObjectId, aws::recipientAccountId, dest, group.name, signature, src, user, vendor_product
Author
Mauricio Velazco, Splunk
Source
github.com/splunk/security_content

The following analytic identifies instances where a user grants consent to an application requesting mail-related permissions within the Office 365 environment. It leverages O365 audit logs, specifically focusing on events related to application permissions and user consent actions. This activity is significant as it can indicate potential security risks, such as data exfiltration or spear phishing, if malicious applications gain access. If confirmed malicious, this could lead to unauthorized data access, email forwarding, or sending malicious emails from the compromised account. Validating the legitimacy of the application and consent context is crucial to prevent data breaches.

Known false positives

  • OAuth applications that require mail permissions may be legitimate, investigate and filter as needed.

MITRE ATT&CK coverage

TacticTechniques
Credential Access

Telemetry coverage

PlatformRecord / event type
Microsoft 365Consent to application.

Rules detecting the same action

These rules filter on the same operation.

Rule body

name: O365 Mail Permissioned Application Consent Granted by User
id: fddad083-cdf5-419d-83c6-baa85e329595
version: 9
creation_date: '2023-12-06'
modification_date: '2026-05-13'
author: Mauricio Velazco, Splunk
status: production
type: TTP
description: The following analytic identifies instances where a user grants consent to an application requesting mail-related permissions within the Office 365 environment. It leverages O365 audit logs, specifically focusing on events related to application permissions and user consent actions. This activity is significant as it can indicate potential security risks, such as data exfiltration or spear phishing, if malicious applications gain access. If confirmed malicious, this could lead to unauthorized data access, email forwarding, or sending malicious emails from the compromised account. Validating the legitimacy of the application and consent context is crucial to prevent data breaches.
data_source:
    - O365 Consent to application.
search: "`o365_management_activity` Workload=AzureActiveDirectory Operation=\"Consent to application.\" ResultStatus=Success | eval admin_consent =mvindex('ModifiedProperties{}.NewValue',0) | search admin_consent=False | eval permissions =mvindex('ModifiedProperties{}.NewValue',4) | rex field=permissions \"Scope:(?<Scope>[^,]+)\" | makemv delim=\" \" Scope | search Scope IN (\"Mail.Read\", \"Mail.ReadBasic\", \"Mail.ReadWrite\", \"Mail.Read.Shared\", \"Mail.ReadWrite.Shared\", \"Mail.Send\", \"Mail.Send.Shared\") | fillnull | stats count min(_time) as firstTime max(_time) as lastTime values(Scope) as Scope by signature dest user src vendor_account vendor_product object ObjectId | `security_content_ctime(lastTime)` | `o365_mail_permissioned_application_consent_granted_by_user_filter`"
how_to_implement: You must install the Splunk Microsoft Office 365 Add-on and ingest Office 365 management activity events.
known_false_positives: OAuth applications that require mail permissions may be legitimate, investigate and filter as needed.
references:
    - https://attack.mitre.org/techniques/T1528/
    - https://www.microsoft.com/en-us/security/blog/2022/09/22/malicious-oauth-applications-used-to-compromise-email-servers-and-spread-spam/
    - https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/protect-against-consent-phishing
    - https://learn.microsoft.com/en-us/defender-cloud-apps/investigate-risky-oauth
    - https://www.alteredsecurity.com/post/introduction-to-365-stealer
    - https://github.com/AlteredSecurity/365-Stealer
finding:
    title: User $user$ consented an OAuth application that requests mail-related permissions.
    entity:
        field: user
        type: user
        score: 50
analytic_story:
    - Office 365 Account Takeover
asset_type: O365 Tenant
mitre_attack_id:
    - T1528
product:
    - Splunk Enterprise
    - Splunk Enterprise Security
    - Splunk Cloud
category: cloud
security_domain: identity

Stages and Predicates

Stage 1: search

`o365_management_activity` Workload=AzureActiveDirectory Operation="Consent to application." ResultStatus=Success

Stage 2: eval

| eval admin_consent =mvindex('ModifiedProperties{}.NewValue',0)

Stage 3: search

| search admin_consent=False

Stage 4: eval

| eval permissions =mvindex('ModifiedProperties{}.NewValue',4)

Stage 5: rex

| rex field=permissions "Scope:(?<Scope>[^,]+)"

Stage 6: makemv

| makemv delim=" " Scope

Stage 7: search

| search Scope IN ("Mail.Read", "Mail.ReadBasic", "Mail.ReadWrite", "Mail.Read.Shared", "Mail.ReadWrite.Shared", "Mail.Send", "Mail.Send.Shared")

Stage 8: fillnull

| fillnull

Stage 9: stats

| stats count min(_time) as firstTime max(_time) as lastTime values(Scope) as Scope by signature dest user src vendor_account vendor_product object ObjectId

Stage 10: search

| `security_content_ctime(lastTime)`

Stage 11: search

| `o365_mail_permissioned_application_consent_granted_by_user_filter`

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Operationeq
  • "Consent to application."
field:"Operation" kind:eq
ResultStatuseq
  • Success
field:"ResultStatus" kind:eq value:"Success"
Scopein
  • "Mail.Read"
  • "Mail.Read.Shared"
  • "Mail.ReadBasic"
  • "Mail.ReadWrite"
  • "Mail.ReadWrite.Shared"
  • "Mail.Send"
  • "Mail.Send.Shared"
field:"Scope" kind:in
Workloadeq
  • AzureActiveDirectory
field:"Workload" kind:eq value:"AzureActiveDirectory"
admin_consenteq
  • False
field:"admin_consent" kind:eq value:"False"
sourcetypeeq
  • o365:management:activity
field:"sourcetype" kind:eq value:"o365:management:activity"