{"id":3633,"date":"2013-08-02T07:00:00","date_gmt":"2013-08-02T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2013\/08\/02\/it-rather-involved-being-on-the-other-side-of-this-airtight-hatchway-open-access-to-the-application-directory\/"},"modified":"2020-12-07T09:30:55","modified_gmt":"2020-12-07T17:30:55","slug":"it-rather-involved-being-on-the-other-side-of-this-airtight-hatchway-open-access-to-the-application-directory","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20130802-00\/?p=3633","title":{"rendered":"It rather involved being on the other side of this airtight hatchway: Open access to the application directory"},"content":{"rendered":"<p>A security vulnerability report arrived claiming that the Program\u00a0X installer was insecure because it loaded a DLL (let&#8217;s call it <code>HAHA.DLL<\/code>) from the current directory, thereby being susceptible to a <a title=\"Using delayload to detect functionality is a security vulnerability\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20101111-00\/?p=12303\"> current directory attack<\/a>. (Other terms for this type of attack are <i>DLL planting<\/i> and <i>DLL side-loading<\/i>.)<\/p>\n<p>The vendors who were responsible for Program\u00a0X forwarded the report to Microsoft because their program never loaded <code>HAHA.DLL<\/code> directly; it was being loaded by a system component.<\/p>\n<p>The first order of business was to verify that it was actually a DLL planting vulnerability. And it wasn&#8217;t. It was an application directory attack, not a current directory attack. It turns out that a lot of purported DLL planting vulnerability reports are actually application directory attacks. DLLs in the application directory take priority over system DLLs because <a title=\"In Windows, the directory is the application bundle\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110620-00\/?p=10393\"> the directory is the Windows equivalent of what on the Mac is called an application bundle<\/a>.\u00b9 Which only serves to highlight the importance of <a title=\"The TEMP directory is like a public hot tub whose water hasn't been changed in over a year\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20121031-00\/?p=6203\"> securing your application directory<\/a>.<\/p>\n<p>In the original report, Program\u00a0X was in a directory called something like <code>\\\\server\\<wbr \/>software\\<wbr \/>install<\/code>, which was filled with setup programs for various applications. As a result, all of the programs were <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2012\/10\/31\/10364271.aspx\"> soaking in the same hot-tub<\/a>.<\/p>\n<p>When this issue was pointed out to the vendors of Program\u00a0X, they responded, &#8220;No, this is still a bug. You need to add <code>HAHA.DLL<\/code> to the KnownDlls list so that it cannot be overridden by the application directory.&#8221;<\/p>\n<p>The KnownDlls list is <a> not a security feature<\/a>. It is a <i>performance<\/i> feature. The fact that KnownDlls overrides the application directory is a side-effect of its implementation (namely, to avoid directory searching for popular DLLs), and it is arguably a bug, since it breaks contractual behavior: The application directory no longer takes precedence over the system directory. The Application Compatibility folks spend a lot of time studying the KnownDlls list to make sure that the DLLs in there are ones that no properly-functioning application should be trying to override with a local copy.<\/p>\n<p>Even if <code>HAHA.DLL<\/code> were added to the KnownDlls list, that does not guarantee that it will always be loaded from the system directory. If somebody can attack your application directory, then they can drop a DLL redirection manifest into the directory or use DotLocal DLL redirection, both of which also override KnownDlls. (Observe that both of these attacks require write access to the application directory.)<\/p>\n<p>The application directory is your safety bubble. If you let anybody into your safety bubble, then it isn&#8217;t very safe any more.<\/p>\n<p>In the parlance of airtight hatchways: Granting open write access to your application directory is equivalent to leaving open the door to your airtight hatchway.<\/p>\n<p>\u00b9 I used to say simply &#8220;The directory is the application bundle&#8221;, but I&#8217;m now forced to use the much more awkward formulation because at least one person <a> thought I was talking about Windows Store application bundles<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can&#8217;t just let anybody into your safety bubble.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-3633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>You can&#8217;t just let anybody into your safety bubble.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/3633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=3633"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/3633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=3633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=3633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=3633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}