Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1310 CNY

100%

CVE-2021-1732 PoC — Windows Win32k Elevation of Privilege Vulnerability

Source
Associated Vulnerability
Title:Windows Win32k Elevation of Privilege Vulnerability (CVE-2021-1732)
Description:Windows Win32k Elevation of Privilege Vulnerability
Readme
# CVE-2021-1732

- 漏洞发生在Windows 图形驱动`win32kfull!NtUserCreateWindowEx`函数中的一处内核回调用户态分配内存与tagWND->flag属性设置不同步导致的漏洞。使得可以伪造这个`tagWND->offset`值发生内存越界。
- 当驱动win32kfull.sys调用`NtUserCreateWindowEx`创建窗口时会判断`tagWND->cbWndExtra`(窗口实例额外分配内存数),该值不为空时调用`win32kfull!xxxClientAllocWindowClassExtraBytes`函数回调用户层`user32.dll!__xxxClientAllocWindowClassExtraBytes`分配空间,分配后的地址使用`NtCallbackReturn`函数修正堆栈后重新返回内核层并保存并继续运行,而当`tagWND->flag`值包含0x800属性后该保存值变成了一个offset。
- 攻击者可以Hook `user32.dll!_xxxClientAllocWindowClassExtraBytes`函数调用NtUserConsoleControl修改tagWND->flag包含0x800属性值后使用`NtCallbackReturn`返回一个自定义的值到内核tagWND->offset。

1. 漏洞发生在Windows 图形驱动`win32kfull!NtUserCreateWindowEx`中。
2. 当驱动`win32kfull.sys`调用`NtUserCreateWindowEx`创建窗口时会判断`tagWND->cbWndExtra`(窗口实例额外分配内存数),该值不为空时调用`win32kfull!xxxClientAllocWindowClassExtraBytes`函数回调用户层`user32.dll!__xxxClientAllocWindowClassExtraBytes`创建内存,分配后的地址使用`NtCallbackReturn`函数修正堆栈后重新返回内核层并保存并继续运行,而当`tagWND->flag`值包含0x800属性时候对该值采用offset 寻址。
3. 使用`NtUserConsoleControl`修改flag包含0x800属性。

`17763:[[gpKernelHandleTable] + 0x18 * ((hwnd->cx * [gSharedInfo+0x10]) >> 5)]`

提到调用`NtUserConsoleControl`会重新设置`tagWND->offset`跟`tagWND->flag`值包含`0x800`属性, flag值包含`0x800`属性采用offset 寻址。我们在当前调用`NtUserConsoleControl`的目的就是修改`tagWND->flag`值包含0x800属性,  再调用`NtCallbackReturn`函数返回指定值目的是重新修改`tagWND->offset`, 因为`win32kfull!xxxClientAllocWindowClassExtraBytes`会把返回值放入到`tagWND->offset`

`+0x058 KernelCallbackTable : 0x00007ffb0e9d1070 Void`

`00007ffb`0e9d1448`
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →