MacOS provides the option to list specific applications to run when a user logs in. These applications run under the logged in user's context, and will be started every time the user logs in. Login items installed using the Service Management Framework are not visible in the System Preferences and can only be removed by the application that created them (Citation: Adding Login Items). Users have direct control over login items installed using a shared file list which are also visible in System Preferences (Citation: Adding Login Items). These login items are stored in the user's ~/Library/Preferences/ directory in a plist file called com.apple.loginitems.plist (Citation: Methods of Mac Malware Persistence). Some of these applications can open visible dialogs to the user, but they don’t all have to since there is an option to ‘Hide’ the window. If an adversary can register their own login item or modified an existing one, then they can use it to execute their code for a persistence mechanism each time the user logs in (Citation: Malware Persistence on OS X) (Citation: OSX.Dok Malware). The API method SMLoginItemSetEnabled can be used to set Login Items, but scripting languages like AppleScript can do this as well (Citation: Adding Login Items).
T1162は「Login Item(ログインアイテム)」として定義されていた、macOS環境における自動実行・永続化手法です。
T1159(Launch Agent)や T1160(Launch Daemon)が設定ファイル(.plist)をベースにする手法だったのに対し、T1162(Login Item)は「macOSのGUIや公式API、あるいはAppleScriptの仕組みを悪用して、ユーザーがログインした際にアプリやスクリプトを自動起動させる」手法です。
Macユーザーには馴染みの深い、システム設定の「ログイン項目」そのものです。ユーザーがMacにサインインした際、メールアプリやチャットツールを自動的に立ち上げるための正規機能です。
攻撃者はこの仕組みを悪用し、マルウェア(遠隔操作ツールなど)をログイン項目へと滑り込ませます。実行権限はログインしたユーザーのものになるため、管理者権限(root権限)を持たない初期侵入の段階から利用できるという特徴があります。
攻撃者がこの自動起動を仕込む際、主に以下の2つのアプローチ(API/スクリプト)が使われます。それぞれ検知の難易度が異なります。
macOSの「LaunchServices」という機能を使い、ログイン時に開くファイルのリスト(共有ファイルリスト)にマルウェアのパスを追加します。
applescript
tell application "System Events" to make login item at end with properties {path:"/path/to/malware", hidden:true}
hidden:true を指定することで、起動時にウィンドウを開かずバックグラウンドでこっそり実行させることが可能です)。アプリ開発者向けの公式APIである SMLoginItemSetEnabled を悪用する高度な手口です。
手口:
攻撃者が作成したアプリ(App Bundle)の内部(Contents/Library/LoginItems/)にヘルパーアプリとしてマルウェアを仕込み、API経由でそれを有効化します。
特徴:
この方法でインストールされたログインアイテムは、launchd によって制御されるため、Macの「システム設定」の画面には一切表示されません。 ユーザーがGUIから気づいて削除することが不可能なため、非常に高いステルス性を持ちます。
侵入とマルウェア設置:
フィッシングメールなどを経由してMacに侵入し、ユーザーのホームディレクトリ内など(例: ~/Library/Application Support/)にバックドアを設置します。
自動起動の登録:
osascript コマンド)を実行して共有ファイルリストに登録する。継続的なアクセス:
ユーザーがMacを再起動したり、ログアウト後に再ログインするたびに、バックドアが自動的に起動し、C2サーバーへの接続を確立します。
設定ファイルや不審なコマンドの動きを捉える必要があります。
永続化ファイルの監視:
AppleScript等で登録されたログイン項目は、以下のデータファイルに書き込まれます。このファイルの作成・変更をEDRなどで監視します。
~/Library/Application Support/com.apple.backgroundtaskmanagementagent/backgrounditems.btmAppleScriptの実行ログ監視:
コマンドライン引数に "login item" や "hidden:true" といった文字列が含まれる不審な osascript(AppleScriptを実行するバイナリ)のプロセス生成を検知します。
不審な親プロセスのチェック:
ログイン直後に、ユーザーの意図しないタイミングで、LaunchServices やアプリ内の LoginItems フォルダから未知のバイナリが起動していないかをプロセスツリーで確認します。
T1159(Launch Agent)とT1162(Login Item)は、どちらも「ユーザーログイン時」に動くため混同されがちですが、「plistという設定ファイルを書くか(Agent)」「OSのLaunchServicesやAPIに直接登録するか(Login Item)」 という実装の違いがあります。
調査の際は、不審なplistがないからと安心せず、backgrounditems.btm の改ざんや、アプリ bundle 内に隠された隠しログインアイテムの有無まで目を光らせるのがセオリーです。
この攻撃手法を利用する脅威アクターは登録されていません。
この攻撃手法に関連する CVE は登録されていません。