{"id":7092,"date":"2020-04-09T22:31:19","date_gmt":"2020-04-09T22:31:19","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=7092"},"modified":"2020-04-09T23:14:05","modified_gmt":"2020-04-09T23:14:05","slug":"tag-me-if-you-can-driver","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2020\/04\/09\/tag-me-if-you-can-driver\/","title":{"rendered":"Tag me if you can&#8230; driver"},"content":{"rendered":"\n<p>Developers of kernel drivers rely on these two memory allocation functions:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/wdm\/nf-wdm-exallocatepoolwithtag\">ExAllocatePoolWithTag<\/a><\/li><li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/wdm\/nf-wdm-exfreepoolwithtag\">ExFreePoolWithTag<\/a><\/li><\/ul>\n\n\n\n<p>The <em>Tag<\/em> parameter that these 2 functions take is defined as:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>The tag is a non-zero character literal of one to to four characters delimited by single quotation marks (for example, &#8216;Tag1&#8217;). The string is usually specified in reverse order (for example, &#8216;1gaT&#8217;). Each ASCII character in the tag must be a value in the range 0x20 (space) to 0x7E (tilde). Each allocation code path should use a unique pool tag to help debuggers and verifiers identify the code path.<\/p><\/blockquote>\n\n\n\n<p>While I am not a kernel mode driver developer, and somehow kernel mode was never even that interesting to me, I did a fair amount of code reading over the years&#8230; primarily focused on snippets from Microsoft Documentation (DDK\/WDM), and rootkits&#8217; source codes. And if there was one thing that stuck with me after reading all this code good\/bad-ness&#8230; it was that most of the developers rarely changed the tags used by these two memory allocation functions from the tags used in Microsoft samples &#8211; that is, &#8216;Ddk &#8216;, and &#8216;Wdm &#8216;.<\/p>\n\n\n\n<p>So&#8230; assuming everyone does it&#8230; I went on an adventure to find out what actual tags are being used out there apart from these memorable two.<\/p>\n\n\n\n<p>To address the question I looked at the corpora of 60K+ signed drivers for both 32- and 64- bit architectures, did some automation, data crunching, and eventually came up with a list of which exempt is presented below. And in fairness, I did hope I can find some interesting, playful tags, but reality was actually pretty boring&#8230;<\/p>\n\n\n\n<p>So, without further ado, these are the top 20 tags I found:<\/p>\n\n\n\n<ul><li>6D437A41 107843 AzCm<\/li><li>774E6350 65888 PcNw<\/li><li>42434541 36356 AECB<\/li><li>6D446266 30262 fbDm<\/li><li>7A67554D 25411 MUgz<\/li><li>56727444 24846 DtrV<\/li><li>64417A41 23406 AzAd<\/li><li>206D6457 20588 Wdm<\/li><li>7453764E 20228 NvSt<\/li><li>4D444351 15442 QCDM<\/li><li>53537442 15104 BtSS<\/li><li>6C4C7A41 14364 AzLl<\/li><li>6D457674 13254 tvEm<\/li><li>64577A41 12498 AzWd<\/li><li>4D6253 11940 SbM<\/li><li>65487A41 11662 AzHe<\/li><li>6D507A41 11660 AzPm<\/li><li>484C764E 11410 NvLH<\/li><li>34387A41 10561 Az84<\/li><li>5A41564E 9883 NVAZ<\/li><\/ul>\n\n\n\n<p>Yup. Boooooring!<\/p>\n\n\n\n<p>&#8216;Wdm &#8216; is there on position 8, and the &#8216;Ddk &#8216; was on position 40 (not shown on the list above).<\/p>\n\n\n\n<p>Booooooring intensifies.<\/p>\n\n\n\n<p>Unhappy, after not finding any groundbreaking results, I turned into the &#8216;scandalous&#8217; area. I skimmed the list looking for obscenities, and lo and behold, I quickly discovered a driver that used the following tags:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"296\" height=\"18\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/tag_1.png\" alt=\"\" class=\"wp-image-7093\"\/><\/figure>\n\n\n\n<p>and<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"493\" height=\"16\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/tag_2.png\" alt=\"\" class=\"wp-image-7094\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/tag_2.png 493w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/tag_2-300x10.png 300w\" sizes=\"(max-width: 493px) 100vw, 493px\" \/><\/figure>\n\n\n\n<p>Hooray. Thank you &#8216;O&amp;O Software GmbH&#8217;. Finally this post has some meaning after all.<\/p>\n\n\n\n<p>The hashes you are thinking of now are:<\/p>\n\n\n\n<ul><li>MD5 : A516F6C7738BDB447289A90824480D65<\/li><li>SHA1 : 692CF950D99E4DF33AF1A8EB29831692CB31FC9D<\/li><li>SHA256: 3DCD8EB2FE16232DDB7DE1EBFEE791E0FE29F13B0C75D704A9972E19E697B7C3<\/li><\/ul>\n\n\n\n<p>But it was still booooooring.<\/p>\n\n\n\n<p>Then the other thing caught my eye. I was certainly perplexed by the findings that suggested a lot of tags are being reused by more than one, two companies. For instance, &#8216;AzCm&#8217;, &#8216;PcNw&#8217;, &#8216;AECB&#8217;, &#8216;MUgz&#8217;, &#8216;AzAd&#8217;, &#8216;QCDM&#8217;, &#8216;BtSS&#8217;, &#8216;AzWd&#8217;, and many more. I won&#8217;t list the companies, because I don&#8217;t want to get sued, but it is an interesting conundrum indeed. How come all of these companies use that particular tag, huh? The other striking discovery was that there is a lot of vendor-specific drivers that are re-using these tags and are at the same time signed by the &#8216;Microsoft Windows Hardware Compatibility Publisher&#8217;. I guess the latter phenomenon can be attributed to the Windows Hardware Compatibility Program (anyone knows?).<\/p>\n\n\n\n<p>Back to these shared tags though&#8230; Is it possible that vendors either share code, get access to it via acquisition, or hire the same third party company to write their drivers? <\/p>\n\n\n\n<p>This is a very important question&#8230; <\/p>\n\n\n\n<p>If the answer is YES, then the same memory tags, code habits, and &#8230; bugs&#8230; propagate across a whole bunch of drivers. And this leads to a question: is <a href=\"https:\/\/twitter.com\/hFireF0X\">hfiref0x<\/a> right? His research is pretty much killing it when it comes to buggy driver analysis. As he is constantly, continuously and consistently pointing out&#8230;. the copypasta in a driver industry is a a HUGE driver (pun intended) for many drivers exhibiting the same buggy &#8216;features&#8217;&#8230;<\/p>\n\n\n\n<p>Perhaps it&#8217;s time I run my corpora via the <a href=\"https:\/\/github.com\/eclypsium\/Screwed-Drivers\">ScrewedDrivers<\/a>&#8230;<\/p>\n\n\n\n<p><strong>Update<\/strong><\/p>\n\n\n\n<p>After I posted it, I got some feedback on Twitter which I am posting below (Thx <a href=\"https:\/\/twitter.com\/attrc\">@attrc<\/a>!)<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/techcommunity.microsoft.com\/t5\/ask-the-performance-team\/an-introduction-to-pool-tags\/ba-p\/372983\">https:\/\/techcommunity.microsoft.com\/t5\/ask-the-performance-team\/an-introduction-to-pool-tags\/ba-p\/372983<\/a><\/li><li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/devtest\/poolmon\">https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/devtest\/poolmon<\/a><\/li><\/ul>\n\n\n\n<p>After cross-referencing with the &#8216;pooltag.txt&#8217; file from the latest win10 sdk I I got the following result:<\/p>\n\n\n\n<ul><li>6D437A41 107843 AzCm AzCm HD Audio Class Driver (AzCommon) &#8211; HDAudio.sys<\/li><li>774E6350 65888 PcNw PcNw WDM audio stuff &#8211;<\/li><li>42434541 36356 AECB #N\/A #N\/A<\/li><li>6D446266 30262 fbDm #N\/A #N\/A<\/li><li>7A67554D 25411 MUgz #N\/A #N\/A<\/li><li>56727444 24846 DtrV #N\/A #N\/A<\/li><li>64417A41 23406 AzAd AzAd HD Audio Class Driver (AzPcAudDev) &#8211; HDAudio.sys<\/li><li>206D6457 20588 Wdm Wdm WDM &#8211;<\/li><li>7453764E 20228 NvSt #N\/A #N\/A<\/li><li>4D444351 15442 QCDM #N\/A #N\/A<\/li><li>53537442 15104 BtSS #N\/A #N\/A<\/li><li>6C4C7A41 14364 AzLl #N\/A #N\/A<\/li><li>6D457674 13254 tvEm #N\/A #N\/A<\/li><li>64577A41 12498 AzWd AzWd HD Audio Class Driver (AzWidget) &#8211; HDAudio.sys<\/li><li>4D6253 11940 SbM #N\/A #N\/A<\/li><li>65487A41 11662 AzHe #N\/A #N\/A<\/li><li>6D507A41 11660 AzPm #N\/A #N\/A<\/li><li>484C764E 11410 NvLH NvLH nVidia video driver &#8211;<\/li><li>34387A41 10561 Az84 #N\/A #N\/A<\/li><li>5A41564E 9883 NVAZ #N\/A #N\/A<\/li><\/ul>\n\n\n\n<ul><li><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Developers of kernel drivers rely on these two memory allocation functions: ExAllocatePoolWithTag ExFreePoolWithTag The Tag parameter that these 2 functions take is defined as: The tag is a non-zero character literal of one to to four characters delimited by single &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2020\/04\/09\/tag-me-if-you-can-driver\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[39,89,90],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7092"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=7092"}],"version-history":[{"count":10,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7092\/revisions"}],"predecessor-version":[{"id":7104,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7092\/revisions\/7104"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=7092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=7092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=7092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}