{"id":6203,"date":"2012-10-31T07:00:00","date_gmt":"2012-10-31T14:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/10\/31\/the-temp-directory-is-like-a-public-hot-tub-whose-water-hasnt-been-changed-in-over-a-year\/"},"modified":"2021-01-09T09:37:56","modified_gmt":"2021-01-09T17:37:56","slug":"20121031-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20121031-00\/?p=6203","title":{"rendered":"The TEMP directory is like a public hot tub whose water hasn&#8217;t been changed in over a year"},"content":{"rendered":"<p>A customer reported that they couldn&#8217;t install product\u00a0X. When they ran the installer, the got the error message<\/p>\n<div style=\"display: inline-block; border: solid 1px #5284bc;\">\n<table style=\"color: black; background-color: white; hyphens: manual; font-size: 10pt; border: solid 5px #6badf6; border-top: 0pt; width: 30em; font-family: Segoe UI, Tahoma, Arial, sans-serif;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr style=\"font-size: 10pt;\" bgcolor=\"#6badf6\">\n<td style=\"padding-bottom: 5px;\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\">\u00a0<\/td>\n<td align=\"center\" valign=\"bottom\" width=\"100%\">setup.exe &#8211; Application Error<\/td>\n<td align=\"center\"><span style=\"float: right; background-color: #c75050; color: white; font-size: 14pt; width: 32pt;\"> <b>\u00d7<\/b> <\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr style=\"color: black;\">\n<td style=\"padding: 1em;\" colspan=\"2\">The application was unable to start correctly (0xc00000ba). Click OK to close the application.<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color: #f0f0f0; border-top: solid 1px #dfdfdf; padding: 1em; text-align: right;\"><span style=\"display: inline-block; border: solid 1px #adadad;\"> <span style=\"display: inline-block; border: solid 1px #e1e1e1; background-color: #e1e1e1; padding: 2px 1em; width: 5em; text-align: center;\">OK<\/span> <\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>The product\u00a0X setup team weren&#8217;t sure what to make of this, and they asked if anybody had any ideas.<\/p>\n<p>The error code <code>0xc00000ba<\/code> is <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc704588(PROT.10).aspx\"> <code>STATUS_<wbr \/>FILE_<wbr \/>IS_<wbr \/>A_<wbr \/>DIRECTORY<\/code><\/a>, which means that something was supposed to be a file, but instead it was a directory. <a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20120208-00\/?p=8353\"> The path-searching algorithm is not a backtracking algorithm<\/a>, so once it finds something wrong, it just stops rather than backing up and trying the next directory.<\/p>\n<p>This was enough of a clue to direct further investigation, which revealed that the customer had a <i>directory<\/i> named <code>C:\\<wbr \/>Users\\<wbr \/>Bob\\<wbr \/>AppData\\<wbr \/>Local\\<wbr \/>Temp\\<wbr \/>version.dll\\<\/code>. The customer responded, &#8220;There are plenty of directories with names of DLLs in my TEMP directory, but getting rid of this one fixes the issue. Thanks!&#8221;<\/p>\n<p>(Puzzle: Why are there so many directories with the names of DLLs? <a href=\"http:\/\/support.microsoft.com\/kb\/311503\">Psychic answer<\/a>.)<\/p>\n<p>I slipped something past you a little while back. Did you notice?<\/p>\n<p>Okay, I gave it away in the subject line. The setup program is running from the TEMP directory. That should already set off alarm bells.<\/p>\n<p>The TEMP directory is a dumping ground of random junk. A downloader may have put a DLL there and forgotten to delete it. (Or worse, <a href=\"http:\/\/web.archive.org\/web\/20110205091635\/http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2011\/01\/25\/10119675.aspx#10120540\"> expected it to stay there forever<\/a>.) And that DLL might be from an incompatible version of some DLL your setup program uses. (I have seen applications ship their own custom versions of system DLLs! Yeah, because the x86 version of <code>shlwapi.dll<\/code> from Windows\u00a02000 is drop-in compatible with the version of <code>shlwapi.dll<\/code> that comes with Windows\u00a07.) Who knows what other yucky things have been lying around in that directory. Since the application directory is the first directory searched when the system looks for a DLL, a rogue DLL in the TEMP directory is a trap waiting to be sprung. (A similar issue applies to a shared Downloads directory.)<\/p>\n<p>It&#8217;s like the horror movie trope where the frightened pretty girl runs into a room, slams the door shut, then breathes a sigh of relief, believing herself to be safe. But she didn&#8217;t check that the room was empty! (In other words, she created her airtight hatchway around an insecure room.)<\/p>\n<p>The Program\u00a0X setup team decided to change their installer so that it created a <i>subdirectory<\/i> of TEMP and extracted the main setup program there. That way, it got a fresh hot tub with clean water.<\/p>\n<p>Remember, <a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110620-00\/?p=10393\"> the directory is the application bundle<\/a>. If you drop your application into a random directory, you&#8217;ve just added everything in that directory to your bundle. And if you don&#8217;t secure your application directory, you&#8217;re allowing anybody to add components to your bundle. That&#8217;s one of the reasons why the Logo program encourages (requires?) applications to install into the Program Files directory: The ACLs on the Program Files directory allow write access only to administrators and installers. This makes the application bundle secure by default. If you want to make your application bundle insecure, you have to go out of your way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All sorts of germs.<\/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-6203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>All sorts of germs.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/6203","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=6203"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/6203\/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=6203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=6203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=6203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}