← Back to SOC feed Coverage →

detect-exfiltration-after-termination

kql MEDIUM Azure-Sentinel
DeviceFileEventsDeviceNetworkEvents
backdoorhuntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-21T11:00:00Z · Confidence: medium

Hunt Hypothesis

A terminated employee may exfiltrate large amounts of data before leaving the organization, indicating potential data theft or insider threat. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify and mitigate data loss risks early.

KQL Query

// Look for any activity for terminated employee creating a DeviceNetworkEvents after they announced termination or resignation
let TermAccount = 'departing.employee'; //Enter the departing employee's username
let ReleaseTime = datetime("01/16/2022 00:00:00"); //Enter the date the resignation or termination was announced
DeviceNetworkEvents
| where InitiatingProcessAccountName =~ TermAccount
| where Timestamp  > ReleaseTime
//| project Timestamp , DeviceName, InitiatingProcessAccountName
| sort by Timestamp  desc
| join 
DeviceFileEvents on InitiatingProcessAccountName
| where FileName endswith ".docx" or FileName endswith ".pptx" or FileName endswith ".xlsx" or FileName endswith ".pdf"
| join DeviceNetworkInfo on DeviceId
| where ConnectedNetworks !contains '"Category":"Domain"'  //Looking for remote, non-domain networks
| summarize TotalFiles=count() by bin(5Minutebin=Timestamp, 5m), InitiatingProcessAccountName
|where TotalFiles >1000 // adjust accordingly
| project TotalFiles,5Minutebin,InitiatingProcessAccountName

Analytic Rule Definition

id: 69ceaac7-5ea1-4a09-a8ce-b240210b8d2f
name: detect-exfiltration-after-termination
description: |
  This query can be used to explore any instances where a terminated individual (i.e. one who has an impending termination date but has not left the company) downloads a large number of files from a non-Domain network address.
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - DeviceNetworkEvents
  - DeviceFileEvents
  - DeviceNetworkInfo
tactics:
- Exfiltration
query: |
  // Look for any activity for terminated employee creating a DeviceNetworkEvents after they announced termination or resignation
  let TermAccount = 'departing.employee'; //Enter the departing employee's username
  let ReleaseTime = datetime("01/16/2022 00:00:00"); //Enter the date the resignation or termination was announced
  DeviceNetworkEvents
  | where InitiatingProcessAccountName =~ TermAccount
  | where Timestamp  > ReleaseTime
  //| project Timestamp , DeviceName, InitiatingProcessAccountName
  | sort by Timestamp  desc
  | join 
  DeviceFileEvents on InitiatingProcessAccountName
  | where FileName endswith ".docx" or FileName endswith ".pptx" or FileName endswith ".xlsx" or FileName endswith ".pdf"
  | join DeviceNetworkInfo on DeviceId
  | where ConnectedNetworks !contains '"Category":"Domain"'  //Looking for remote, non-domain networks
  | summarize TotalFiles=count() by bin(5Minutebin=Timestamp, 5m), InitiatingProcessAccountName
  |where TotalFiles >1000 // adjust accordingly
  | project TotalFiles,5Minutebin,InitiatingProcessAccountName

Required Data Sources

Sentinel TableNotes
DeviceFileEventsEnsure this data connector is enabled
DeviceNetworkEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Exfiltration/detect-exfiltration-after-termination.yaml