Dataverse - Terminated employee exfiltration over email
| Id | de039242-47e0-43fa-84d7-b6be24305349 |
| Rulename | Dataverse - Terminated employee exfiltration over email |
| Description | This query identifies Dataverse exfiltration via email by terminated employees. |
| Severity | High |
| Tactics | Exfiltration |
| Techniques | T1639 T1567 |
| Required data connectors | AzureActiveDirectoryIdentityProtection IdentityInfo MicrosoftThreatProtection |
| Kind | Scheduled |
| Query frequency | 1h |
| Query period | 14d |
| Trigger threshold | 0 |
| Trigger operator | gt |
| Source Uri | https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Microsoft Business Applications/Analytic Rules/Dataverse - Terminated employee exfiltration over email.yaml |
| Version | 3.2.0 |
| Arm template | de039242-47e0-43fa-84d7-b6be24305349.json |
// Note this detection relies upon the user's UPN matching their email address.
// UEBA can provide more accurate data if enabled.
let query_frequency = 1h;
let allowed_destination_smtp_domains = dynamic([
// Specify a list of recipient domains to exclude from alerting.
// Example:
// "microsoft.com", "contoso.com"
]);
let exfiltration_alert_users = SecurityAlert
| where Tactics has 'Exfiltration' and Entities has_all ('account', '32780')
| mv-expand DataverseEntities = todynamic(Entities)
| where DataverseEntities.AppId == 32780
| extend InstanceUrl = tostring(DataverseEntities.InstanceName)
| mv-expand AccountEntities = todynamic(Entities)
| where AccountEntities.Type == 'account'
| extend
AccountName = tostring(AccountEntities.Name),
UPNSuffix = tostring(AccountEntities.UPNSuffix)
| summarize InstanceUrls = make_set(InstanceUrl, 100) by AccountName, UPNSuffix
| extend UserId = tolower(strcat(AccountName, "@", UPNSuffix));
exfiltration_alert_users
| join kind=inner (
MSBizAppsTerminatedEmployees
| project UserId = tolower(UserPrincipalName), NotificationDate
| where startofday(NotificationDate) <= startofday(now()))
// Uncomment the below KQL if UEBA is available to gain more accurate
// email address data:
// | join kind=leftouter (_ASIM_IdentityInfo) on $left.UserId == $right.Username
// | extend UserId = iif(UserId == UserMailAddress or isempty(UserMailAddress), UserId, UserMailAddress))
on UserId
| join kind=inner (
EmailEvents
| where TimeGenerated >= ago (query_frequency)
| where EmailDirection == "Outbound" and AttachmentCount > 0
| extend RecipientDomain = tolower(split(RecipientEmailAddress, '@')[1])
| where RecipientDomain !in (allowed_destination_smtp_domains)
| summarize
RecipientAddresses = make_set(RecipientEmailAddress, 1000),
Subject = make_set(Subject, 1000)
by SenderAddress = tolower(SenderMailFromAddress), SenderIPv4)
on $left.UserId == $right.SenderAddress
| mv-expand InstanceUrl = InstanceUrls to typeof(string)
| extend
CloudAppId = int(32780),
AccountName = tostring(split(UserId, "@")[0]),
UPNSuffix = tostring(split(UserId, "@")[1])
| project
UserId,
InstanceUrl,
SenderIPv4,
RecipientAddresses,
Subject,
AccountName,
UPNSuffix,
CloudAppId
alertDetailsOverride:
alertDescriptionFormat: 'Departing or terminated user {{UserId}} was found to send email to external domains not on the allowed list: {{RecipientAddresses}}'
alertDisplayNameFormat: Email attachment sent externally by terminated user following Dataverse exfiltration alerts
description: This query identifies Dataverse exfiltration via email by terminated employees.
kind: Scheduled
tactics:
- Exfiltration
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
dataTypes:
- EmailEvents
- connectorId: AzureActiveDirectoryIdentityProtection
dataTypes:
- SecurityAlert
- connectorId: IdentityInfo
dataTypes:
- IdentityInfo
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Microsoft Business Applications/Analytic Rules/Dataverse - Terminated employee exfiltration over email.yaml
severity: High
name: Dataverse - Terminated employee exfiltration over email
triggerThreshold: 0
queryPeriod: 14d
query: |
// Note this detection relies upon the user's UPN matching their email address.
// UEBA can provide more accurate data if enabled.
let query_frequency = 1h;
let allowed_destination_smtp_domains = dynamic([
// Specify a list of recipient domains to exclude from alerting.
// Example:
// "microsoft.com", "contoso.com"
]);
let exfiltration_alert_users = SecurityAlert
| where Tactics has 'Exfiltration' and Entities has_all ('account', '32780')
| mv-expand DataverseEntities = todynamic(Entities)
| where DataverseEntities.AppId == 32780
| extend InstanceUrl = tostring(DataverseEntities.InstanceName)
| mv-expand AccountEntities = todynamic(Entities)
| where AccountEntities.Type == 'account'
| extend
AccountName = tostring(AccountEntities.Name),
UPNSuffix = tostring(AccountEntities.UPNSuffix)
| summarize InstanceUrls = make_set(InstanceUrl, 100) by AccountName, UPNSuffix
| extend UserId = tolower(strcat(AccountName, "@", UPNSuffix));
exfiltration_alert_users
| join kind=inner (
MSBizAppsTerminatedEmployees
| project UserId = tolower(UserPrincipalName), NotificationDate
| where startofday(NotificationDate) <= startofday(now()))
// Uncomment the below KQL if UEBA is available to gain more accurate
// email address data:
// | join kind=leftouter (_ASIM_IdentityInfo) on $left.UserId == $right.Username
// | extend UserId = iif(UserId == UserMailAddress or isempty(UserMailAddress), UserId, UserMailAddress))
on UserId
| join kind=inner (
EmailEvents
| where TimeGenerated >= ago (query_frequency)
| where EmailDirection == "Outbound" and AttachmentCount > 0
| extend RecipientDomain = tolower(split(RecipientEmailAddress, '@')[1])
| where RecipientDomain !in (allowed_destination_smtp_domains)
| summarize
RecipientAddresses = make_set(RecipientEmailAddress, 1000),
Subject = make_set(Subject, 1000)
by SenderAddress = tolower(SenderMailFromAddress), SenderIPv4)
on $left.UserId == $right.SenderAddress
| mv-expand InstanceUrl = InstanceUrls to typeof(string)
| extend
CloudAppId = int(32780),
AccountName = tostring(split(UserId, "@")[0]),
UPNSuffix = tostring(split(UserId, "@")[1])
| project
UserId,
InstanceUrl,
SenderIPv4,
RecipientAddresses,
Subject,
AccountName,
UPNSuffix,
CloudAppId
relevantTechniques:
- T1639
- T1567
id: de039242-47e0-43fa-84d7-b6be24305349
queryFrequency: 1h
status: Available
version: 3.2.0
triggerOperator: gt
eventGroupingSettings:
aggregationKind: AlertPerResult
entityMappings:
- entityType: Account
fieldMappings:
- columnName: AccountName
identifier: Name
- columnName: UPNSuffix
identifier: UPNSuffix
- entityType: IP
fieldMappings:
- columnName: SenderIPv4
identifier: Address
- entityType: CloudApplication
fieldMappings:
- columnName: CloudAppId
identifier: AppId
- columnName: InstanceUrl
identifier: InstanceName