T1070.004

File Deletion

Adversaries delete files created during their intrusion to remove forensic evidence of their presence. This includes malware droppers, staged tools, credential harvest output files, scan results, and exfiltrated data copies. Common methods include the del or erase commands on Windows, rm or unlink on Linux/macOS, PowerShell Remove-Item, and specialized secure-deletion tools like SDelete (Sysinternals) which overwrites file content before deletion to prevent recovery. Self-deleting malware (RansomHub, SamSam, ProLock, APT38's CLOSESHAVE utility, TeamTNT, Aquatic Panda) is extremely common — the malware executes then schedules its own deletion via cmd.exe /c del commands or moves itself to TEMP and deletes. Detection relies on correlating file creation events with rapid subsequent deletion, process lineage anomalies (svchost.exe or Office processes deleting files from TEMP), and behavioral baselining of which processes legitimately delete from which directories.

Microsoft Sentinel / Defender
kusto
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType == "FileDeleted"
| where (
    // Executables/scripts deleted from staging directories
    (FolderPath has_any ("\\Temp\\", "\\AppData\\Local\\Temp\\", "\\ProgramData\\", "\\Users\\Public\\", "\\Windows\\Temp\\")
     and (FileName endswith ".exe" or FileName endswith ".dll" or FileName endswith ".bat"
          or FileName endswith ".ps1" or FileName endswith ".vbs" or FileName endswith ".js"
          or FileName endswith ".hta" or FileName endswith ".cmd"))
    or
    // SDelete usage (overwrites then deletes — generates high-volume file events)
    (InitiatingProcessFileName =~ "sdelete.exe" or InitiatingProcessFileName =~ "sdelete64.exe")
    or
    // Process deleting its own executable (self-deletion pattern)
    (InitiatingProcessFolderPath =~ FolderPath and InitiatingProcessFileName =~ FileName)
)
| where InitiatingProcessFileName !in~ ("msiexec.exe", "setup.exe", "uninstall.exe", "MpSigStub.exe",
                                         "TiWorker.exe", "TrustedInstaller.exe")
| project Timestamp, DeviceName, AccountName, FileName, FolderPath, ActionType,
         InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessAccountName
| sort by Timestamp desc
medium severity medium confidence

Data Sources

File: File Deletion Process: Process Creation Microsoft Defender for Endpoint

Required Tables

DeviceFileEvents DeviceProcessEvents

False Positives

  • Legitimate software installers and updaters that clean up temporary files after installation completes
  • Antivirus quarantine and remediation tools deleting malware samples they have identified and contained
  • Build systems and CI/CD pipelines that compile code and clean up intermediate artifacts in TEMP directories
  • IT management tools like SCCM or PDQ that deploy and remove packages, leaving temporary files that are then cleaned up

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections