Detection of Unauthorized Remote SSH Service Enablement on macOS
Adversaries may use the systemsetup or launchctl commands to programmatically enable remote SSH services on macOS to facilitate persistence and lateral movement.
Adversaries targeting macOS systems may attempt to establish remote access for persistence or lateral movement by enabling the built-in Secure Shell (SSH) service. The standard method for this is the systemsetup utility, specifically the -setremotelogin argument, or by interacting directly with the launchctl service manager to load the SSH daemon (sshd). While legitimate administrative tasks (such as those performed by Jamf) frequently require this capability, unauthorized execution of these commands - particularly by non-administrative user accounts - is a high-signal indicator of adversary activity. Defenders should monitor for these process execution patterns to identify configuration changes that deviate from standard deployment baselines.
Attack Chain
- The attacker gains initial access to the target macOS host via an exploit or user-executed malware.
- The attacker identifies that remote management is disabled, limiting their ability to maintain access or move laterally.
- The attacker executes
systemsetup -setremotelogin onto enable the SSH service. - Alternatively, the attacker uses
launchctl loadto bootstrapcom.openssh.sshdifsystemsetupis restricted. - The attacker potentially adds an authorized SSH key to the target user's
~/.ssh/authorized_keysfile. - The attacker establishes a persistent remote connection to the host using the newly enabled SSH service for command-and-control.
- The attacker uses the established SSH session to perform internal network reconnaissance and lateral movement.
Impact
Successful exploitation allows attackers to bypass security controls, maintain long-term persistence on the compromised host, and utilize the host as a jump box to pivot into the internal network. This compromises the confidentiality and integrity of the affected workstation and its associated user accounts.
Recommendation
- Deploy the provided Sigma rule to monitor for unauthorized execution of
systemsetupandlaunchctlfor SSH-related configuration changes. - Baseline your organization's use of automated administrative tools (e.g., Jamf, Kandji, or custom management scripts) and create specific exclusion filters for these known-good parent processes.
- Restrict administrative privileges on macOS endpoints to reduce the likelihood of unauthorized users executing system-level configuration changes.
- Monitor process execution logs for suspicious parent-child relationships, specifically looking for
systemsetuporlaunchctlspawned by shells or unknown binaries.
Immediate actions
Deploy the Sigma rule to identify unauthorized SSH configuration changes.
Detection coverage 1
Detect Unauthorized SSH Remote Login Enablement
mediumDetects the use of systemsetup or launchctl to enable or load the SSH service on macOS, excluding known management tools.
Detection queries are available on the platform. Get full rules →