Boot or Logon Initialization Scripts: Logon Script (Mac)

Adversaries may use macOS logon scripts automatically executed at logon initialization to establish persistence. macOS allows logon scripts (known as login hooks) to be executed whenever a specific user logs into a system. A login hook tells Mac OS X to execute a certain script when a user logs in, but unlike Startup Items, a login hook executes as the elevated root user.[1]

Adversaries may use these login hooks to maintain persistence on a single system.[2] Access to login hook scripts may allow an adversary to insert additional malicious code. There can only be one login hook at a time though and depending on the access configuration of the hooks, either local credentials or an administrator account may be necessary.

ID: T1037.002
Sub-technique of:  T1037
Platforms: macOS
Version: 1.0
Created: 10 January 2020
Last Modified: 27 March 2020
Provided by LAYER 8

Mitigations

ID Mitigation Description
M1022 Restrict File and Directory Permissions

Restrict write access to logon scripts to specific administrators.

Detection

ID Data Source Data Component
DS0017 Command Command Execution
DS0022 File File Creation
File Modification
DS0009 Process Process Creation

Monitor logon scripts for unusual access by abnormal users or at abnormal times. Look for files added or modified by unusual accounts outside of normal administration duties. Monitor running process for actions that could be indicative of abnormal programs or executables running upon logon.

References