VirtualBox VBoxDrv.sys驱动本地权限漏洞
发布日期:2008-08-04
更新日期:2008-08-05
受影响系统:
Sun xVM VirtualBox 1.6.2
Sun xVM VirtualBox 1.6.0
描述:
----------------------------------------------------------------------------
BUGTRAQ ID: 30481
CVE(CAN) ID: CVE-2008-3431
VirtualBox是由德国Innotek公司开发的开源虚拟化技术,目前已成为Sun xVM产品家族的成员。
在Windows主机操作系统上使用的时候VirtualBox会安装VBoxDrv.sys内核驱动来控制guest操作系统的虚拟化。该驱动未经任何验证便允许非特权用户以METHOD_NEITHER缓冲模式打开//./VBoxDrv设备,这就允许不可信任的用户态代码向驱动传送任意内核地址作为参数。通过特制的输入,恶意用户就可以使用内核中的功能执行任意内核态代码。
以下是SUPDrv-win.cpp中用于处理IOCTL请求的函数:
/----------- NTSTATUS _stdcall VBoxDrvNtDeviceControl(PDEVICE_OBJECT pDevObj, PIRPpIrp) { PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)pDevObj->DeviceExtension; PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); PSUPDRVSESSION pSession =(PSUPDRVSESSION)pStack->FileObject->FsContext; /* * Deal with the two high-speed IOCtl that takes it's arguments from * the session and iCmd, and only returns a VBox status code. */ ULONG ulCmd = pStack->Parameters.DeviceIoControl.IoControlCode; if ( ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN(1) || ulCmd == SUP_IOCTL_FAST_DO_HWACC_RUN || ulCmd == SUP_IOCTL_FAST_DO_NOP) { KIRQL oldIrql; int rc; /* Raise the IRQL to DISPATCH_LEVEl to prevent Windows fromrescheduling us to another CPU/core. */ Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL); KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);(2) rc = supdrvIOCtlFast(ulCmd, pDevExt, pSession); KeLowerIrql(oldIrql); /* Complete the I/O request. */ NTSTATUS rcNt = pIrp->IoStatus.Status = STATUS_SUCCESS; pIrp->IoStatus.Information = sizeof(rc); __try {(3) *(int *)pIrp->UserBuffer = rc; } __except(EXCEPTION_EXECUTE_HANDLER) { rcNt = pIrp->IoStatus.Status = GetExceptionCode(); dprintf(("VBoxSupDrvDeviceContorl: Exception Code %#x/n", rcNt)); } IoCompleteRequest(pIrp, IO_NO_INCREMENT); return rcNt; } return VBoxDrvNtDeviceControlSlow(pDevExt, pSession, pIrp, pStack); }- -----------/
在(1)处句子检查了IOCTL代码,SUPDrvIOC.h以如下方式定义:
/-----------#define SUP_IOCTL_FAST_DO_RAW_RUN SUP_CTL_CODE_FAST(64)/** Fast path IOCtl: VMMR0_DO_HWACC_RUN */#define SUP_IOCTL_FAST_DO_HWACC_RUN SUP_CTL_CODE_FAST(65)/** Just a NOP call for profiling the latency of a fast ioctl call toVMMR0. */#define SUP_IOCTL_FAST_DO_NOP SUP_CTL_CODE_FAST(66)- -----------/
同一文件中还定义了SUP_CTL_CODE_FAST()宏:
/-----------#define SUP_CTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN,(Function) | SUP_IOCTL_FLAG, METHOD_NEITHER, FILE_WRITE_ACCESS)- -----------/
这时可以知道所使用的通讯方式为METHOD_NEITHER,然后在(2)处将supdrvIOCtlFast()的返回值保存到了rc中,在(3)处未经任何有效性检查便将rc中的值直接写入到了用户态所发送的缓冲区指针。在这种情况下,就可以对IOCTL提供内核地址,向supdrvIOCtlFast()的返回值写入内核空间内存中的任意地址,以任意修改内核代码或内核指针,之后在ring 0环境中执行任意代码。
<*来源:Anibal Sacco
链接:http://marc.info/?l=bugtraq&m=121788371725717&w=2
http://secunia.com/advisories/31361/
http://sunsolve.sun.com/search/printfriendly.do?assetkey=1-66-240095-1
*>
建议:
----------------------------------------------------------------------------
厂商补丁:
Sun
---
Sun已经为此发布了一个安全公告(Sun-Alert-240095)以及相应补丁:
Sun-Alert-240095:A Security Vulnerability in 'VBoxDrv.sys' driver of Sun xVM VirtualBox 1.6 may lead to Arbitrary Code Execution or Denial of Service (DoS)
链接:http://sunsolve.sun.com/search/printfriendly.do?assetkey=1-66-240095-1