Detection rules › Kusto
Dataverse - Terminated employee exfiltration to USB drive
Identifies files downloaded from Dataverse by departing or terminated employees which are copied to USB mounted drives.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Exfiltration | T1052 Exfiltration Over Physical Medium |
Rule body kusto
id: c5e75cb6-cea0-49c2-a998-da414035aac1
kind: Scheduled
name: Dataverse - Terminated employee exfiltration to USB drive
description: Identifies files downloaded from Dataverse by departing or terminated
employees which are copied to USB mounted drives.
severity: High
status: Available
requiredDataConnectors:
- connectorId: Dataverse
dataTypes:
- DataverseActivity
- connectorId: MicrosoftThreatProtection
dataTypes:
- DeviceInfo
- DeviceEvents
- DeviceFileEvents
queryFrequency: 1h
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
- Exfiltration
relevantTechniques:
- T1052
query: |
let drive_mount_lookback = 14d;
let query_frequency = 1h;
DataverseActivity
| distinct InstanceUrl
| join kind=inner (DeviceFileEvents
| where TimeGenerated >= ago(query_frequency))
on $left.InstanceUrl == $right.FileOriginUrl
| join kind=inner (MSBizAppsTerminatedEmployees()) on $left.InitiatingProcessAccountUpn == $right.UserPrincipalName
| join kind=inner (DeviceEvents
| where TimeGenerated >= ago(drive_mount_lookback)
| where ActionType == "UsbDriveMounted"
| extend DriveLetter = tostring(AdditionalFields.DriveLetter)
| summarize MountedDriveLetters = make_set(DriveLetter, 26) by DeviceId, DeviceName)
on DeviceId
| extend TargetDriveLetter = tostring(split(FolderPath, "\\")[0])
| where set_has_element(MountedDriveLetters, TargetDriveLetter)
| join kind=inner (DeviceInfo
| summarize arg_max(TimeGenerated, DeviceId, PublicIP) by DeviceName)
on DeviceId
| project-rename
UserId = UserPrincipalName
| summarize LatestEvent = arg_max(TimeGenerated, *), Files = make_set(FileName, 100) by UserId, InstanceUrl
| extend
CloudAppId = int(32780),
AccountName = tostring(split(UserId, '@')[0]),
UPNSuffix = tostring(split(UserId, '@')[1])
| project
LatestEvent,
UserId,
PublicIP,
Files,
InstanceUrl,
CloudAppId,
AccountName,
UPNSuffix
eventGroupingSettings:
aggregationKind: AlertPerResult
entityMappings:
- entityType: Account
fieldMappings:
- identifier: Name
columnName: AccountName
- identifier: UPNSuffix
columnName: UPNSuffix
- entityType: IP
fieldMappings:
- identifier: Address
columnName: PublicIP
- entityType: CloudApplication
fieldMappings:
- identifier: AppId
columnName: CloudAppId
- identifier: InstanceName
columnName: InstanceUrl
alertDetailsOverride:
alertDisplayNameFormat: Dataverse - terminated user copied files from {{InstanceUrl}}
to USB
alertDescriptionFormat: '{{UserId}} , on the TerminatedUsers watchlist, was found
to copy files to a USB mounted drive.'
customDetails: {}
version: 3.2.0
Stages and Predicates
Parameters
let drive_mount_lookback = 14d;
let query_frequency = 1h;
Stage 1: source
DataverseActivity
Stage 2: distinct
| distinct InstanceUrl
Stage 3: join
| join kind=inner (DeviceFileEvents
| where TimeGenerated >= ago(query_frequency))
on $left.InstanceUrl == $right.FileOriginUrl
Stage 4: join
| join kind=inner (MSBizAppsTerminatedEmployees()) on $left.InitiatingProcessAccountUpn == $right.UserPrincipalName
Stage 5: join
| join kind=inner (DeviceEvents
| where TimeGenerated >= ago(drive_mount_lookback)
| where ActionType == "UsbDriveMounted"
| extend DriveLetter = tostring(AdditionalFields.DriveLetter)
| summarize MountedDriveLetters = make_set(DriveLetter, 26) by DeviceId, DeviceName)
on DeviceId
Stage 6: extend
| extend TargetDriveLetter = tostring(split(FolderPath, "\\")[0])
Stage 7: where
| where set_has_element(MountedDriveLetters, TargetDriveLetter)
Stage 8: join
| join kind=inner (DeviceInfo
| summarize arg_max(TimeGenerated, DeviceId, PublicIP) by DeviceName)
on DeviceId
Stage 9: project-rename
| project-rename
UserId = UserPrincipalName
Stage 10: summarize
| summarize LatestEvent = arg_max(TimeGenerated, *), Files = make_set(FileName, 100) by UserId, InstanceUrl
Stage 11: extend
| extend
CloudAppId = int(32780),
AccountName = tostring(split(UserId, '@')[0]),
UPNSuffix = tostring(split(UserId, '@')[1])
Stage 12: project
| project
LatestEvent,
UserId,
PublicIP,
Files,
InstanceUrl,
CloudAppId,
AccountName,
UPNSuffix
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 |
|---|---|---|
ActionType | eq |
|
TargetDriveLetter | in |
|
Output fields
Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.
| Field | Source |
|---|---|
AccountName | project |
CloudAppId | project |
Files | project |
InstanceUrl | project |
LatestEvent | project |
PublicIP | project |
UPNSuffix | project |
UserId | project |