
NSKeyedUnarchiver 역직렬화에 취약한 시뮬레이션된 macOS/iOS XPC 서비스와, 안전하지 않은 역직렬화를 통한 RCE를 위한 익스플로잇 데모 및 제작된 plist 페이로드가 포함되어 있습니다.
#!/usr/bin/env python3
# vulnerable_xpc_service.py - Simulated XPC service using unsafe plist deserialization
import plistlib, subprocess, socketserver, struct
# Mach message simulation: we just accept a binary plist over TCP.
class XPCHandler(socketserver.BaseRequestHandler):
def handle(self):
raw = self.request.recv(4096)
# Insecure: using plistlib.loads on untrusted data without sanitization
plist_data = plistlib.loads(raw) # In real macOS, NSKeyedUnarchiver can execute code
# Simulate a command being embedded in the plist
command = plist_data.get("runCommand")
if command:
subprocess.Popen(command, shell=True)
self.request.sendall(b"Success")
server = socketserver.TCPServer(('localhost', 8888), XPCHandler)
print("Vulnerable XPC service on :8888")
server.serve_forever()
macOS/iOS의 XPC 서비스는 보안 코딩 허용 목록 없이 NSKeyedUnarchiver를 사용하여 수신되는 Mach 메시지를 역직렬화합니다. 공격자는 역직렬화 시 임의 코드를 실행하는 직렬화된 객체 그래프를 제작할 수 있습니다.
NSKeyedUnarchiver가 신뢰할 수 없는 데이터와 클래스 화이트리스트 없이 사용되어 코드 실행을 유발하는 객체(예: NSInvocation)의 인스턴스화를 허용합니다.python vulnerable_xpc_service.py
python exploit_xpc.py