{"id":183,"date":"2014-12-18T13:47:10","date_gmt":"2014-12-18T13:47:10","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/bharry\/2014\/12\/18\/git-vulnerability-with-gitconfig\/"},"modified":"2019-02-16T22:46:48","modified_gmt":"2019-02-16T22:46:48","slug":"git-vulnerability-with-gitconfig","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/bharry\/git-vulnerability-with-gitconfig\/","title":{"rendered":"Git vulnerability with .gitconfig"},"content":{"rendered":"<p>Today the Git community disclosed an issue in Git that, in the worst case, could allow a developer&rsquo;s machine to be taken over.&nbsp; This is an issue that manifests across much of the Git ecosystem and is not unique to Microsoft&rsquo;s Git implementation or to Windows.&nbsp; I&rsquo;ll describe the problem and the steps we&rsquo;ve taken to ensure our customers using Git repositories are protected against this issue.\nFirst, I want to thank the Hg (Mercurial) community for their help.&nbsp; An analogous issue was discovered in Hg.&nbsp; They took the time to look at Git and discovered that the same issue existed.&nbsp; They carefully informed appropriate people in the community, shared information and controlled disclosure until preparations could be made to mitigate the issue.&nbsp; It&rsquo;s a great example of cooperation in the community.<\/p>\n<h3>The problem<\/h3>\n<p>Git has a file that it stores in your local GIt repository called config, in the .git folder.&nbsp; This file contains a number of personal\/preference settings.&nbsp; Among them are aliases for git commands.&nbsp; Using an alias, pretty much any git command can be repurposed to do anything you want.\nNormally the git client avoids ever overwriting that file.&nbsp; Even if you commit a .git\\config file and push it to a shared repo, no one else&rsquo;s Git client will check it out into their private repos.&nbsp; However, a bug was discovered where various permutations of the .git folder name (e.g. mixed case, gIT, GiT, etc, Windows filename shortening .git~123, Ignorable Unicode codepoints .g\\u200cit\\config, etc) were not caught be the Git client&rsquo;s filtering logic.&nbsp; As such, if someone pushed a malicious config file with one of these permutations, other people&rsquo;s Git clients would check them out, overwriting their personal config file and hijacking their Git commands.&nbsp; This affects, at least, Windows NTFS and Mac OS X HFS+ filesystems, both of which are case insensitive filesystems.<\/p>\n<h3>The risk<\/h3>\n<p>The risk is not quite as bad as it sounds.&nbsp; For someone to do this to you, they have to have commit rights to a repo that you pull from.&nbsp; Inside a corporation, that would likely have to be an attack from the inside.&nbsp; The most likely (not only, but most likely) scenario here is in some small OSS project.&nbsp; Large ones generally have pretty well known\/trusted committers.&nbsp; Further, as you&rsquo;ll see below, steps have been take to mitigate this.<\/p>\n<h3>The fix<\/h3>\n<p>We and other members of the Git community have worked together to prepare for this issue becoming public.&nbsp; I won&rsquo;t speak for others but I know core Git and GitHub have both mitigated the issue.&nbsp; I&rsquo;ll talk concretely about steps we (Microsoft) have taken.<\/p>\n<ol>\n<li>A week or so ago, we applied a patch both to VS Online and Codeplex that prevents the server from accepting pushes of .git\\config files.&nbsp; The bug really isn&rsquo;t on the server (it&rsquo;s in the client) but by doing this we reduce the possibility of any unpatched client from being exploited from one of our services.<\/li>\n<li>We have prepared the same server fix for TFS 2013 (both RTM and Update 4).&nbsp; TFS 2013 is the only TFS version that supports hosting Git repositories.&nbsp; This will allow TFS administrators to take the same preventative steps as we have with VS Online and Codeplex.&nbsp; If you are on some TFS 2013 Update other than 4 (Update 1, 2 or 3), you will need to upgrade to Update 4 before applying the patch.<\/li>\n<ol>\n<li><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=523726\">TFS 2013 RTM patch<\/a><\/li>\n<li><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=523727\">TFS 2013 Update 4 patch<\/a><\/li>\n<\/ol>\n<li>We have released patches for Visual Studio 2013 RTM, Visual Studio 2013 Update 4 and for our VS 2012 VSIX extension so customers can patch their clients to be safe.&nbsp; Note, Visual Studio does not use any of the Git aliases but we want to be sure that VS cannot be used as an attack vector to get a malicious config file downloaded on to people&rsquo;s machines such that the attack completes the first time the developer drops to the command line to use some git CLI.&nbsp; If you are on some VS 2013 Update other than 4 (Update 1, 2 or 3), you will need to upgrade to Update 4 before applying the patch.<\/li>\n<ol>\n<li><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=523728\">VS 2013 RTM patch<\/a><\/li>\n<li><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=523729\">VS 2013 Update 4 patch<\/a><\/li>\n<li><a href=\"https:\/\/visualstudiogallery.msdn.microsoft.com\/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c\">VS 2012 VSIX update<\/a><\/li>\n<\/ol>\n<li>As part of all of this, we also worked together with the community to patch the <a href=\"https:\/\/github.com\/libgit2\/libgit2\">LibGit2 open source library<\/a> that many of us share as the core of our Git implementations.<\/li>\n<\/ol>\n<p>You&rsquo;ll find other important, related posts here:<\/p>\n<ul>\n<li>Main announce post: <a href=\"http:\/\/git-blame.blogspot.com\/2014\/12\/git-1856-195-205-214-and-221-and.html\">http:\/\/git-blame.blogspot.com\/2014\/12\/git-1856-195-205-214-and-221-and.html<\/a><\/li>\n<li>Core git patch:&nbsp;&nbsp; <a href=\"https:\/\/git.kernel.org\/cgit\/git\/git.git\/commit\/?id=3f1509809e728b70ea7912e4e1b40f22965e45ee\">https:\/\/git.kernel.org\/cgit\/git\/git.git\/commit\/?id=3f1509809e728b70ea7912e4e1b40f22965e45ee<\/a><\/li>\n<li>Git for Windows: <a href=\"http:\/\/msysgit.github.io\/\">http:\/\/msysgit.github.io\/<\/a><\/li>\n<\/ul>\n<p>Hopefully this clearly explains the issue and what you can do about it.<\/p>\n<p>Brian<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today the Git community disclosed an issue in Git that, in the worst case, could allow a developer&rsquo;s machine to be taken over.&nbsp; This is an issue that manifests across much of the Git ecosystem and is not unique to Microsoft&rsquo;s Git implementation or to Windows.&nbsp; I&rsquo;ll describe the problem and the steps we&rsquo;ve taken [&hellip;]<\/p>\n","protected":false},"author":244,"featured_media":14617,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[5,4,8],"class_list":["post-183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-tfs","tag-visual-studio","tag-vsonline"],"acf":[],"blog_post_summary":"<p>Today the Git community disclosed an issue in Git that, in the worst case, could allow a developer&rsquo;s machine to be taken over.&nbsp; This is an issue that manifests across much of the Git ecosystem and is not unique to Microsoft&rsquo;s Git implementation or to Windows.&nbsp; I&rsquo;ll describe the problem and the steps we&rsquo;ve taken [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/users\/244"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/media\/14617"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}