T1074 Microsoft Sentinel · KQL

Detect Data Staged in Microsoft Sentinel

Adversaries may stage collected data in a central location or directory prior to exfiltration. Data may be kept in separate files or combined into one file through archiving techniques. Adversaries choose staging to minimize the number of connections made to their C2 server and better evade detection. Staging locations are commonly temp directories, user profile folders, or hidden directories. In cloud environments, adversaries may stage data within a particular instance before exfiltration.

MITRE ATT&CK

Tactic
Collection
Technique
T1074 Data Staged
Canonical reference
https://attack.mitre.org/techniques/T1074/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
let StagingPaths = dynamic([
  "\\Temp\\", "\\tmp\\", "\\AppData\\Local\\Temp\\",
  "\\AppData\\Roaming\\", "\\ProgramData\\",
  "\\Users\\Public\\", "\\Windows\\Temp\\"
]);
let StagingExtensions = dynamic([".zip", ".7z", ".rar", ".tar", ".gz", ".cab", ".iso"]);
let BulkCopyProcesses = dynamic(["robocopy.exe", "xcopy.exe", "copy", "cp", "rsync"]);
// Branch 1: Bulk file creation events in staging paths
let BulkFileStaging =
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified")
| where FolderPath has_any (StagingPaths)
| summarize FileCount=count(), Extensions=make_set(tolower(tostring(split(FileName, ".")[-1]))), FirstSeen=min(Timestamp), LastSeen=max(Timestamp)
    by DeviceName, InitiatingProcessAccountName, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath
| where FileCount >= 10
| extend StagingType="BulkFileStaging"
| project Timestamp=LastSeen, DeviceName, AccountName=InitiatingProcessAccountName,
    InitiatingProcessFileName, InitiatingProcessCommandLine,
    FolderPath, FileCount, Extensions, StagingType;
// Branch 2: Archive files created in staging paths
let ArchiveStaging =
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType == "FileCreated"
| where FolderPath has_any (StagingPaths)
| where FileName has_any (StagingExtensions)
| extend StagingType="ArchiveCreated"
| project Timestamp, DeviceName, AccountName=InitiatingProcessAccountName,
    InitiatingProcessFileName, InitiatingProcessCommandLine,
    FolderPath, FileName, StagingType;
// Branch 3: Bulk copy commands executed
let BulkCopyStaging =
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("robocopy.exe", "xcopy.exe", "cmd.exe", "powershell.exe")
| where ProcessCommandLine has_any ("robocopy", "xcopy", "copy /", "Copy-Item", "cp -r")
    and ProcessCommandLine has_any (StagingPaths)
| extend StagingType="BulkCopyCommand"
| project Timestamp, DeviceName, AccountName, FileName,
    ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine,
    StagingType;
union BulkFileStaging, ArchiveStaging, BulkCopyStaging
| sort by Timestamp desc
high severity medium confidence

Detects data staging behaviors using Microsoft Defender for Endpoint tables. Three detection branches: (1) bulk file creation events in common staging paths where 10+ files are written by the same process, indicating automated data aggregation; (2) archive files created in staging directories, suggesting compression before exfiltration; (3) bulk copy commands (robocopy, xcopy, Copy-Item) targeting staging directories. Uses DeviceFileEvents for file-level telemetry and DeviceProcessEvents for command-line analysis.

Data Sources

File: File CreationFile: File ModificationProcess: Process CreationCommand: Command ExecutionMicrosoft Defender for Endpoint

Required Tables

DeviceFileEventsDeviceProcessEvents

False Positives & Tuning

  • Software installation processes that extract files to temp directories during setup (installers, MSI packages)
  • Backup agents (Veeam, Backup Exec, Windows Backup) that stage files before writing to backup media
  • Software deployment tools (SCCM, Intune) copying update packages to staging directories
  • Log aggregation tools that collect and consolidate logs into a single directory for shipping
  • Developers using robocopy/xcopy in legitimate build scripts or deployment pipelines
Download portable Sigma rule (.yml)

Other platforms for T1074


Testing Methodology

Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Stage Sensitive Files to Temp Directory Using Robocopy

    Expected signal: Sysmon Event ID 1: Process Create with Image=robocopy.exe, CommandLine containing source and destination temp paths with /E /COPYALL flags. Sysmon Event ID 11: Multiple FileCreate events in %TEMP%\df00tech-stage\ for each copied file. Security Event ID 4688 (if command line auditing enabled) for robocopy.exe execution. DeviceProcessEvents and DeviceFileEvents will capture this in MDE environments.

  2. Test 2Stage and Compress Data Using 7-Zip from Command Line

    Expected signal: Sysmon Event ID 1: Process Create for cmd.exe with copy command, then 7z.exe with -p flag (password) targeting staging directory. Sysmon Event ID 11: FileCreate events for each copied file in df00tech-collection\, then FileCreate for df00tech-exfil.zip. The -p flag in 7z.exe command line indicates password protection — a high-fidelity indicator of malicious intent.

  3. Test 3Stage Data Using PowerShell Copy-Item to ProgramData

    Expected signal: Sysmon Event ID 1: Process Create for powershell.exe with Copy-Item in CommandLine targeting C:\ProgramData\MicrosoftUpdates. Sysmon Event ID 11: Multiple FileCreate events in C:\ProgramData\MicrosoftUpdates\. Sysmon Event ID 12/13: Registry or attribute change if attrib command is monitored. The directory name 'MicrosoftUpdates' is a common masquerading technique — look for this in DeviceFileEvents FolderPath.

  4. Test 4Linux Data Staging Using cp and tar

    Expected signal: Linux auditd syscall events (if configured): open/creat syscalls for files in /tmp/.df00tech_stage/, execve for cp, find, tar commands. Syslog entries if auditd rules cover /tmp/ writes. If Sysmon for Linux is deployed: Sysmon Event ID 11 for file creations, Event ID 1 for process creation with tar czf command. The hidden directory name (.df00tech_stage with leading dot) indicates deliberate concealment.

  5. Test 5Remote Data Staging via Network Share Copy

    Expected signal: Sysmon Event ID 1: Process Create for net.exe (net use) with UNC path and xcopy.exe with /E /H /Y flags. Sysmon Event ID 3: Network Connection to target host on port 445 (SMB). Sysmon Event ID 11: FileCreate events in staging directory. Security Event ID 4648 (explicit credential logon) if credentials were provided to net use. Security Event ID 5140/5145 (network share access) on the target host if SMB auditing is enabled.

Unlock Pro Content

Get the full detection package for T1074 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections