{"id":15032,"date":"2019-04-08T12:00:52","date_gmt":"2019-04-08T20:00:52","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2019\/04\/08\/news-8781\/"},"modified":"2019-04-08T12:00:52","modified_gmt":"2019-04-08T20:00:52","slug":"news-8781","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2019\/04\/08\/news-8781\/","title":{"rendered":"From alert to driver vulnerability: Microsoft Defender ATP investigation unearths privilege escalation flaw"},"content":{"rendered":"<p><strong>Credit to Author: Eric Avena| Date: Mon, 25 Mar 2019 15:00:07 +0000<\/strong><\/p>\n<p>With Microsoft continuously improving kernel mitigations and raising the bar for exploiting native kernel components, third-party kernel drivers are becoming a more appealing target for attackers and an important area of research for security analysts. A vulnerability in a signed third-party driver could have a serious impact: it can be abused by attackers to escalate privileges or, more commonly, bypass driver signature enforcement\u2014without the complexity of using a more expensive zero-day kernel exploit in the OS itself.<\/p>\n<p>Computer manufacturers usually ship devices with software and tools that facilitate device management. These software and tools, including drivers, often contain components that run with ring-0 privileges in the kernel. With these components installed by default, each must be as secure as the kernel; even one flawed component could become the Achilles\u2019 heel of the whole kernel security design.<\/p>\n<p>We discovered such a driver while investigating an alert raised by <a href=\"https:\/\/www.microsoft.com\/en-us\/windowsforbusiness\/windows-atp?ocid=cx-blog-mmpc\">Microsoft Defender Advanced Threat Protection<\/a>\u2019s kernel sensors. We traced the anomalous behavior to a device management driver developed by Huawei. Digging deeper, we found a lapse in the design that led to a vulnerability that could allow local privilege escalation.<\/p>\n<p>We reported the vulnerability (assigned CVE-2019-5241) to Huawei, who responded and cooperated quickly and professionally. On January 9, 2019, Huawei released a fix: https:\/\/www.huawei.com\/en\/psirt\/security-advisories\/huawei-sa-20190109-01-pcmanager-en.<\/p>\n<p>In this blog post, we\u2019d like to share our journey from investigating one Microsoft Defender ATP alert to discovering a vulnerability, cooperating with the vendor, and protecting customers.<\/p>\n<h3>Detecting kernel-initiated code injections with Microsoft Defender ATP<\/h3>\n<p>Starting in Windows 10, version 1809, the kernel has been instrumented with new sensors designed to trace User APC code injection initiated by a kernel code, providing better visibility into kernel threats like DOUBLEPULSAR. As described in our <a href=\"https:\/\/cloudblogs.microsoft.com\/microsoftsecure\/2017\/06\/30\/exploring-the-crypt-analysis-of-the-wannacrypt-ransomware-smb-exploit-propagation\/\">in-depth analysis<\/a>, DOUBLEPULSAR is a kernel backdoor used by the WannaCry ransomware to inject the main payload into user-space. DOUBLEPULSAR copied the user payload from the kernel into an executable memory region in lsass.exe and inserted a User APC to a victim thread with NormalRoutine targeting this region.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-89164\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-01-WannaCry-user-APC-injection-technique-schematic-diagram.png\" alt=\"figure-01-WannaCry-user-APC-injection-technique-schematic-diagram\" width=\"700\" height=\"350\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-01-WannaCry-user-APC-injection-technique-schematic-diagram.png 998w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-01-WannaCry-user-APC-injection-technique-schematic-diagram-300x150.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-01-WannaCry-user-APC-injection-technique-schematic-diagram-768x384.png 768w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 1. WannaCry User APC injection technique schematic diagram<\/em><\/p>\n<p>While the User APC code injection technique isn\u2019t novel (see <a href=\"https:\/\/www.microsoft.com\/en-us\/wdsi\/threats\/malware-encyclopedia-description?Name=Win32\/Conficker\">Conficker<\/a> or <a href=\"https:\/\/community.osr.com\/discussion\/88852\">Valerino\u2019s earliest proof-of-concept<\/a>), detecting threats running in the kernel is not trivial. Since PatchGuard was introduced, hooking NTOSKRNL is no longer allowed; there\u2019s no documented way drivers could get notification for any of the above operations. Hence, without proper optics, the only sustainable strategy would be applying memory forensics, which can be complicated.<\/p>\n<p>The new set of kernel sensors aim to address this kind of kernel threat. Microsoft Defender ATP leverages these sensors to detect suspicious operations invoked by a kernel code that might lead to code injection into user-mode. One such suspicious operation, though not related to WannaCry, DOUBLEPULSAR, or other known kernel threats, triggered this investigation that led to our discovery of a vulnerability.<\/p>\n<h3>Investigating an anomalous code injection from the kernel<\/h3>\n<p>While monitoring alerts related to kernel-mode attacks, one alert drew our attention:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-89189\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-02-2-Microsoft-Defender-ATP-kernel-initiating-code-injection-alert.png\" alt=\"figure-02-2-Microsoft-Defender-ATP-kernel-initiating-code-injection-alert\" width=\"997\" height=\"827\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-02-2-Microsoft-Defender-ATP-kernel-initiating-code-injection-alert.png 997w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-02-2-Microsoft-Defender-ATP-kernel-initiating-code-injection-alert-300x249.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-02-2-Microsoft-Defender-ATP-kernel-initiating-code-injection-alert-768x637.png 768w\" sizes=\"auto, (max-width: 997px) 100vw, 997px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 2. Microsoft Defender ATP kernel-initiating code injection alert<\/em><\/p>\n<p>The alert process tree showed an abnormal memory allocation and execution in the context of <em>services.exe<\/em> by a kernel code. Investigating further, we found that an identical alert was fired on another machine around the same time.<\/p>\n<p>To get a better understanding of the observed anomaly, we looked at the raw signals we got from the kernel sensors. This analysis yielded the following findings:<\/p>\n<ul>\n<li>A system thread called <em>nt!NtAllocateVirtualMemory<\/em> allocated a single page (size = 0x1000) with <em>PAGE_EXECUTE_READWRITE<\/em> protection mask in <em>services.exe<\/em> address space<\/li>\n<li>The system thread then called <em>nt!KeInsertQueueApc<\/em> to queue User APC to a <em>services.exe<\/em> arbitrary thread with <em>NormalRoutine<\/em> pointing to the beginning of the executable page and <em>NormalContext<\/em> pointing to offset <em>0x800<\/em><\/li>\n<\/ul>\n<p>The payload copied from kernel mode is divided into two portions: a shellcode (<em>NormalRoutine<\/em>) and a parameter block (<em>NormalContext<\/em>). At this point, the overall behavior looked suspicious enough for us to proceed with the hunting. Our goal was to incriminate the kernel code that triggered the alert.<\/p>\n<h3>Incriminating the source<\/h3>\n<p>In user-mode threats, the caller process context could shed light on the actor and link to other phases in the attack chain. In contrast, with kernel-mode threats, the story is more complicated. The kernel by nature is asynchronous; callbacks might be called in an arbitrary context, making process context meaningless for forensics purposes.<\/p>\n<p>Therefore, we tried to find an indirect evidence to third-party code loaded into the kernel. By inspecting the machine timeline, we found that several third-party drivers were loaded earlier that day.<\/p>\n<p>We concluded based on their file path that they are all related to an app from Huawei called PC Manager, a device management software for Huawei MateBook laptops. The installer is available on Huawei website, so we downloaded it for inspection. For each Huawei driver we used <em>dumpbin.exe<\/em> to examine imported functions.<\/p>\n<p>And then we had a hit:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89166 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-03-dumpbin-utility-used-to-detect-user-APC-injection-primitives.png\" alt=\"figure-03-dumpbin-utility-used-to-detect-user-APC injection-primitives\" width=\"1107\" height=\"54\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-03-dumpbin-utility-used-to-detect-user-APC-injection-primitives.png 1107w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-03-dumpbin-utility-used-to-detect-user-APC-injection-primitives-300x15.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-03-dumpbin-utility-used-to-detect-user-APC-injection-primitives-768x37.png 768w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-03-dumpbin-utility-used-to-detect-user-APC-injection-primitives-1024x50.png 1024w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-03-dumpbin-utility-used-to-detect-user-APC-injection-primitives-1083x54.png 1083w\" sizes=\"auto, (max-width: 1107px) 100vw, 1107px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 3. dumpbin utility used to detect user APC injection primitives<\/em><\/p>\n<h3><em>HwOs2Ec10x64.sys<\/em>: Unexpected behavior from a driver<\/h3>\n<p>Hunting led us to the kernel code that triggered the alert. One would expect that a device management software would perform mostly hardware-related tasks, with the supplied device drivers being the communication layer with the OEM-specific hardware. So why was this driver exhibiting unusual behavior? To answer this question, we reverse-engineered <em>HwOs2Ec10x64.sys<\/em>.<\/p>\n<p>Our entry point was the function implementing the user APC injection. We found a code path that:<\/p>\n<ol>\n<li>allocates <em>RWX<\/em> page in some target process;<\/li>\n<li>resolves <em>CreateProcessW<\/em> and <em>CloseHandle<\/em> function pointers in the address space of the target process;<\/li>\n<li>copies a code area from the driver as well as what seemed to be a parameter block to the allocated page; and<\/li>\n<li>performs User APC injection targeting that page<\/li>\n<\/ol>\n<p>The parameter block contains both the resolved function pointers as well as a string, which was found to be a command line.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89167 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-04-User-APC-injection-code.png\" alt=\"figure-04-User-APC-injection-code\" width=\"1014\" height=\"791\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-04-User-APC-injection-code.png 1014w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-04-User-APC-injection-code-300x234.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-04-User-APC-injection-code-768x599.png 768w\" sizes=\"auto, (max-width: 1014px) 100vw, 1014px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 4. User APC injection code<\/em><\/p>\n<p>The APC normal routine is a shellcode which calls <em>CreateProcessW<\/em> with the given process command line string. This implied that the purpose of the code injection to <em>services.exe<\/em> is to spawn a child process.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89168 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-05-User-shellcode-performing-process-creation.png\" alt=\"figure-05-User-shellcode-performing-process-creation\" width=\"441\" height=\"533\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-05-User-shellcode-performing-process-creation.png 441w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-05-User-shellcode-performing-process-creation-248x300.png 248w\" sizes=\"auto, (max-width: 441px) 100vw, 441px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 5. User shellcode performing process creation<\/em><\/p>\n<p>Inspecting the <em>xrefs<\/em>, we noticed that the injection code originated from a create-process notify routine when <em>Create = FALSE<\/em>. Hence, the trigger was some process termination.<\/p>\n<p>But what command does the shellcode execute? Attaching a kernel debugger and setting a breakpoint on the <em>memcpy_s<\/em> in charge of copying the parameters from kernel to user-mode revealed the created process: one of Huawei\u2019s installed services, <em>MateBookService.exe<\/em>, invoked with <em>&#8220;\/startup&#8221;<\/em> in its command line.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-89190\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-06-2-Breakpoint-hit-on-the-call-to-memcpy_s-copying-shellcode-parameters.png\" alt=\"figure-06-2-Breakpoint-hit-on-the-call-to-memcpy_s-copying-shellcode-parameters\" width=\"968\" height=\"761\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-06-2-Breakpoint-hit-on-the-call-to-memcpy_s-copying-shellcode-parameters.png 968w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-06-2-Breakpoint-hit-on-the-call-to-memcpy_s-copying-shellcode-parameters-300x236.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-06-2-Breakpoint-hit-on-the-call-to-memcpy_s-copying-shellcode-parameters-768x604.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 6. Breakpoint hit on the call to memcpy_s copying shellcode parameters<\/em><\/p>\n<p>Why would a valid service be started that way? Inspecting <em>MateBookService.exe!main<\/em> revealed a &#8220;startup mode&#8221; that revived the service if it&#8217;s stopped \u2013 some sort of watchdog mechanism meant to keep the Huawei PC Manager main service running.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89170 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-07-MateBookService-exe-startup-code-path.png\" alt=\"figure-07-MateBookService-exe-startup-code-path\" width=\"1140\" height=\"423\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-07-MateBookService-exe-startup-code-path.png 1140w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-07-MateBookService-exe-startup-code-path-300x111.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-07-MateBookService-exe-startup-code-path-768x285.png 768w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-07-MateBookService-exe-startup-code-path-1024x380.png 1024w\" sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 7. MateBookService.exe \/startup code path<\/em><\/p>\n<p>At this point of the investigation, the only missing piece in the puzzle was making sure the terminated process triggering the injection is indeed <em>MateBookService.exe<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89171 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-08-Validating-terminated-process-identity.png\" alt=\"figure-08-Validating-terminated-process-identity\" width=\"1148\" height=\"509\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-08-Validating-terminated-process-identity.png 1148w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-08-Validating-terminated-process-identity-300x133.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-08-Validating-terminated-process-identity-768x341.png 768w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-08-Validating-terminated-process-identity-1024x454.png 1024w\" sizes=\"auto, (max-width: 1148px) 100vw, 1148px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 8. Validating terminated process identity<\/em><\/p>\n<p>The code path that decides whether to inject to <em>services.exe<\/em> uses a global list of watched process names. Hitting a breakpoint in the iteration loop revealed which process was registered: it was <em>MateBookService.exe<\/em>, as expected, and it was the only process on that list.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89172 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-09-Breakpoint-hit-during-process-name-comparison-against-global-list.png\" alt=\"figure-09-Breakpoint-hit-during-process-name-comparison-against-global-list\" width=\"790\" height=\"456\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-09-Breakpoint-hit-during-process-name-comparison-against-global-list.png 790w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-09-Breakpoint-hit-during-process-name-comparison-against-global-list-300x173.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-09-Breakpoint-hit-during-process-name-comparison-against-global-list-768x443.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 9. Breakpoint hit during process name comparison against global list<\/em><\/p>\n<p><em>HwOs2Ec10x64.sys<\/em> also provided process protection against external tampering. Any attempt to force <em>MateBookService.exe<\/em> termination would fail with <em>Access Denied<\/em>.<\/p>\n<h3>Abusing <em>HwOs2Ec10x64.sys<\/em> process watch mechanism<\/h3>\n<p>The next step in our investigation was to determine whether an attacker can tamper with the global watched process list. We came across an IOCTL handler that added an entry to that list. <em>MateBookService.exe<\/em> process likely uses this IOCTL to register itself when the service starts. This IOCTL is sent to the driver control device, created from its <em>DriverEntry<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89173 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-10-HwOs2Ec10x64.sys-control-device-creation-with-IoCreateDevice.png\" alt=\"figure-10-HwOs2Ec10x64.sys-control-device-creation-with-IoCreateDevice\" width=\"537\" height=\"143\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-10-HwOs2Ec10x64.sys-control-device-creation-with-IoCreateDevice.png 537w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-10-HwOs2Ec10x64.sys-control-device-creation-with-IoCreateDevice-300x80.png 300w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 10. HwOs2Ec10x64.sys control device creation with IoCreateDevice<\/em><\/p>\n<p>Since the device object is created with <em>IoCreateDevice<\/em>, <em>Everyone<\/em> has RW access to it. Another important observation was that this device isn&#8217;t exclusive, hence multiple handles could be opened to it.<\/p>\n<p>Nevertheless, when we tried to open a handle to the device <em>\\.HwOs2EcX64<\/em>, it failed with <em>Last Error = 537, &#8220;Application verifier has found an error in the current process&#8221;<\/em>. The driver was rejecting our request to open the device. How is access enforced? It must be on the <em>CreateFile<\/em> path; in other words, in <em>HwOs2Ec10x64.sys<\/em> <em>IRP_MJ_CREATE<\/em> dispatch routine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89174 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-11-IRP_MJ_CREATE-dispatch-routine.png\" alt=\"figure-11-IRP_MJ_CREATE-dispatch-routine\" width=\"533\" height=\"243\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-11-IRP_MJ_CREATE-dispatch-routine.png 533w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-11-IRP_MJ_CREATE-dispatch-routine-300x137.png 300w\" sizes=\"auto, (max-width: 533px) 100vw, 533px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 11. IRP_MJ_CREATE dispatch routine<\/em><\/p>\n<p>This function validates the calling process by making sure that the main executable path belongs to a whitelist (e.g., <em>C:Program FilesHuaweiPCManagerMateBookService.exe<\/em>). This simple check on the initiating process name, however, doesn\u2019t guarantee the integrity of the calling process. An attacker-controlled instance of <em>MateBookService.exe<\/em> will still be granted access to the device <em>\\.HwOs2EcX64<\/em> and be able to call some of its IRP functions. Then, the attacker-controlled process could abuse this capability to talk with the device to register a watched executable of its own choice. Given the fact that a parent process has full permissions over its children, even a code with low privileges might spawn an infected <em>MateBookService.exe<\/em> and inject code into it. In our proof-of-concept, we used <a href=\"https:\/\/www.microsoft.com\/security\/blog\/2017\/07\/12\/detecting-stealthier-cross-process-injection-techniques-with-windows-defender-atp-process-hollowing-and-atom-bombing\/\">process hollowing<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89175 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-12-Procmon-utility-results-showing-POC-process-start-exit-IL.png\" alt=\"figure-12-Procmon-utility-results-showing-POC-process-start-exit-IL\" width=\"749\" height=\"132\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-12-Procmon-utility-results-showing-POC-process-start-exit-IL.png 749w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-12-Procmon-utility-results-showing-POC-process-start-exit-IL-300x53.png 300w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 12. Procmon utility results showing POC process start\/exit &amp; IL<\/em><\/p>\n<p>Because watched processes are blindly launched by the watchdog when they\u2019re terminated, the attacker-controlled executable would be invoked as a child of services.exe, running as LocalSystem, hence with elevated privileges.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-89176 aligncenter\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-13-Procexp-utility-process-tree-view-showing-LPE_POC-running-as-LocalSystem.png\" alt=\"figure-13-Procexp-utility-process-tree-view-showing-LPE_POC-running-as-LocalSystem\" width=\"598\" height=\"47\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-13-Procexp-utility-process-tree-view-showing-LPE_POC-running-as-LocalSystem.png 598w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-13-Procexp-utility-process-tree-view-showing-LPE_POC-running-as-LocalSystem-300x24.png 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 13. Procexp utility process-tree view showing LPE_POC running as LocalSystem<\/em><\/p>\n<h3>Responsible disclosure and protecting customers<\/h3>\n<p>Once we had a working POC demonstrating the elevation of privilege from a low-integrity attacker-controlled process, we responsibly reported the bug to Huawei through the Microsoft Security Vulnerability Research (<a href=\"https:\/\/www.microsoft.com\/en-us\/msrc\/msvr\">MSVR<\/a>) program. The vulnerability was assigned CVE-2019-5241. Meanwhile, we kept our customers safe by building a detection mechanism that would raise an alert for any successful privilege escalation exploiting the <em>HwOs2Ec10x64.sys<\/em> watchdog vulnerability as we described.<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-89191\" src=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-14-2-Microsoft-Defender-ATP-alerting-on-the-privilege-escalation-POC-code.png\" alt=\"figure-14-2-Microsoft-Defender-ATP-alerting-on-the-privilege-escalation-POC-code\" width=\"942\" height=\"741\" srcset=\"https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-14-2-Microsoft-Defender-ATP-alerting-on-the-privilege-escalation-POC-code.png 942w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-14-2-Microsoft-Defender-ATP-alerting-on-the-privilege-escalation-POC-code-300x236.png 300w, https:\/\/www.microsoft.com\/security\/blog\/wp-content\/uploads\/2019\/03\/figure-14-2-Microsoft-Defender-ATP-alerting-on-the-privilege-escalation-POC-code-768x604.png 768w\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" \/><\/p>\n<p style=\"text-align: center;\"><em>Figure 14. Microsoft Defender ATP alerting on the privilege escalation POC code<\/em><\/p>\n<h3>Abusing a second IOCTL handler<\/h3>\n<p>Having been able to freely invoke IOCTL handlers of the driver from user-mode, we looked for other capabilities that can be abused. We found one: the driver provided a capability to map any physical page into user-mode with RW permissions. Invoking this handler allowed a code running with low privileges to read-write beyond the process boundaries\u2014to other processes or even to kernel space. This, of course, means a full machine compromise.<\/p>\n<p>We also worked with Huawei to fix this second vulnerability, which was assigned CVE-2019-5242. Huawei addressed the flaw in the same security advisory: https:\/\/www.huawei.com\/en\/psirt\/security-advisories\/huawei-sa-20190109-01-pcmanager-en.<\/p>\n<p>We presented our research at the Blue Hat IL Conference in February. Watch the <a href=\"https:\/\/youtu.be\/Ltzye0Cj9G8\">video recording here<\/a>, and get the <a href=\"https:\/\/msrnd-cdn-stor.azureedge.net\/bluehat\/bluehatil\/2019\/assets\/doc\/Who%20is%20Watching%20the%20Watchdog%20Uncovering%20a%20Privilege%20Escalation%20Vulnerability%20in%20OEM%20Driver.pdf\">slide deck here<\/a>.<\/p>\n<h3>Summary<\/h3>\n<p>While the original alert turned out to be benign, in the sense that it didn\u2019t detect an actual kernel threat like DOUBLEPULSAR, it did trigger an investigation that eventually led us to finding vulnerabilities. The two vulnerabilities we discovered in the driver prove the importance of designing software and products with security in mind. Security boundaries must be honored. Attack surface should be minimized as much as possible. In this case, the flaws could have been prevented if certain precautions were taken:<\/p>\n<ul>\n<li>The device object created by the driver should be created with a DACL granting SYSTEM RW access (since only the vendor\u2019s services were communicating directly with the driver)<\/li>\n<li>If a service should persist, developers should check that it\u2019s not already provided by the OS before trying to implement a complex mechanism<\/li>\n<li>User-mode shouldn\u2019t be allowed to perform privileged operations like writing to any physical page; if needed, the driver should do the actual writing for well-defined, hardware-related scenarios<\/li>\n<\/ul>\n<p>Microsoft&#8217;s <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/driversecurity\/driver-security-checklist\">driver security checklist<\/a> provides some guidelines for driver developers to help reduce the risk of drivers being compromised.<\/p>\n<p>Our discovery of the driver vulnerabilities also highlights the strength of <a href=\"https:\/\/www.microsoft.com\/en-us\/windowsforbusiness\/windows-atp?ocid=cx-blog-mmpc\">Microsoft Defender ATP<\/a>\u2019s sensors. These sensors expose anomalous behavior and give SecOps personnel the intelligence and tools to investigate threats, as we did.<\/p>\n<p>Anomalous behaviors typically point to attack techniques perpetrated by adversaries with only malicious intent. In this case, they pointed to a flawed design that can be abused. Nevertheless, Microsoft Defender ATP exposed a security flaw and protected customers before it can even be used in actual attacks.<\/p>\n<p>Not yet reaping the benefits of Microsoft Defender ATP\u2019s<a href=\"https:\/\/cloudblogs.microsoft.com\/microsoftsecure\/2018\/12\/03\/insights-from-the-mitre-attack-based-evaluation-of-windows-defender-atp\/\"> industry-leading optics and detection capabilities<\/a>? <strong><a href=\"https:\/\/www.microsoft.com\/en-us\/windowsforbusiness\/windows-atp?ocid=cx-blog-mmpc\">Sign up for free trial<\/a> <\/strong>today.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Amit Rapaport <\/em><\/strong><em>(<\/em><em><a href=\"https:\/\/twitter.com\/realAmitRap\">@realAmitRap<\/a>)<\/em><br \/> <em>Microsoft Defender Research team<\/em><\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/www.microsoft.com\/security\/blog\/2019\/03\/25\/from-alert-to-driver-vulnerability-microsoft-defender-atp-investigation-unearths-privilege-escalation-flaw\/\">From alert to driver vulnerability: Microsoft Defender ATP investigation unearths privilege escalation flaw<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/www.microsoft.com\/security\/blog\/\">Microsoft Security<a>.<\/p>\n<p><a href=\"https:\/\/www.microsoft.com\/security\/blog\/2019\/03\/25\/from-alert-to-driver-vulnerability-microsoft-defender-atp-investigation-unearths-privilege-escalation-flaw\/\" target=\"bwo\" >https:\/\/blogs.technet.microsoft.com\/mmpc\/feed\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><strong>Credit to Author: Eric Avena| Date: Mon, 25 Mar 2019 15:00:07 +0000<\/strong><\/p>\n<p>Our discovery of two privilege escalation vulnerabilities in a driver highlights the strength of Microsoft Defender ATP\u2019s sensors. These sensors expose anomalous behavior and give SecOps personnel the intelligence and tools to investigate threats, as we did.<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/www.microsoft.com\/security\/blog\/2019\/03\/25\/from-alert-to-driver-vulnerability-microsoft-defender-atp-investigation-unearths-privilege-escalation-flaw\/\">From alert to driver vulnerability: Microsoft Defender ATP investigation unearths privilege escalation flaw<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/www.microsoft.com\/security\/blog\/\">Microsoft Security<a>.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10759,10378],"tags":[21487,4500,12318,21482,11638,21488,21489,21490,21484,21491,21492,10467,10865],"class_list":["post-15032","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-security","tag-blue-hat","tag-cybersecurity","tag-doublepulsar","tag-endpoint-security","tag-exploit","tag-kernel-driver","tag-kernel-sensors","tag-kernel-mode-attacks","tag-microsoft-defender-atp","tag-privlege-escalation","tag-responsible-vulnerability-disclosure","tag-vulnerability","tag-windows-defender-atp"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/15032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=15032"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/15032\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=15032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=15032"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=15032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}