Windows Kernel stack memory disclosure in win32k!xxxSendMenuSelect (via fnHkINLPMSG user-mode callback) CVE-2017-11853 We have discovered that the win32k!xxxSendMenuSelect function has a bug which leads to the disclosure of uninitialized stack memory to user-mode clients, due to unused fields in a structure which ends up copied to userland. The act of copying uninitialized kernel memory was originally detected under the following stack trace: --- cut --- 957836ec 82abe89d nt!memcpy+0x35 95783748 91161d46 nt!KeUserModeCallback+0xc6 957837ec 9111ffe8 win32k!fnHkINLPMSG+0x148 9578384c 911658b3 win32k!xxxHkCallHook+0x337 957838ec 9115ab70 win32k!xxxCallHook2+0x3ac 95783908 91227798 win32k!xxxCallHook+0x26 95783928 9121acd1 win32k!_CallMsgFilter+0x71 95783960 911f22aa win32k!xxxSendMenuSelect+0xce 957839c0 9120f5a9 win32k!xxxMNInvertItem+0x3ae 95783a2c 912452f9 win32k!xxxMNSelectItem+0x216 95783aa0 912141a4 win32k!xxxRealMenuWindowProc+0xba3 95783ad4 9118c593 win32k!xxxMenuWindowProc+0xfd 95783b14 9118c665 win32k!xxxSendMessageTimeout+0x1ac 95783b3c 9120f0d5 win32k!xxxSendMessage+0x28 95783b8c 9120ebcc win32k!xxxMNMouseMove+0x177 95783be8 9120e784 win32k!xxxHandleMenuMessages+0x310 95783c34 912147d3 win32k!xxxMNLoop+0x2fa 95783ca0 912148be win32k!xxxTrackPopupMenuEx+0x5fd 95783d14 8287ee06 win32k!NtUserTrackPopupMenuEx+0xc3 95783d14 77236c74 nt!KiSystemServicePostCall 000bf210 757a480e ntdll!KiFastSystemCallRet 000bf214 0055342c USER32!NtUserTrackPopupMenuEx+0xc --- cut --- At that point of execution, 0x30 bytes are copied from kernel to user-mode. The layout of the i/o structure passed down to the user-mode callback that we're seeing is as follows: --- cut --- 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000020: ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 ................ --- cut --- Where 00 denote bytes which are properly initialized, while ff indicate uninitialized values copied back to user-mode. As shown above, there are 12 bytes leaked at offsets 0x20-0x2b. We have determined that these bytes originally come from a smaller structure of size 0x1c, allocated in the stack frame of the win32k!xxxSendMenuSelect function. More specifically, we have found that the local structure is in fact of type MSG, and the uninitialized bytes correspond to the trailing "time" and "pt" fields: --- cut --- typedef struct tagMSG { HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam; DWORD time; POINT pt; } MSG, *PMSG, *LPMSG; --- cut --- Such a partially initialized structure is then passed down to win32k!_CallMsgFilter, and further down the call stack, before being eventually leaked to ring-3 through the user-mode callback. A proof-of-concept program is not provided for this issue, but it has been observed and confirmed at normal system runtime, and is quite evident in the code. Repeatedly triggering the vulnerability could allow local authenticated attackers to defeat certain exploit mitigations (kernel ASLR) or read other secrets stored in the kernel address space. This bug is subject to a 90 day disclosure deadline. After 90 days elapse or a patch has been made broadly available, the bug report will become visible to the public. Found by: mjurczyk