Trusted Design

T1501 - Systemd Service

概要

Systemd services can be used to establish persistence on a Linux system. The systemd service manager is commonly used for managing background daemon processes (also known as services) and other system resources.(Citation: Linux man-pages: systemd January 2014)(Citation: Freedesktop.org Linux systemd 29SEP2018) Systemd is the default initialization (init) system on many Linux distributions starting with Debian 8, Ubuntu 15.04, CentOS 7, RHEL 7, Fedora 15, and replaces legacy init systems including SysVinit and Upstart while remaining backwards compatible with the aforementioned init systems.

Systemd utilizes configuration files known as service units to control how services boot and under what conditions. By default, these unit files are stored in the /etc/systemd/system and /usr/lib/systemd/system directories and have the file extension .service. Each service unit file may contain numerous directives that can execute system commands.

Adversaries have used systemd functionality to establish persistent access to victim systems by creating and/or modifying service unit files that cause systemd to execute malicious commands at recurring intervals, such as at system boot.(Citation: Anomali Rocke March 2019)(Citation: gist Arch package compromise 10JUL2018)(Citation: Arch Linux Package Systemd Compromise BleepingComputer 10JUL2018)(Citation: acroread package compromised Arch Linux Mail 8JUL2018)

While adversaries typically require root privileges to create/modify service unit files in the /etc/systemd/system and /usr/lib/systemd/system directories, low privilege users can create/modify service unit files in directories such as ~/.config/systemd/user/ to achieve user-level persistence.(Citation: Rapid7 Service Persistence 22JUNE2016)

管理者によるコメント

T1501 は、Linuxのサービス管理機構を悪用した自動実行手法「Systemd Service(Systemdサービスの悪用)」として定義されています。

1. 概要(攻撃者は何を実現できるのか?)

この手法で攻撃者は、「Linuxサーバーが起動した瞬間から、ユーザーのログイン状態に関係なく、OSの最高権限(root)を伴ったバックドアをバックグラウンドで完全常駐させること」を実現します。

2. 攻撃の流れ

Systemdサービスは、特定のフォルダ内に配置された .service という拡張子の設定ファイル(ユニットファイル)で管理されています。攻撃者はここに独自のファイルをねじ込みます。

  1. 初期侵入と管理者権限の確保:
    Webアプリケーションの脆弱性(RCEなど)を突いてLinuxサーバーに侵入し、他の脆弱性を悪用して管理者権限(root)へと昇格します。

  2. マルウェア(バイナリやスクリプト)の配置:
    遠隔操作用ツール(RAT)や仮想通貨マイニング用のプログラム(例: .sshdkswapd など、正規プロセスを装った名前)を、/usr/local/bin/ などの目立たないフォルダに配置します。

  3. 悪意あるサービスファイルの作成・設置:
    システム全体を管理する以下のいずれかのSystemd用フォルダに、新しいサービスファイル(例: com.system.security.service など)を作成します。

    • 配置先フォルダ: /etc/systemd/system/ または /lib/systemd/system/

ファイル内には以下のような「永続化設定」を記述します。

``` [Unit] Description=System Security Daemon # もっともらしい説明文

[Service] Type=simple ExecStart=/usr/local/bin/マルウェアのパス # 手順2の不正プログラムを指定 Restart=always # プロセスが落ちたら即座に再起動させる

[Install] WantedBy=multi-user.target # OS起動時に自動実行させる設定

```

  1. リロードと有効化(トリガー):
    攻撃者はコマンドを実行し、作成したサービスをシステムに認識させ、次回の再起動を待たずにその場で強制起動します。

``` systemctl daemon-reload systemctl enable com.system.security.service systemctl start com.system.security.service

```

3. 防御・対策

Systemdフォルダのファイル整合性と、サービス登録時のコマンドラインを監視するのが最も効果的です。

4. 重要ポイント

5. 関連する主なCWE

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

Linuxサーバーを狙うあらゆるAPT(国家系ハッカー)や、ボットネット、暗号資産マイニングマルウェアにとって「必須」と言えるほど定番の手法です。

実務上のアドバイス

Linuxサーバーで「原因不明の高負荷が続いている」「怪しいプロセスを殺しても即座に復活する」という場合は、ターミナルで以下のコマンドを叩き、登録されているサービスの一覧と状態を確認してください。

``` systemctl list-unit-files --type=service

```

各サービスの .service ファイルの実体を確認し、ExecStart= に指定されているバイナリのパスが本当に正規のもの(/usr/bin/ ではなく /tmp/ や不自然な隠しフォルダになっていないか)を点検することが、Systemdを悪用した潜伏を暴くための最も確実な手順となります。

分析

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

この攻撃手法を利用する脅威アクターは登録されていません。

関連する CVE

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


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