Windows systems use a common method to look for required DLLs to load into a program. (Citation: Microsoft DLL Search) Adversaries may take advantage of the Windows DLL search order and programs that ambiguously specify DLLs to gain privilege escalation and persistence.
Adversaries may perform DLL preloading, also called binary planting attacks, (Citation: OWASP Binary Planting) by placing a malicious DLL with the same name as an ambiguously specified DLL in a location that Windows searches before the legitimate DLL. Often this location is the current working directory of the program. Remote DLL preloading attacks occur when a program sets its current directory to a remote location such as a Web share before loading a DLL. (Citation: Microsoft 2269637) Adversaries may use this behavior to cause the program to load a malicious DLL.
Adversaries may also directly modify the way a program loads DLLs by replacing an existing DLL or modifying a .manifest or .local redirection file, directory, or junction to cause the program to load a different DLL to maintain persistence or privilege escalation. (Citation: Microsoft DLL Redirection) (Citation: Microsoft Manifests) (Citation: Mandiant Search Order)
If a search order-vulnerable program is configured to run at a higher privilege level, then the adversary-controlled DLL that is loaded will also be executed at the higher level. In this case, the technique could be used for privilege escalation from user to administrator or SYSTEM or from administrator to SYSTEM, depending on the program.
Programs that fall victim to path hijacking may appear to behave normally because malicious DLLs may be configured to also load the legitimate DLLs they were meant to replace.
T1038「DLL Search Order Hijacking」(DLL検索順序の乗っ取り) は、Windows OSがプログラム実行時に必要なDLL(動的リンクライブラリ)を検索する際の「優先順位」を悪用して、正規のDLLの代わりに悪意のあるDLLを読み込ませる手法です。
この手法は「永続化(Persistence)」と「特権昇格(Privilege Escalation)」によく使われます。
この手法で攻撃者は、「正規のアプリケーションを起動するだけで、自動的にマルウェアをシステムにロードさせること」を実現します。
検知の回避:
攻撃者自身の実行ファイル(.exe)を動かすのではなく、信頼された正規プログラム(例:Word, Teams, システムツール)のプロセスの一部として動作するため、セキュリティソフトの監視をすり抜けやすくなります。
権限昇格:
SYSTEM権限などの高い権限で動作するプログラムが、攻撃者のDLLを読み込んでしまった場合、その攻撃コードも高い権限で実行されます。
永続化:
ユーザーが日常的に使うアプリのフォルダに悪意のあるDLLを置いておくだけで、アプリ起動のたびに攻撃が再開されます。
WindowsにはDLLを探す標準的な順番(検索順序)があります。攻撃者はこれを利用します。
検索順序の把握: 通常、Windowsは以下の順でDLLを探します。
C:\Windows\System32)脆弱なアプリの特定:
システムディレクトリ(System32)にあるはずのDLLを、自身のインストールフォルダから先に探そうとするアプリを見つけます。
悪意のあるDLLの配置:
正規のDLLと同じ名前(例:version.dll, dwmapi.dll など)でマルウェアを偽装し、アプリケーションと同じフォルダに配置します。
実行:
ユーザーがアプリを起動すると、OSはSystem32を見に行く前に、同じフォルダにある攻撃者のDLLを「必要なファイル」として読み込んでしまいます。
「DLLの読み込み制限」と「フォルダ権限の管理」が重要です。
SafeDLLSearchMode の有効化:
デフォルトで有効ですが、これが有効だとカレントディレクトリの優先順位が下がります。
絶対パスによるロード:
開発者は LoadLibrary を使用する際、相対パスではなくフルパス(絶対パス)を指定するようにプログラムを記述します。
ディレクトリの書き込み制限:
C:\Program Files などのアプリケーションフォルダに対して、一般ユーザーがファイルを書き込めないようにアクセス権限(ACL)を厳格化します。
DLL署名の検証:
署名のないDLLや、予期しないパスからロードされるDLLを監視・遮断するEDR(Endpoint Detection and Response)を導入します。
「DLLサイドローディング」との違い:
T1038は検索順序の不備を突くものですが、DLLサイドローディング(T1574.002)は、正規のアプリが特定のDLLを読み込む性質を意図的に利用するもので、手法として非常に近しい関係にあります。
「既知のDLL」 (KnownDLLs):
kernel32.dll や user32.dll などの重要なシステムDLLは、レジストリの KnownDLLs に登録されており、この順序を無視して安全にロードされる仕組みになっています。
CWE-427: Uncontrolled Search Path Element:
実行ファイルの検索パスが適切に制御されておらず、意図しないバイナリが実行される問題。
CWE-426: Untrusted Search Path:
信頼できない場所にあるパスを検索対象に含めてしまっている設計上の不備。
多くの有名ソフトウェアが過去にこの脆弱性を指摘されています。
CVE-2010-3132:
WinampにおけるDLL検索順序の脆弱性。
CVE-2016-3235:
Windowsのプログラムインストーラーにおける脆弱性。
CVE-2018-8414:
Windows Shellにおける、.settingcontent-ms ファイルを介したDLL乗っ取りに関連する脆弱性。
特定のアプリを起動したときに、本来 System32 から読み込まれるべきDLLが、なぜかそのアプリのインストールフォルダ(例:Downloads フォルダなど)から読み込まれていないかを監視することが、この攻撃を検知する最も効果的な方法です。