My exploit for CVE-2021-40449, a Windows LPE via a UAF in win32kfull!GreResetDCInternal.
along with the UAF vulnerabilty other primitives are being used to make this exploit possible:
- leaking the exploit's
access token
address in ring0 viaNtQuerySystemInformation()
function with theSystemHandleInformation
parameter. - using
rtlSetAllBits()
as a gadget to overwrite the exploit'saccess_token.privileges
with0xFF
s. - leaking
rtlSetAllBits()
address on ring0 by leaking the base address ofntoskrnl.exe
module viaEnumDeviceDrivers()
function. - crafting the gadget's parameter
BitMapHeader
in such a way that will allow us to overwrite theaccess_token.privileges
of the exploit. - allocating the crafted
BitMapHeader
viaNtSetInformationThread()
primitive and leaking the allocation address in the big pool viaNtQuerySystemInformation()
function withSystemBigPoolInformation
parameter. - to interact with the vulnerable function we first enum printers on the system via
EnumPrinters()
load the driver of one of them one of them then hook the calls to the usermode callback functionDrvEnablePDEV()
. - in the hook we proxy the call to the original
DrvEnablePDEV()
function, do the exploit stuff then return whats returned from the proxied call to the GDI. - triggering the UAF via a second call to
ResetDC()
in the hookedDrvEnablePDEV()
. - reclaim the freed
PDC
object via spraying a crafted object of the same size using theCreatePalette()
primitive. - abusing the new aquired
SeDebugPrivilege
privilege to getNT AUTHORITY\SYSTEM
via injecting shellcode towinlogon.exe
process.
More information can be found on this article by Kaspersky.