T1222.001

Windows File and Directory Permissions Modification

Adversaries may modify file or directory permissions on Windows systems using built-in utilities (icacls, cacls, takeown, attrib) or PowerShell ACL cmdlets to bypass access control lists and gain access to protected files. This technique is commonly used by ransomware families (Ryuk, WannaCry, BitPaymer, BlackByte) to take ownership of system files before encryption, by persistence mechanisms preparing hijack targets, and by threat actors (Wizard Spider, Storm-1811) to remove access restrictions on backup and recovery infrastructure. Key patterns include granting Everyone full control (/grant Everyone:F), taking file ownership (takeown /F), resetting ACL inheritance (icacls /reset), and hiding files with attrib +h.

Microsoft Sentinel / Defender
kusto
let SuspiciousIcaclsArgs = dynamic([
  "Everyone:F", "everyone:f",
  "/grant Everyone", "/grant everyone",
  "/T /C /Q", "/t /c /q",
  "/inheritance:r", "/inheritance:d",
  "/reset"
]);
let SuspiciousSystemPaths = dynamic([
  "C:\\Windows\\", "C:\\System32\\", "C:\\Program Files\\",
  "C:\\ProgramData\\", "\\Backup\\", "\\Recovery\\",
  "C:\\Users\\", "%SystemRoot%", "%ProgramFiles%"
]);
// Branch 1: icacls granting Everyone full control or manipulating inheritance
let IcaclsSuspicious = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "icacls.exe"
| where ProcessCommandLine has_any (SuspiciousIcaclsArgs)
| extend AlertReason = case(
    ProcessCommandLine has_any ("Everyone:F", "everyone:f"), "icacls granting Everyone full control",
    ProcessCommandLine has "/inheritance:r", "icacls removing ACL inheritance",
    ProcessCommandLine has "/reset" and ProcessCommandLine has_any (SuspiciousSystemPaths), "icacls resetting ACL on system path",
    ProcessCommandLine has "/grant" and ProcessCommandLine has_any ("/T", "/C", "/Q"), "icacls bulk recursive permission grant",
    "icacls suspicious argument"
  );
// Branch 2: takeown taking ownership of system files
let TakeownSuspicious = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "takeown.exe"
| where ProcessCommandLine has "/F"
| where ProcessCommandLine has_any (SuspiciousSystemPaths)
       or ProcessCommandLine has "/A"  // takeown for Administrators group
       or ProcessCommandLine has "/R"  // recursive
| extend AlertReason = case(
    ProcessCommandLine has_any (SuspiciousSystemPaths), "takeown on protected system path",
    ProcessCommandLine has "/R", "takeown recursive on directory",
    "takeown suspicious usage"
  );
// Branch 3: cacls modifying permissions
let CaclsSuspicious = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "cacls.exe"
| where ProcessCommandLine has_any ("/E /G", "/G Everyone", "/g everyone", "/P", "Everyone:F")
| extend AlertReason = "cacls modifying ACL permissions";
// Branch 4: attrib hiding files or removing system/read-only on sensitive paths
let AttribSuspicious = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "attrib.exe"
| where (ProcessCommandLine has "+h" or ProcessCommandLine has "+s")
       and ProcessCommandLine has_any (SuspiciousSystemPaths)
| extend AlertReason = "attrib hiding/system-flagging file in sensitive path";
// Branch 5: PowerShell Set-Acl granting Everyone full control
let PsAclSuspicious = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has_any ("Set-Acl", "SetAccessRule", "AddAccessRule")
       and ProcessCommandLine has_any ("Everyone", "FullControl", "Allow")
| extend AlertReason = "PowerShell Set-Acl granting excessive permissions";
union IcaclsSuspicious, TakeownSuspicious, CaclsSuspicious, AttribSuspicious, PsAclSuspicious
| extend IsRansomwarePattern = ProcessCommandLine has_any ("Everyone:F", "everyone:f") and (ProcessCommandLine has "/T" or ProcessCommandLine has "/R")
| extend IsBackupTargeting = ProcessCommandLine has_any ("Backup", "backup", "Recovery", "recovery", "vss", "VSS", "shadow", "Shadow")
| extend IsSystemPathTargeted = ProcessCommandLine has_any (SuspiciousSystemPaths)
| project Timestamp, DeviceName, AccountName, AccountDomain, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessParentFileName,
         AlertReason, IsRansomwarePattern, IsBackupTargeting, IsSystemPathTargeted
| sort by Timestamp desc
high severity high confidence

Data Sources

Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives

  • Software installation packages that use icacls to set permissions on their own application directories during setup (e.g., MSI installers, third-party applications)
  • System administrators using takeown and icacls to recover access to accidentally locked files or directories
  • IT automation tools (SCCM, Ansible, Puppet) using PowerShell Set-Acl or icacls to enforce standardized permission baselines across managed endpoints
  • Backup software agents that modify ACLs on their own installation and data directories
  • Vulnerability remediation scripts that reset over-permissive ACLs on shared directories

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections