Trusted Design

T1138 - Application Shimming

概要

The Microsoft Windows Application Compatibility Infrastructure/Framework (Application Shim) was created to allow for backward compatibility of software as the operating system codebase changes over time. For example, the application shimming feature allows developers to apply fixes to applications (without rewriting code) that were created for Windows XP so that it will work with Windows 10. (Citation: Elastic Process Injection July 2017) Within the framework, shims are created to act as a buffer between the program (or more specifically, the Import Address Table) and the Windows OS. When a program is executed, the shim cache is referenced to determine if the program requires the use of the shim database (.sdb). If so, the shim database uses Hooking to redirect the code as necessary in order to communicate with the OS.

A list of all shims currently installed by the default Windows installer (sdbinst.exe) is kept in:

Custom databases are stored in:

To keep shims secure, Windows designed them to run in user mode so they cannot modify the kernel and you must have administrator privileges to install a shim. However, certain shims can be used to Bypass User Account Control (UAC) (RedirectEXE), inject DLLs into processes (InjectDLL), disable Data Execution Prevention (DisableNX) and Structure Exception Handling (DisableSEH), and intercept memory addresses (GetProcAddress). Similar to Hooking, utilizing these shims may allow an adversary to perform several malicious acts such as elevate privileges, install backdoors, disable defenses like Windows Defender, etc.

管理者によるコメント

T1138は「Application Shimming(アプリケーション・シミング)」として定義されていた、Windowsの互換性維持機能を逆手に取った高度な攻撃手法です。

Windowsが古いソフトウェアを新しいOSでも動かせるように用意している「互換性スタック(Shim)」という仕組みを悪用し、特定のアプリケーションが起動した際にマルウェア(DLL)を自動的にプロセスインジェクション(強制注入)させる手法です。主に「永続化(Persistence)」と「防御回避(Defense Evasion)」に利用されます。

1. 「Shim(シム)」とは?

Windowsにおける「Shim(詰め木・隙間テープの意味)」とは、OSのバージョンアップによって動かなくなった古いアプリを、ソースコードを書き換えることなく動かすための救済システムです。

たとえば、Windows XP向けに作られた古い業務アプリをWindows 11で動かす際、Windowsがそのアプリと最新OSの「仲介役」となり、アプリからの古い命令(API呼び出し)を最新の命令に裏で変換してあげます。この仲介設定をまとめたデータベースファイルを .sdb (Shim Database) と呼びます。

攻撃者は、この「裏で命令をパッと書き換えて中継する」というShimの強力な挙動(フッキング機能)を、そのままマルウェアの起動に悪用します。

2. 攻撃の流れ

カスタムのShimデータベースをシステムに登録・適用するため、攻撃者は事前にシステム内での管理者権限(Administrator)を確保している必要があります。

  1. 悪意のあるShimの作成:
    攻撃者はマイクロソフト公式の検証ツール(Application Compatibility Toolkit)などを使い、独自の .sdb ファイルを作成します。

    • このファイルの中に、「(例)iexplore.exe(Internet Explorer)や notepad.exe(メモ帳)が起動した時、特定のマルウェアDLLをそのメモリに注入(インジェクション)して実行する」というルールを仕込みます。
  2. データベースの登録:
    Windows標準のコマンドである sdbinst.exe(Shimデータベースインストーラー)を悪用して、作成した .sdb ファイルをシステムにインストールします。

    • コマンドの例: sdbinst.exe evil_shim.sdb
  3. レジストリへの自動反映:
    このコマンドが実行されると、Windowsは自動的に以下のレジストリキーにShimの情報を登録します。

    • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Custom
  4. 自動実行と隠蔽:
    次回、ユーザーやシステムがターゲットにされた正規のアプリ(メモ帳など)を起動した瞬間、OSはShimデータベースに従い、アプリの起動と同時にマルウェアのDLLをそのプロセスの内部で強制実行させます。

3. 防御・対策

「インストールコマンドの監視」と「レジストリのチェック」が非常に効果的です。

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\InstalledSDB

4. 重要ポイント

5. 関連する主なCWE

6. 関連する代表的な事例・ツール

OSの高度な正規機能をディープに悪用するため、サイバースパイ活動を行う国家系の組織が好む傾向にあります。

実務上のアドバイス

もしEDRなどで「プロセス sdbinst.exe が急に実行された」というアラートを検知した場合、それは「攻撃者がすでに管理者権限を持っており、最後の潜伏・永続化の罠を仕掛けた最終段階」である可能性が極めて高いです。即座にその端末を隔離し、インストールされた .sdb ファイルのタイムスタンプから前後に実行された不正なファイルを追跡してください。

分析

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

関連する CVE

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


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