{"id":103091,"date":"2019-11-13T07:00:00","date_gmt":"2019-11-13T15:00:00","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/oldnewthing\/?p=103091"},"modified":"2019-11-13T06:42:58","modified_gmt":"2019-11-13T14:42:58","slug":"20191113-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20191113-00\/?p=103091","title":{"rendered":"Not even getting to the airtight hatchway: Planting files in world-writable directories"},"content":{"rendered":"<p>A security vulnerability report came in declaring that the finder had discovered an elevation of privilege vulnerability. They explained that they identified a world-writable directory and that an attacker can exploit the directory by creating or deleting a file, or could perform arbitrary execution from that directory.<\/p>\n<p>Their proof-of-concept copied a file into the world-writable directory and confirmed that it was there and could be read. They also copied an executable into the world-writable directory, and then executed it.<\/p>\n<p>So, yeah, that&#8217;s what happens when you have write permission in a directory. You can copy files into the directory, and that includes copying executables. But so what?<\/p>\n<p>There had yet to be any demonstrated elevation of privilege. The user who copied the files into the directory is the same use that read them out or executed them.<\/p>\n<p>Now, if the system automatically executed programs in that directory as some other user, say because the world-writable directory is on the default <code>PATH<\/code>, or because it&#8217;s a directory like the global Startup Folder, then you&#8217;d have something. You placed an executable in a place that will execute as another user.<\/p>\n<p>But so far, all you did was load a trap. You didn&#8217;t do anything to <i>spring<\/i> the trap.<\/p>\n<p>In order to spring the trap, you need to trick somebody into going into that world-writable directory and running your program. That requires the victim to take some significant nondefault actions, and you&#8217;ll have to convince them to click on multiple things. At this point, what you have is a social engineering attack, not a security vulnerability.<\/p>\n<p>After all, you don&#8217;t have to look around for world-writable directories. You can always make your own!<\/p>\n<pre>mkdir %USERPROFILE%\\trap\r\nicacls %USERPROFILE%\\trap \/grant users:RW\r\n<\/pre>\n<p>Bingo, you just created a world-writable directory, just like the big boys.<\/p>\n<p>Go ahead, copy your favorite malware into that directory. You haven&#8217;t achieved any elevation of privilege. The files are there, but you still have to trick somebody into launching them, and that&#8217;s where the real work begins.<\/p>\n<p><b>Bonus chatter<\/b>: This is a fertile ground for bogus security vulnerability reports. Most such reports claim elevation of privilege, but their &#8220;proof of concept&#8221; document doesn&#8217;t show any actual elevation of privilege. Many of them don&#8217;t even show any code execution! They title their report something like &#8220;Arbitrary file creation could potentially perform arbitrary execution,&#8221; but nowhere in the report is any realization of this potential ever demonstrated.<\/p>\n<p>Any program can be potentially executed. I plug in a USB drive with an executable on it. <i>Oh no, I have potential arbitrary execution!<\/i><\/p>\n<p>That&#8217;s not the hard part. The hard part is getting it executed.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>But who uses that world-writable directory?<\/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-103091","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>But who uses that world-writable directory?<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103091","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=103091"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103091\/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=103091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=103091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=103091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}