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 tokenaddress in ring0 viaNtQuerySystemInformation()function with theSystemHandleInformationparameter. - using
rtlSetAllBits()as a gadget to overwrite the exploit'saccess_token.privilegeswith0xFFs. - leaking
rtlSetAllBits()address on ring0 by leaking the base address ofntoskrnl.exemodule viaEnumDeviceDrivers()function. - crafting the gadget's parameter
BitMapHeaderin such a way that will allow us to overwrite theaccess_token.privilegesof the exploit. - allocating the crafted
BitMapHeaderviaNtSetInformationThread()primitive and leaking the allocation address in the big pool viaNtQuerySystemInformation()function withSystemBigPoolInformationparameter. - 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
PDCobject via spraying a crafted object of the same size using theCreatePalette()primitive. - abusing the new aquired
SeDebugPrivilegeprivilege to getNT AUTHORITY\SYSTEMvia injecting shellcode towinlogon.exeprocess.
More information can be found on this article by Kaspersky.
