Nytro Posted May 26, 2014 Report Posted May 26, 2014 From: Tavis Ormandy <taviso () cmpxchg8b com>Date: Wed, 21 May 2014 11:57:31 -0700Apparently I'm being lured into pointless discussions today, so here's another.As I'm sure everyone is aware, Microsoft introduced basic NULL pagemitigations for Windows 8 (both x86 and x64), and even backported themitigation to Vista+ (On x64 only). There are some weaknesses, butthis is a topic for another time.Interestingly, on Windows 8 x86, there is an intentional exception, ifan Administrator has installed the 16bit subsystem the mitigation isworthless because you can run your exploit in the context of NTVDM(simply use the technique I documented in CVE-2010-0232Windows NT - User Mode to Ring 0 Escalation Vulnerability).An Administrator can do this either on-demand by running an 16bit program, e.g.C:\> debugOr using fondue to install it manually:C:\> fondue /enable-feature:ntvdm /hide-ux:allLet's look at an example of a NULL dereference. It's obvious from thecode that win32k!GreSetPaletteEntries doesn't validate the MDCOBJAcall succeeds in the HDC list traversal, resulting in a very cleanNULL dereference..text:001EAF49 lea esi, [ebp+var_2C] ;out pointer.text:001EAF4C call ??0MDCOBJA@@QAE () PAUHDC__@@@Z ;MDCOBJA::MDCOBJA(HDC__ *).text:001EAF51 push 1.text:001EAF53 mov edx, edi.text:001EAF55 call _GreGetObjectOwner () 8 ;GreGetObjectOwner(x,x).text:001EAF5A mov esi, eax.text:001EAF5C callds:__imp__PsGetCurrentProcessId () 0 ; PsGetCurrentProcessId().text:001EAF62 and eax, 0FFFFFFFCh.text:001EAF65 cmp esi, eax.text:001EAF67 jnz short loc_1EAFBA.text:001EAF69 and [ebp+ms_exc.registration.TryLevel], 0.text:001EAF6D mov eax, [ebp+var_2C] ;load pointer.text:001EAF70 mov ecx, [eax+38h] ;NULL dereference.text:001EAF73 mov eax, [ecx+4]Callers like GreIsRendering, GreSetDCOrg, GreGetBounds, etc, etc checkcorrectly for comparison. This better code is from win32k!GreSetDCOrg:.text:00213DA2 lea esi, [ebp+var_C] ;out pointer.text:00213DA5 xor ebx, ebx.text:00213DA7 call ??0MDCOBJA@@QAE () PAUHDC__@@@Z ;MDCOBJA::MDCOBJA(HDC__ *).text:00213DAC mov edi, [ebp+var_C] ;load result.text:00213DAF test edi, edi ;check for NULL.text:00213DB1 jz short loc_213E15 ; errorThis bug can be triggered with typical resource exhaustion patterns(see my exploit for CVE-2013-3660 for referenceWindows NT - Windows 8 EPATHOBJ Local Ring 0 Exploit). However, I have alsostumbled onto a Windows 8 specific technique that does not requireresource exhaustion, using the (undocumented) Xferable object flag.See the attached code (the testcase is Windows 8+ on x86 specific,although the bug affects other versions and platforms).This seems exploitable on 32bit systems prior to Windows 8, but onWindows 8 it's only exploitable (ignoring mitigation failures) withNTVDM configured.It's my understanding that Microsoft no longer consider this asupported configuration, and are only interested in fixing NULL pagemitigation bypasses.I'm not convinced this is a reasonable stance, what do other people think?Tavis.P.S. I think linux introduced it's mmap_min_addr mitigation to stablearound 2007? Seven years lag, I guess that's the power of the SDL ;-)-- -------------------------------------taviso () cmpxchg8b com | pgp encrypted mail preferred-------------------------------------------------------Attachment: SetPalette.cSursa: Full Disclosure: NULL page mitigations on Windows 8 x86 Quote