{"id":3541,"date":"2019-07-16T11:30:26","date_gmt":"2019-07-16T08:30:26","guid":{"rendered":"https:\/\/blog.eset.ee\/?p=3541"},"modified":"2019-07-16T11:46:47","modified_gmt":"2019-07-16T08:46:47","slug":"windows-zero%e2%80%91day-cve%e2%80%912019%e2%80%911132-exploited-in-targeted-attacks","status":"publish","type":"post","link":"https:\/\/blog.eset.ee\/et\/en\/2019\/07\/16\/windows-zero%e2%80%91day-cve%e2%80%912019%e2%80%911132-exploited-in-targeted-attacks\/","title":{"rendered":"Windows zero\u2011day CVE\u20112019\u20111132 exploited in targeted attacks"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In June 2019, ESET researchers identified a zero-day exploit being used in a highly targeted attack in Eastern Europe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The exploit abuses a local privilege escalation vulnerability in Microsoft Windows, specifically a NULL pointer dereference in the&nbsp;<code>win32k.sys<\/code>&nbsp;component. Once the exploit was discovered and analyzed, it was reported to the Microsoft Security Response Center, who promptly fixed the vulnerability and released a&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/portal.msrc.microsoft.com\/en-us\/security-guidance\/advisory\/CVE-2019-1132\" target=\"_blank\">patch<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The vulnerability affects the following Windows versions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Windows 7 for 32-bit Systems Service Pack 1<\/li><li>Windows 7 for x64-based Systems Service Pack 1<\/li><li>Windows Server 2008 for 32-bit Systems Service Pack 2<\/li><li>Windows Server 2008 for Itanium-Based Systems Service Pack 2<\/li><li>Windows Server 2008 for x64-based Systems Service Pack 2<\/li><li>Windows Server 2008 R2 for Itanium-Based Systems Service Pack 1<\/li><li>Windows Server 2008 R2 for x64-based Systems Service Pack 1<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This blog post focuses on the technical details of the vulnerability and its exploitation.&nbsp;<a href=\"https:\/\/www.welivesecurity.com\/2019\/07\/11\/buhtrap-zero-day-espionage-campaigns\/\" target=\"_blank\" rel=\"noreferrer noopener\">Another post<\/a>&nbsp;delves into the malware sample and its broader implications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Exploitation<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As with a number of other Microsoft Windows&nbsp;<code>win32k.sys<\/code>&nbsp;vulnerabilities disclosed in recent years, this exploit uses popup menu objects. For example, the Sednit group\u2019s local privilege escalation exploit that&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.welivesecurity.com\/2017\/05\/09\/sednit-adds-two-zero-day-exploits-using-trumps-attack-syria-decoy\/\" target=\"_blank\">we analyzed in&nbsp;2017<\/a>&nbsp;used menu objects and techniques very similar to the current exploit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This exploit creates two windows; one for the first stage and another one for the second stage of the exploitation. For the first window, it creates popup menu objects and appends menu items using the&nbsp;<code>CreatePopupMenu<\/code>&nbsp;and&nbsp;<code>AppendMenu<\/code>&nbsp;functions. In addition, the exploit sets up&nbsp;<code>WH_CALLWNDPROC<\/code>&nbsp;and&nbsp;<code>EVENT_SYSTEM_MENUPOPUPSTART<\/code>&nbsp;hooks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then the exploit displays a menu using the&nbsp;<code>TrackPopupMenu<\/code>&nbsp;function. At this point the code hooked to&nbsp;<code>EVENT_SYSTEM_MENUPOPUPSTART<\/code>&nbsp;gets executed. This code attempts to open as the first available item in the menu, by sending a sequence of&nbsp;<code>MN_SELECTITEM<\/code>,&nbsp;<code>MN_SELECTFIRSTVALIDITEM<\/code>&nbsp;and&nbsp;<code>MN_OPENHIERARCHY<\/code> messages to the menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The next step is very important for triggering this vulnerability. The exploit must catch the moment in time when the initial menu is already created, but the sub-menu is only about to be created. For that, the exploit has code that handles the&nbsp;<code>WM_NCCREATE<\/code>&nbsp;message in the&nbsp;<code>WH_CALLWNDPROC<\/code>&nbsp;hook. When the exploit code detects the system is in this state, it sends&nbsp;<code>MN_CANCELMENUS<\/code>&nbsp;(0x1E6) message to the first menu, which cancels that menu. However, its sub-menu is still about to be created.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now if we check this sub-menu object in kernel mode, we would see that&nbsp;<code>tagPOPUPMENU\u2011&gt;ppopupmenuRootequals 0<\/code>. This state allows the attacker to use that element in this kernel structure as a NULL pointer dereference. The exploit allocates a new page at address 0x0 and this address will be treated as a&nbsp;<code>tagPOPUPMENUobject<\/code> (see Figure 1) by the kernel.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a  href=\"https:\/\/www.welivesecurity.com\/wp-content\/uploads\/2019\/07\/01_tagPOPUPMENU_NULL_red-1.png\" data-rel=\"lightbox-gallery-0\" data-rl_title=\"\" data-rl_caption=\"\" data-magnific_type=\"gallery\" title=\"\"><img decoding=\"async\" src=\"https:\/\/www.welivesecurity.com\/wp-content\/uploads\/2019\/07\/01_tagPOPUPMENU_NULL_red-1.png\" alt=\"\" class=\"wp-image-127583\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Figure 1. The&nbsp;<\/em><code>tagPOPUPMENU<\/code>&nbsp;<em>kernel structure<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At this point, the attackers use the second window. The main exploit goal is to flip the&nbsp;<code>bServerSideWindowProc<\/code>&nbsp;bit in the&nbsp;<code>tagWND<\/code>&nbsp;structure of the second window. This causes the execution of a&nbsp;<code>WndProc<\/code>&nbsp;procedure in kernel mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To perform that, the attackers leak the kernel memory address of the<code>&nbsp;tagWND<\/code>&nbsp;structure of the second window by calling the non-exported&nbsp;<code>HMValidateHandle<\/code>&nbsp;function in the&nbsp;<code>user32.dll<\/code>&nbsp;library. Then the exploit crafts a fake&nbsp;<code>tagPOPUPMENU<\/code>&nbsp;object at the NULL page and sends a&nbsp;<code>MN_BUTTONDOWN<\/code>&nbsp;message to a sub-menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that, the kernel will eventually execute the&nbsp;<code>win32k!xxxMNOpenHierarchy<\/code>&nbsp;function.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a  href=\"https:\/\/www.welivesecurity.com\/wp-content\/uploads\/2019\/07\/02_HMAssignmentLock-1.png\" data-rel=\"lightbox-gallery-0\" data-rl_title=\"\" data-rl_caption=\"\" data-magnific_type=\"gallery\" title=\"\"><img decoding=\"async\" src=\"https:\/\/www.welivesecurity.com\/wp-content\/uploads\/2019\/07\/02_HMAssignmentLock-1.png\" alt=\"\" class=\"wp-image-127584\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Figure 2. Disassembled code of the&nbsp;<\/em><code>win32k!xxxMNOpenHierarchy<\/code>&nbsp;function<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This function passes a crafted object at the NULL page to&nbsp;<code>win32k!HMAssignmentLock<\/code>. The&nbsp;<code>bServerSideWindowProc<\/code>&nbsp;bit is set inside the&nbsp;<code>win32k!HMDestroyUnlockedObject<\/code>&nbsp;function, which is located a few calls deeper inside&nbsp;<code>win32k!HMAssignmentLock<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a  href=\"https:\/\/www.welivesecurity.com\/wp-content\/uploads\/2019\/07\/03_HMDestroyUnlockedObject-1.png\" data-rel=\"lightbox-gallery-0\" data-rl_title=\"\" data-rl_caption=\"\" data-magnific_type=\"gallery\" title=\"\"><img decoding=\"async\" src=\"https:\/\/www.welivesecurity.com\/wp-content\/uploads\/2019\/07\/03_HMDestroyUnlockedObject-1.png\" alt=\"\" class=\"wp-image-127585\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Figure 3. Disassembled code of the&nbsp;<\/em><code>win32k!HMDestroyUnlockedObject<\/code>&nbsp;function<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Everything is done! Now the exploit can send a specific message to the second window in order to execute&nbsp;<code>WndProc<\/code>&nbsp;in kernel mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The exploit only works against older versions of Windows, because since Windows 8 a user process is not allowed to map the NULL page. Microsoft back-ported this mitigation to Windows 7 for x64-based systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">People who still use Windows 7 for 32-bit systems Service Pack 1 should consider updating to newer operating systems, since extended support of Windows 7 Service Pack 1 ends on&nbsp;<a href=\"http:\/\/windows.microsoft.com\/en-us\/windows\/lifecycle\" target=\"_blank\" rel=\"noreferrer noopener\">January 14<sup>th<\/sup>, 2020<\/a>. Which means that Windows 7 users won\u2019t receive critical security updates. Thus, vulnerabilities like this one will stay unpatched forever.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Indicators of Compromise (IoCs)<\/strong><\/p>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>SHA-1 hash<\/th><th>ESET detection name<\/th><\/tr><\/thead><tbody><tr><td>CBC93A9DD769DEE98FFE1F43A4F5CADAF568E321<br><\/td><td>Win32\/Exploit.CVE-2019-1132.A<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p class=\"wp-block-paragraph\">Source: <a href=\"https:\/\/www.welivesecurity.com\/2019\/07\/10\/windows-zero-day-cve-2019-1132-exploit\/\">Welivesecurity<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In June 2019, ESET researchers identified a zero-day exploit being used in a highly targeted attack in Eastern Europe. The exploit abuses a local privilege escalation vulnerability in Microsoft Windows, specifically a NULL pointer dereference in the&nbsp;win32k.sys&nbsp;component. Once the exploit was discovered and analyzed, it was reported to the Microsoft Security Response Center, who promptly [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":3542,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2880],"tags":[],"class_list":["post-3541","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-digital-security"],"acf":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/posts\/3541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/comments?post=3541"}],"version-history":[{"count":0,"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/posts\/3541\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/media\/3542"}],"wp:attachment":[{"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/media?parent=3541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/categories?post=3541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eset.ee\/et\/en\/wp-json\/wp\/v2\/tags?post=3541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}