LWN: Comments on "Git security fixes released" https://lwn.net/Articles/891112/ This is a special feed containing comments posted to the individual LWN article titled "Git security fixes released". en-us Fri, 19 Sep 2025 05:12:25 +0000 Fri, 19 Sep 2025 05:12:25 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Git security fixes released https://lwn.net/Articles/891368/ https://lwn.net/Articles/891368/ mathstuf <div class="FormattedComment"> LFS does technically have a flag, but it is an envvar which is tedious to consistently maintain.<br> <p> And while true, the build system is where I&#x27;d expect any surreptitious behavior to go since that already has a blanket contract to execute code.<br> </div> Thu, 14 Apr 2022 17:37:11 +0000 Git security fixes released https://lwn.net/Articles/891367/ https://lwn.net/Articles/891367/ mathstuf <div class="FormattedComment"> Probably as many that lurk in and around functions passed to signal(7) APIs.<br> </div> Thu, 14 Apr 2022 17:34:46 +0000 Git security fixes released https://lwn.net/Articles/891363/ https://lwn.net/Articles/891363/ agateau More details can be found in this article: <a href="https://blog.sonarsource.com/securing-developer-tools-git-integrations">https://blog.sonarsource.com/securing-developer-tools-git-integrations</a>. Thu, 14 Apr 2022 16:00:35 +0000 Git security fixes released https://lwn.net/Articles/891362/ https://lwn.net/Articles/891362/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; (MSVC still has problems with some long filenames) </font><br> <p> _This_ is the mind-boggling part.<br> <p> <font class="QuotedText">&gt; which made projects run back to `C:\foo` and lose their spaces-in-paths test cases.</font><br> <p> I wonder how many security holes lie there...<br> </div> Thu, 14 Apr 2022 15:18:45 +0000 Git security fixes released https://lwn.net/Articles/891355/ https://lwn.net/Articles/891355/ ericproberts <div class="FormattedComment"> This type of vulnerability feels like it should be more common, since a lot of tools walk back directories.<br> <p> For instance (on OSX but I think it would work the same on Linux):<br> <p> $ touch -p /tmp/node_modules/lodash<br> $ echo &#x27;console.log(&quot;pwn&quot;)&#x27; &gt;/tmp/node_modules/lodash/index.js<br> $ sudo chown -R nobody:nobody /tmp/node_modules<br> <p> $ mkdir /tmp/nodeproject &amp;&amp; cd /npm/nodeproject<br> $ npm init &amp;&amp; npm install<br> $ node &lt;&lt;&lt;&#x27;require(&quot;lodash&quot;)&#x27;<br> pwn<br> <p> This requires importing an uninstalled package, so it seems of limited usefulness, but some packages will use a try { require(&quot;...&quot;) } catch {} for optional dependencies.<br> </div> Thu, 14 Apr 2022 13:12:25 +0000 Git security fixes released https://lwn.net/Articles/891353/ https://lwn.net/Articles/891353/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; I enable LFS per-repo because I don&#x27;t want to clone a repo and get smacked with tons of data I don&#x27;t care about because I&#x27;m fixing a typo.</font><br> <p> LFS could have an option to enable or disable it which is separate from the definitions of the filter commands. Only the filter command lines would need to be set globally.<br> <p> <font class="QuotedText">&gt; At $DAYJOB, we also use repo-local aliases which call scripts in the repo so that we can maintain them sensibly.</font><br> <p> That&#x27;s obviously a gaping security hole if you might run Git commands from a repo someone else has write access to, whether deliberately or accidentally.<br> <p> Perhaps `git config` could add the ability to configure per-repo settings in the global user configuration files, which you could then import explicitly? Or as with the fix in this article you could globally configure a list of &quot;trusted&quot; repos (or paths containing repos) which are allowed to define commands in the repos&#x27; configuration files.<br> </div> Thu, 14 Apr 2022 12:44:10 +0000 Git security fixes released https://lwn.net/Articles/891321/ https://lwn.net/Articles/891321/ hmh <div class="FormattedComment"> Apparently, there is a fresh new release to address some of it, adding the equivalent to a disable switch...<br> <p> https://public-inbox.org/git/xmqq1qy04iqa.fsf@gitster.g/<br> <p> However, one should keep in mind that wherever the security fix broke a build system under &quot;fakeroot&quot; or &quot;sudo&quot;, that build system is running git as a privileged (or fake-privileged) user in a generally unsafe way. It might not be a big deal in some particular setup, obviously, but it is a very bad, and unsafe, practice in the general case.<br> <p> IMO, fixing the build system to never call git in targets that are run as a privileged user (install, uninstall, etc) would be the appropriate response, medium-term. Short-term, you do what you need to do, of course... but it would be best to ensure parent directories are secure first thing...<br> <p> And yeah, that does mean one should rethink how those powerful git-aware prompts or powerlines in shells should be enabled in a path-aware way or not enabled by default...<br> </div> Thu, 14 Apr 2022 11:27:06 +0000 Git security fixes released https://lwn.net/Articles/891283/ https://lwn.net/Articles/891283/ NYKevin <div class="FormattedComment"> Well, there&#x27;s also C:\Program Files, so at least your actual binary has to support spaces in its path, but the Python people managed to even avoid doing that by installing into C:\Python3x (where x is the minor version).<br> </div> Thu, 14 Apr 2022 02:39:31 +0000 Git security fixes released https://lwn.net/Articles/891282/ https://lwn.net/Articles/891282/ NYKevin <div class="FormattedComment"> As someone who has done similar things (but not for Git specifically), I can tell you why people do this: We can&#x27;t stand waiting for the damn prompt to finish rendering. My prompt should print in under ~200 ms, but that&#x27;s unrealistic if you&#x27;re going to invoke half a dozen subshells on random command substitutions and the like. There are basically two ways out of this:<br> <p> 1. The right, but difficult way: Spawn a daemon or daemon-like process (running as yourself, e.g. using systemd&#x27;s --user functionality, or just by persuading your shell to fork off a coprocess somehow) which knows how to find all of the information that your shell needs to print out its prompt, and then have your shell asynchronously send &quot;I cd&#x27;d to a new directory&quot; notifications to this daemon and asynchronously read updated prompt information from the daemon via some pipe/socket nonsense. Then you can get away with running heavy stuff like Git or Mercurial in the daemon, and your shell updates its prompt when the daemon eventually gets back to it.<br> 2. The wrong, but easy way: Take shortcuts such as looking for .git, .hg, etc. by hand, hard-coding paths that you &quot;know&quot; have certain semantics in practice (e.g. &quot;I know that the Git repos always live under /foo/bar/ on this system, so I will match ${PWD} against that prefix and then do [[ -d /foo/bar/$WHATEVER_WE_MATCHED/.git ]] to see whether we&#x27;re in a Git repo&quot;), etc., and never, ever spawn any more subshells than absolutely necessary (e.g. if a shell function has to return a string, do REPLY=&quot;$value&quot; instead of printf &quot;%s\n&quot; &quot;$value&quot;, and then you don&#x27;t need to run it in a command substitution).<br> <p> Tooling for (1) exists (e.g. zsh-async), but it&#x27;s slightly more of a PITA to set up compared to just doing (2) everywhere (and also, I don&#x27;t like running random GitHub code at $WORKPLACE unless it&#x27;s in the package repository and somebody has vetted it), so you end up with horrible spaghetti code all over your .bashrc/.zshrc/what-have-you. It&#x27;s a problem, but I wouldn&#x27;t call it a big problem because ultimately it&#x27;s just a shell prompt, it doesn&#x27;t (directly) make $WORKPLACE money or anything like that.<br> </div> Thu, 14 Apr 2022 02:36:24 +0000 Git security fixes released https://lwn.net/Articles/891272/ https://lwn.net/Articles/891272/ hmh <div class="FormattedComment"> It broke a lot of things related to calling git in the build system while under sudo or fakeroot, yes.<br> <p> Including in git itself. Look at the reply to the announcement message...<br> </div> Wed, 13 Apr 2022 22:42:38 +0000 Git security fixes released https://lwn.net/Articles/891270/ https://lwn.net/Articles/891270/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; Perhaps configuration options which define external commands such as this should only be honored in the system and user global configuration files, and not the ones in the repos? (This would also include aliases, diff tools, filters, etc.)</font><br> <p> Please no. I enable LFS per-repo because I don&#x27;t want to clone a repo and get smacked with tons of data I don&#x27;t care about because I&#x27;m fixing a typo. Fedora&#x27;s `git-lfs` package now has a(n opt-in) mechanism to stop it from installing its filter configuration on the system because I asked for it :) .<br> <p> At $DAYJOB, we also use repo-local aliases which call scripts in the repo so that we can maintain them sensibly.<br> </div> Wed, 13 Apr 2022 22:09:00 +0000 Git security fixes released https://lwn.net/Articles/891268/ https://lwn.net/Articles/891268/ nybble41 <div class="FormattedComment"> The article refers to `core.fsmonitor`:<br> <p> <font class="QuotedText">&gt; If set, the value of this variable is used as a command which will identify all files that may have changed since the requested date/time. This information is used to speed up git by avoiding unnecessary processing of files that have not changed.</font><br> <p> … which seems like a natural fit for a command like `git status`.<br> <p> Perhaps configuration options which define external commands such as this should only be honored in the system and user global configuration files, and not the ones in the repos? (This would also include aliases, diff tools, filters, etc.)<br> </div> Wed, 13 Apr 2022 21:47:12 +0000 Git security fixes released https://lwn.net/Articles/891240/ https://lwn.net/Articles/891240/ dskoll <p>Well, I guess it would fail. But so far it works for all of my use-cases. The source, if anyone is interested, is at <a href="https://dianne.skoll.ca/hacks/gitquickbranch.c">gitquickbranch.c</a>. Wed, 13 Apr 2022 19:26:02 +0000 Git security fixes released https://lwn.net/Articles/891234/ https://lwn.net/Articles/891234/ dtlin But does it know how to follow <tt>git-worktree</tt> to the base repository? There's no <tt>.git/HEAD</tt> there. Wed, 13 Apr 2022 18:35:39 +0000 Git security fixes released https://lwn.net/Articles/891230/ https://lwn.net/Articles/891230/ dskoll <p>I use PS1 to set the git branch in my prompt, but I don't actually invoke <tt>git</tt> to find the branch. I wrote my own program that traverses up to / looking for <tt>.git/HEAD</tt>. It's way smaller and faster than <tt>git</tt> and also much simpler. Wed, 13 Apr 2022 18:21:33 +0000 Git security fixes released https://lwn.net/Articles/891223/ https://lwn.net/Articles/891223/ jthill <p> You can't alias builtins for obviously good reason, I think it's that a planted config could define aliases that will override the user's possibly in a way that's hard to detect, so the user might use `git st` whether in their prompt generator or otherwise. Computer labs full of teenage boys . . . yeah, okay. <p> The check is only on auto-discovered repos, easy enough to shut it off by specifying the repo in GIT_DIR when you know the one you want. <p> Seems to me the safe-directory entries should support globbing, making trusted environments hard to administer is legitimately objectionable. Wed, 13 Apr 2022 17:26:45 +0000 Git security fixes released https://lwn.net/Articles/891226/ https://lwn.net/Articles/891226/ mathstuf <div class="FormattedComment"> Builtins cannot be aliased (AFAIK). I suspect there are hooks one could leave laying around that end up with arbitrary code execution. `pre-auto-gc` seems like something `git status` could trigger.<br> </div> Wed, 13 Apr 2022 17:09:12 +0000 Git security fixes released https://lwn.net/Articles/891225/ https://lwn.net/Articles/891225/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; was so that apps would have to support spaces in paths if they wanted to be capable of moving away from legacy FAT &quot;mydocu~1&quot; altnames.</font><br> <p> Which was naive. Instructions just said to go to `C:\foo` instead. This may have worked for a while, but then `Documents and Settings` made it easy to run into path length limits (MSVC still has problems with some long filenames) which made projects run back to `C:\foo` and lose their spaces-in-paths test cases.<br> <p> <font class="QuotedText">&gt; but actual development tools like build systems - in the 2020s that don&#x27;t support spaces in paths is mind-boggling.</font><br> <p> IME, the issues actually usually come from autoconf-based (or raw Makefile) packages where quoting those `$(topdir)` and such expansions is pretty lax. In CMake, you&#x27;re usually OK, but sometimes someone does something that tries to pass paths around without any thought about &quot;might be seen as two words later&quot;.<br> </div> Wed, 13 Apr 2022 17:06:36 +0000 Git security fixes released https://lwn.net/Articles/891221/ https://lwn.net/Articles/891221/ apoelstra <div class="FormattedComment"> I&#x27;m a bit confused -- can `git status` be made to run arbitrary code? Is the issue that somebody could, for example, edit `.git/config` to alias `git status` to something malicious?<br> </div> Wed, 13 Apr 2022 16:15:56 +0000 Git security fixes released https://lwn.net/Articles/891218/ https://lwn.net/Articles/891218/ nye <div class="FormattedComment"> Thanks, this appears to be the missing link - to my great surprise, it turns out that by default &quot;Authenticated Users&quot; has the &quot;Create folders / append data&quot; bit set explicitly for C: by default.<br> <p> That&#x27;s pretty horrifying but I suppose there are compatibility concerns that would make it hard to fix now.<br> </div> Wed, 13 Apr 2022 15:40:45 +0000 Git security fixes released https://lwn.net/Articles/891213/ https://lwn.net/Articles/891213/ ceplm <div class="FormattedComment"> Other shells (I use fish) have such prompts running scripts as default.<br> </div> Wed, 13 Apr 2022 15:00:31 +0000 Git security fixes released https://lwn.net/Articles/891208/ https://lwn.net/Articles/891208/ Karellen <p>IIRC one of the reasons that Windows started creating paths with spaces by default back in the '90s (e.g. "My Documents", and later "Documents and Settings") was so that apps would <em>have</em> to support spaces in paths if they wanted to be capable of moving away from legacy FAT "mydocu~1" altnames.</p> <p>The idea that there are Windows applications - and not just in-house LOB apps, but actual development tools like build systems - in the 2020s that don't support spaces in paths is mind-boggling.</p> Wed, 13 Apr 2022 14:26:41 +0000 Git security fixes released https://lwn.net/Articles/891185/ https://lwn.net/Articles/891185/ nickleverton <div class="FormattedComment"> Thanks for the headsup, it was very timely. All over the world, embedded system packagers are tearing their hair out wondering why their builds are now failing, because git under fakeroot now fails with a complaint about unsafe directories when image assembly scripts try to capture the hash for HEAD of the build tree.<br> </div> Wed, 13 Apr 2022 14:13:50 +0000 Git security fixes released https://lwn.net/Articles/891142/ https://lwn.net/Articles/891142/ jdisnard <div class="FormattedComment"> <font class="QuotedText">&gt; On Unix it&#x27;s possible to set PS1 to use git, but it&#x27;s not something I&#x27;ve actually seen used, so most users would need to proactively invoke git to get into trouble.</font><br> <p> According to my anecdotal experience, it&#x27;s very very common. I&#x27;ve seen dozens of developers have such a prompt in their bash or zsh shell environment.<br> <p> The idea is so common that the upstream GIT project documented how it works:<br> https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash<br> <p> <p> </div> Wed, 13 Apr 2022 13:27:19 +0000 Git security fixes released https://lwn.net/Articles/891140/ https://lwn.net/Articles/891140/ mathstuf <div class="FormattedComment"> And it&#x27;s often necessary to get paths short enough for some build systems or projects. Or those that don&#x27;t support spaces in paths (yay &quot;Documents and Settings&quot;).<br> </div> Wed, 13 Apr 2022 12:59:25 +0000 Git security fixes released https://lwn.net/Articles/891139/ https://lwn.net/Articles/891139/ mathstuf <div class="FormattedComment"> Doing VCS detection is certainly common enough. I&#x27;ve been using zsh&#x27;s vcs_info for 12 years or so. There are all kinds of blog posts on how to do it too (though they&#x27;ve become less necessary now that git has its own PS1 support).<br> </div> Wed, 13 Apr 2022 12:57:25 +0000 Git security fixes released https://lwn.net/Articles/891138/ https://lwn.net/Articles/891138/ k3ninho <div class="FormattedComment"> <font class="QuotedText">&gt;On Unix it&#x27;s possible to set PS1 to use git, but it&#x27;s not something I&#x27;ve actually seen used, so most users would need to proactively invoke git to get into trouble.</font><br> <p> I have a lot of colleagues who do this, and the Ubuntu ec2 I&#x27;m running hash a .bashrc that pulls in /usr/lib/git-core/git-sh-prompt to add the branchname to the shell prompt. I guess it&#x27;s popular enough that core git package supplies the __git_ps1 function. &quot;it&#x27;s 1337, u kno.&quot;<br> <p> K3n.<br> </div> Wed, 13 Apr 2022 12:55:49 +0000 Git security fixes released https://lwn.net/Articles/891136/ https://lwn.net/Articles/891136/ draco <div class="FormattedComment"> In my experience, non-admin users can usually create directories directly in the root of the C: drive -- even in work environments.<br> </div> Wed, 13 Apr 2022 12:48:17 +0000 Git security fixes released https://lwn.net/Articles/891135/ https://lwn.net/Articles/891135/ tialaramex <div class="FormattedComment"> Most Windows users I&#x27;ve seen who use command line git, do so from an environment in which PS1 is set. So, they don&#x27;t need to actually run &quot;git&quot; to be impacted, every time they look around a directory with this problem they&#x27;re screwed by their shell running git for them. &quot;Git Bash&quot; in particular is a ready to use environment with Git and Bash on Windows. Thus just going into C:\temp to look at a file is enough to trigger the vulnerability for those users.<br> <p> On Unix it&#x27;s possible to set PS1 to use git, but it&#x27;s not something I&#x27;ve actually seen used, so most users would need to proactively invoke git to get into trouble.<br> <p> The other vulnerability is specific to the Uninstaller utility for Git on Windows and so doesn&#x27;t exist on platforms where that&#x27;s not how you uninstall software.<br> </div> Wed, 13 Apr 2022 12:11:32 +0000 Git security fixes released https://lwn.net/Articles/891130/ https://lwn.net/Articles/891130/ nye <div class="FormattedComment"> It stops traversing upwards once it reaches a directory owned by a different user to the one where it started.<br> <p> The thing that confuses me is why all the talk about this seems to imply that it&#x27;s especially bad on Windows, which seems rather counterfactual - on Windows you&#x27;re a great deal less likely to be using a directory under some shared common directory like /tmp, so this is essentially limited to &quot;attacks&quot; from an administrator who can change system directories. But an administrator could just modify your files without bothering with this &quot;exploit&quot;, so...<br> </div> Wed, 13 Apr 2022 10:19:35 +0000 Git security fixes released https://lwn.net/Articles/891127/ https://lwn.net/Articles/891127/ ceplm <div class="FormattedComment"> I am sorry, but this is a horrible changelog message. I am not that much interested in what’s the original problem, but I would like to learn what is the solution provided by the new change.<br> <p> So, what has actually changed?<br> </div> Wed, 13 Apr 2022 09:32:53 +0000 Git security fixes released https://lwn.net/Articles/891125/ https://lwn.net/Articles/891125/ tamiko <div class="FormattedComment"> It is a bit surprising that this well known behavior has been identified as a security vulnerability now and not years ago. But better late than never.<br> <p> For example, one a Linux machine user A can simply create a git repository in /tmp and when user B comes along who happens to have a shell command line showing a git repository status it is game over. I remember discussing this with someone years ago...<br> </div> Wed, 13 Apr 2022 08:39:25 +0000