Trusted Design

T1160 - Launch Daemon

概要

Per Apple’s developer documentation, when macOS and OS X boot up, launchd is run to finish system initialization. This process loads the parameters for each launch-on-demand system-level daemon from the property list (plist) files found in /System/Library/LaunchDaemons and /Library/LaunchDaemons (Citation: AppleDocs Launch Agent Daemons). These LaunchDaemons have property list files which point to the executables that will be launched (Citation: Methods of Mac Malware Persistence).

Adversaries may install a new launch daemon that can be configured to execute at startup by using launchd or launchctl to load a plist into the appropriate directories (Citation: OSX Malware Detection). The daemon name may be disguised by using a name from a related operating system or benign software (Citation: WireLurker). Launch Daemons may be created with administrator privileges, but are executed under root privileges, so an adversary may also use a service to escalate privileges from administrator to root.

The plist file permissions must be root:wheel, but the script or program that it points to has no such requirement. So, it is possible for poor configurations to allow an adversary to modify a current Launch Daemon’s executable and gain persistence or Privilege Escalation.

管理者によるコメント

T1160は「Launch Daemon(ローンチデーモン)」として定義されていた、macOS環境における極めて強力な自動実行・特権昇格手法です。

T1159「Launch Agent」と対になる仕組みですが、Launch Daemonは「OSの起動直後に、ユーザーのログインに関係なく root(最高権限)で自動実行される」という、より強力で危険な性質を持っています。

1. 概要

この手法で攻撃者は、「Macの電源が入った瞬間から、OSの最高権限(root)で動作し続ける、文字通りの『完全なバックドア』」を実現します。

何を実現できるのか

2. Launch Agent(T1159)との決定的な違い

macOSのサービス管理フレームワーク launchd が読み込むファイルですが、配置場所と権限が異なります。

項目 Launch Agent (T1159) Launch Daemon (T1160)
実行タイミング ユーザーがログインした直後 OSが起動した直後(ログイン前)
実行権限 ログインしたユーザーの権限 システムのroot権限(最高権限)
配置フォルダ `~/Library/LaunchAgents/` など `/Library/LaunchDaemons/`
必要な設置権限 一般ユーザー権限で作成可能 管理者権限(sudo / root)が必要

3. 攻撃の流れ

Launch Daemonを登録するためには、攻撃者は事前にシステム内での管理者権限(Administrator権限またはsudo権限)を確保している必要があります。

  1. マルウェアの配置:
    攻撃者は永続化させたい不正なバイナリ(RATなど)を、システムフォルダ内(例: /usr/local/bin/ などの目立たない場所)に配置します。

  2. 悪意あるPlistの作成と配置:
    管理者権限(sudo)を悪用して、以下のデーモン専用フォルダに新しい .plist(プロパティリスト)ファイルを作成して設置します。

    • 配置先: /Library/LaunchDaemons/

.plist 内には、以下のようなバックドアの永続化設定を書き込みます。

* `RunAtLoad`: `true`(起動時に自動実行)
* `KeepAlive`: `true`(プロセスが落とされたらOSが自動で再起動する)
* `ProgramArguments`: (手順1で置いたマルウェアのパスを指定)
  1. 即時実行(または再起動待機):
    攻撃者は launchctl load /Library/LaunchDaemons/bad.plist コマンドを使って、再起動を待たずにその場でroot権限のマルウェアを強制起動させるか、次回のシステム再起動を待ちます。

4. 防御・対策

最高権限の永続化ポイントであるため、厳重な監視が必要です。

5. 関連する主なCWE

6. 関連する代表的な事例

Macを標的にする高度なAPTグループが、最終的な「絶対的な足場」として利用します。

実務上のアドバイス

Launch Daemonによる永続化は、KeepAlive 設定が有効になっていることが多く、「タスクマネージャー(アクティビティモニタ)で怪しいプロセスを見つけて強制終了しても、1秒後にOSが親切にroot権限で再起動してくる」というゾンビのような挙動を示します。

対処する際は、プロセスを殺す前にまずターミナルで sudo launchctl unload /Library/LaunchDaemons/[怪しいファイル].plist を実行してOSの自動起動設定を解除し、その後に対象の .plist ファイルと実行可能バイナリを削除する必要があります。

分析

この攻撃手法を利用する脅威アクター

関連する CVE

攻撃手法 – 脅威アクター Graph


← Technique一覧に戻る ← Tactics一覧に戻る