Detection of Unauthorized macOS Launch Service Persistence
Adversaries achieve persistence on macOS by creating or modifying launch agent or daemon plist files and immediately loading them into the launchd subsystem using the launchctl utility.
Adversaries targeting macOS systems often seek to establish persistence to ensure their malicious payloads survive system reboots or user logouts. A primary method for achieving this is through the abuse of macOS launch services, specifically by creating or modifying property list (plist) files within designated LaunchAgent or LaunchDaemon directories. By placing a configuration file in these locations, an attacker defines a service that the operating system's launchd subsystem will execute automatically. To finalize this process, attackers typically use the launchctl utility to manually load or bootstrap the newly created service into the system configuration. This sequence of file creation followed by immediate service activation is a strong indicator of persistence establishment and should be closely monitored by security teams to detect unauthorized background execution.
Attack Chain
- Attacker gains initial access or code execution on the macOS endpoint.
- Attacker prepares a malicious payload (script or binary) to be executed.
- Attacker creates or modifies a plist configuration file defining the service.
- Attacker writes the plist file to a persistence directory (e.g., /Library/LaunchAgents/).
- Attacker executes
launchctlwith theloadorbootstrapargument. - The
launchdprocess processes the request and registers the new service. - The malicious service is now configured to run automatically upon system start or login.
- Final objective: persistence for recurring malicious activity or exfiltration.
Impact
Successful exploitation allows attackers to maintain long-term, stealthy control over the compromised macOS host. This permits continuous exfiltration of data, recurring monitoring of user activity, or periodic command-and-control communication, significantly increasing the difficulty of incident remediation and eradication.
Recommendation
Prioritize the identification of unauthorized modifications to launch service directories and the subsequent invocation of launchctl.
- Deploy the Sigma rule provided below to identify sequences of plist creation followed by
launchctlservice loading. - Review all current LaunchAgent and LaunchDaemon plists in
/System/Library/,/Library/, and/Users/*/Library/for suspicious executables. - Establish a baseline of legitimate software that requires launch service persistence to reduce false positives during incident response.
Immediate actions
Deploy the Sigma detection rule to the SIEM and calibrate against known software install paths.
Threat Hunt
Identify all currently running services launched via launchctl from user-writable directories.
Data: Process tree logs, Filesystem integrity logs
Mitigations
Implement strict file integrity monitoring (FIM) on /Library/LaunchAgents and /Library/LaunchDaemons.
T1543
Detection coverage 1
Detect macOS Launch Service Creation and Immediate Loading
lowDetects the creation or modification of a launch agent or daemon plist file followed by the immediate execution of launchctl to load the service.
Detection queries are available on the platform. Get full rules →