T1053.004

Launchd

Adversaries may abuse the launchd daemon to perform task scheduling for initial or recurring execution of malicious code on macOS. The launchd daemon is responsible for loading and maintaining services within the operating system. It processes property list (plist) files found in /System/Library/LaunchDaemons, /Library/LaunchDaemons (system-wide daemons run as root), /Library/LaunchAgents (user agents run for all users), and ~/Library/LaunchAgents (user agents run for the specific user). Adversaries may install malicious plist files in these directories to achieve persistence, privilege escalation (via LaunchDaemons running as root), or execution at system startup or login. This technique is noted as deprecated by MITRE due to inaccurate original characterization, but the underlying abuse of launchd-controlled directories remains a valid and observed persistence mechanism on macOS.

Microsoft Sentinel / Defender
kusto
// Detection for T1053.004 - Launchd abuse on macOS via Microsoft Defender for Endpoint
// Detects plist file creation/modification in LaunchDaemon/LaunchAgent directories
// and suspicious launchctl usage
let LaunchDaemonPaths = dynamic([
  "/Library/LaunchDaemons/",
  "/System/Library/LaunchDaemons/",
  "/Library/LaunchAgents/",
  "/System/Library/LaunchAgents/"
]);
let UserLaunchAgentPattern = "/Library/LaunchAgents/";
let SuspiciousParents = dynamic([
  "bash", "sh", "zsh", "python", "python3", "ruby", "perl",
  "curl", "wget", "osascript", "node"
]);
// Detect plist file creation in LaunchDaemon/LaunchAgent directories
let PlistFileCreation = DeviceFileEvents
| where Timestamp > ago(24h)
| where OSPlatform =~ "macOS" or DeviceType =~ "Mac"
| where FolderPath has_any (LaunchDaemonPaths)
| where FileName endswith ".plist"
| where ActionType in ("FileCreated", "FileModified", "FileRenamed")
| extend AlertType = "PlistCreatedInLaunchDirectory"
| extend IsDaemon = FolderPath has "/Library/LaunchDaemons/"
| extend IsSystemPath = FolderPath has "/System/Library/"
| project Timestamp, DeviceName, AccountName, FileName, FolderPath,
          InitiatingProcessFileName, InitiatingProcessCommandLine,
          InitiatingProcessAccountName, ActionType, AlertType, IsDaemon, IsSystemPath;
// Detect suspicious launchctl load/bootstrap commands
let LaunchctlSuspicious = DeviceProcessEvents
| where Timestamp > ago(24h)
| where OSPlatform =~ "macOS" or DeviceType =~ "Mac"
| where FileName =~ "launchctl"
| where ProcessCommandLine has_any ("load", "bootstrap", "submit", "start")
| where InitiatingProcessFileName has_any (SuspiciousParents)
       or ProcessCommandLine has_any ("/tmp/", "/var/tmp/", "/dev/shm", ".hidden",
                                       "curl", "wget", "base64", "/Users/Shared/")
| extend AlertType = "SuspiciousLaunchctlExecution"
| extend IsDaemon = ProcessCommandLine has "/Library/LaunchDaemons/"
| extend IsSystemPath = ProcessCommandLine has "/System/Library/"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine,
          InitiatingProcessAccountName, AlertType, IsDaemon, IsSystemPath;
// Union both detections
PlistFileCreation
| extend ProcessCommandLine = InitiatingProcessCommandLine
| union (LaunchctlSuspicious
         | extend FileName = FileName, FolderPath = "", ActionType = "ProcessCreated")
| sort by Timestamp desc
high severity medium confidence

Data Sources

File: File Creation File: File Modification Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint (macOS)

Required Tables

DeviceFileEvents DeviceProcessEvents

False Positives

  • Legitimate software installation (Homebrew, macOS app installers, enterprise MDM) creating plist files in LaunchDaemons or LaunchAgents directories
  • IT management tools (Jamf Pro, Puppet, Chef, Ansible) deploying configuration via launchctl load as part of policy enforcement
  • Developer tools and package managers (e.g., Homebrew services) that register background services using plist files
  • macOS system updates modifying plist files in /System/Library paths
  • Monitoring agents (CrowdStrike, Carbon Black, SentinelOne endpoint sensors) installing their own LaunchDaemon plist files

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections