All: the originally submitted URL was <a href="https://github.com/git/git/commit/8959555cee7ec045958f9b6dd62e541affb7e7d9" rel="nofollow">https://github.com/git/git/commit/8959555cee7ec045958f9b6dd6...</a>. Readers are divided about which link is better, which probably means you should read both to understand the thread.
<i>> Run the uninstaller under an administrator account rather than as the
SYSTEM user</i><p>How do I run something as SYSTEM? I thought I always ran as "me" or Administrator. Is this only likely to happen for deployment automation tools?<p><i>> Avoid running the uninstaller until after upgrading</i><p>Don't leave us with this cliff-hanger... Does the upgrade installer run the uninstaller first? (The original report doesn't have this bullet point.)
The Windows-specific 'vulnerability' is weird. For one, it's part of the <i>uninstaller</i>, which isn't a common scenario, and secondly... C:\Windows\Temp isn't even writable by unprivileged users by default, it's not even <i>readable</i> by unprivileged users by default (on my relatively fresh Windows 11 system, at least).
> Merely navigating to such a space with a Git-enabled `PS1` when there is a maliciously-crafted `/scratch/.git/` can lead to a compromised account.<p>I'm curious about this -- what's the attack vector here?
This is bullshit. I mean, ok, you are concerned about somebody using git-enabled PS1. Guess what, not everyone is using git-enabled PS1. Unbelievable, right? I would even mock the fact that you are trying to protect users from the behavior they pretty much explicitly allowed, but this is pointless. Truth is, developers are doing something that can fuck up their system daily. Let's forget about wget | bash and copying completely untrusted git repositories (and it's pretty much guaranteed that everybody using git-enabled PS1 won't shy away from that). Just using composer or npm is enough to compromise your system. "Fixing" this is like introducing DRM: you cannot do arbitrary unsafe stuff without doing arbitrary unsafe stuff. And there simply are people out there, who want to do arbitrary unsafe stuff.<p>But ok, let's not take it as an excuse. How about fixing git, then? I mean, actually fixing: making it possible to disable hooks & core.fsmonitor & whatever else they fucked up? No, right, let's just disable git instead.<p>And if I'm reading this correctly, I'm not even allowed to say "I don't care" — I must explicitly mark every shared directory as trusted (I mean, safe.directory = '/' won't work unless / is actually a git directory, right?).<p>I guess I just shouldn't update git until this "fix" is fixed. Or until git is forked.
is_path_owned_by_current_uid(const char *path) isn't symlink safe given a multi-component path.<p>Symlinks, the poisonous gift that keeps on giving.
Well, depending on exactly how much this blocks, this could get pretty awkward -- typing 'git log' in a repo owned by someone else can be awfully handy, even if file system permissions block changing it at all, and putting together a list of all places you might want to do this in advance could get pretty awkward. (Not running hooks, or allowing operations that would trigger them, from non-owned directories would preserve some of this usage, and still at least mitigate the dangerous cases somewhat.)<p>It's also not entirely clear to me what this does to site-wide shared remotes, though I suppose if they can be listed in system config, it's at least not a <i>per-user</i> hassle.
Question for Mac users. Apple installs git with its command line tools and is currently at version 2.32. Is it wise to install git via Homebrew so that you can upgrade faster? Or are there some benefits from apple-git?
If you can create a .git directory above a victim's home directory, then you're root.<p>Or else, if you're not root, you're in messed up system. Whoever is root should go read some 40-year-old book on Unix about how it's supposed to be laid out.<p>This is not a genuine <i>security</i> vulnerability; though of course, it's good to fix it.<p>Here is how I would fix it. Forget about permissions and ownership entirely. There is a weaker, more powerful condition we can check. Ready?<p><i>Git should terminate if it is executed from a subdirectory of a git repo that contains no tracked files according to the first .git/ directory that it finds while ascending the file system.</i><p>If you're in a directory that contains no files that are tracked by the closest .git/
that can be found by walking up the stairs, then that directory has no relationship to that
repo. Git should diagnose that and bail out. (It could allow files in that directory to be added
to the index, but only with -f option to force it.)<p>If git finds a .git/ dir, and that repo's index shows that at least one item in, or below, your working directory is in that repo's index, it should go ahead and work with it, regardless of ownership.
I shouldn’t ask too much of an open source project, etc. etc., but this sounds like something Git should fix themselves rather than just outright disabling. “I want to go into a directory and run git log” is kind of a simple thing to want to do and to not be able to do that sucks. It’s easy to pontificate on this forum but having a “safe” git that doesn’t automatically run hooks or whatever seems like the way forward here, and useful outside of even just a “I want my PS1 to work”.
What is a scenario where you’d be running git in the subdirectory of one owned by a malicious user? Unless a machine is badly configured and administrated, when would one user ever have authority of ownership over /home or /opt or /? And if they have sudo privileges well then they have the authority to do whatever they want. Is this only an issue because of some Windows idiom? I’m somewhat dubious.
Here is a quick fix to prevent system-wide exploits, salt to taste:<p><pre><code> $ grep GIT_CEILING_DIRECTORIES ~/.bashrc
export GIT_CEILING_DIRECTORIES=$HOME:/var/www
</code></pre>
But malicious Git repos could still affect your user profile. You can harden that by putting all git repos in a sandbox, e.g.:<p><pre><code> export GIT_CEILING_DIRECTORIES=$HOME/sandbox</code></pre>
This "fix" breaks deployments where files are checked out as the root user and then chowned to an app-specific user. Any subsequent action as the root user will fail.<p>It seems they forgot to provide an exception for the root user or a way to disable this "feature" on a global level, instead of per-directory.
>This vulnerability affects users working on multi-user machines where a malicious actor could create a .git directory in a shared location above a victim’s current working directory<p>If a malicious actor has access to the filesystem, isn't it a bigger problem? I remember Raymond Chen recounted in his blog that Microsoft usually dismisses vulnerability reports that start with "to use the exploit, you must have access to the machine". As he likes to say, "the gates are already open". If you already have access to the machine and can create files outside of your home directory, what stops you from causing even greater havoc?
Will Ubuntu update to v2.35.2? My current install is using the elder v2.25.1:<p><pre><code> ubuntu@vpn1:$ git --version
git version 2.25.1
ubuntu@vpn1:$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal</code></pre>
Was this change discussed publicly prior to merge?<p>I think this is a big mistake. Build environments use separate users for security purposes. It's insane to decrease security for everyone by requiring a single user to do everything because some of your users want to have fancy terminal prompts.<p>At the very least, let users configure this at a per-user level.
Shouldn't `safe_directory_cb` be checking the key parameter? It's ignoring it completely. So any unrelated config that has a directory in its value will also mark it as safe. Unless I'm misunderstanding something?
The more I think about it, the more I think this is the right call. The only alternative would be something like falling back to running with no hooks and printing a warning to stderr indicating that there are disabled hooks. Actions that modify that repository should also be disabled in that case. Then there should be a command like 'git hooks trust' that adds the directory to the user's list of trusted folders.
And .... there go probably tens of thousands of person-hours of human effort due to fixing this across huge numbers of systems.<p>It's fascinating to me that we have people out there just casually making these kind of decisions with enormous cost implications with barely any thought to the downstream implications. Then meanwhile, we need approval in our org to claim a $30 taxi voucher as an expense.
There's something super jarring about the format of this blog post. I think my brain has been trained to glaze over whenever it runs into corporate abstract art at the top of a page.
Interestingly if you're on Windows, then Chocolatey is the better package manager to use.<p>Microsoft's own package manager Winget only has v2.34.1 right now.<p>Chocolatey
<a href="https://community.chocolatey.org/packages/git#versionhistory" rel="nofollow">https://community.chocolatey.org/packages/git#versionhistory</a><p>Winget
<a href="https://winget.run/pkg/Git/Git" rel="nofollow">https://winget.run/pkg/Git/Git</a>
This feels like a thing that should be introduced default-off, allowing users to opt in to it first, and once it's been in place update the default, rather than break things suddenly when updating without being able to share a git config between systems which don't upgrade simultaneously.
I feel like this doesn't have much to do with Git specifically. Seems to me like PS1 needs to avoid accessing files that aren't owned by the current user. Easier said than done though...
Don’t make tools use processes for “plug-in behavior”. Do one thing and do it well doesn’t really appeal to me to begin with but “let the first thing do the next thing on its own” is definitely a bastardization of that idea as well. Git has that Unix disease where the go to method of getting anything user configurable done with one program is launching <i>another program</i>. I’d much rather use tools that use huge convoluted script languages or good plug-in apis than tools that duct tape together with exit codes.
Deep inside some large enterprise company:<p>Jr Engineer: "Hey, I know we've always managed our little dotnet application via email and shared-network-drive, but I've been reading about a thing called "git" that we should probably use."<p>Sr Engineer: "Change is scary and bad, also we are not a software company. We're not going to learn some newfangled whatsit. Just email me the .vba files when you want me to review the changes with the one copy of visual studio 2008 that our team has access to."<p>Jr Engineer: "C'mon, give it a chance! We can leave everything the way its always been, but have better tracking of changes. Remember that time Bruno hard coded the tool to point to the C: drive? Git would let us just undo that, instead of having to search our emails for the last-most-recent version."<p>Sr Engineer: "Ok fine, I've got 10 minutes, show me."<p>Jr Engineer: "Ahh! Well I just got it installed, so let me go to the network drive... and then I think I have to git init our project folder... huh? Let me just... Maybe if I..."<p>Sr Engineer: "Times up! Looks like this "git" thing isn't compatible with our setup after all. Those modern dev types never make anything that works in a real enterprise environment."
It mildly bugs me that things like this are reported as "Git Security Vuln".<p>CVE-12345: insecure use of consumer grade operating system in multi-user role when expecting any form of real isolation<p>CVE-12346: faulty system administration techniques, including running anything as SYSTEM, can cause things to run with elevated privileges<p>CVE-12347: failure to secure root (C:) and important system directories can allow malicious actors to access them. This can be exploited to trick other parts of the system into doing ... things.<p>I don't mind patching git <i>for windows</i> to workaround these things, but sheesh, the root cause of both of these is people using Windows incorrectly/insecurely.
This feels really pointless. If I can create /.git, I have root already. Any other parent-directory-escalation that I can think of would be so obscure as to be not worth caring about, and would also probably require having access to an already-higher-privilege account.<p>And of course the unspoken: almost nobody uses git on multi user systems, and when they do, most of the time every single user already has sudo.
This certainly came as a surprise to my team today.<p>We operate some number of repositories and the majority of them use <a href="https://github.com/actions-ecosystem/action-get-latest-tag" rel="nofollow">https://github.com/actions-ecosystem/action-get-latest-tag</a> - or more specifically, a fork of that repo which more or less works the same way.<p>Midday today our CI/CD started failing. We must have hit this so soon because the `apk add git` in that Dockerfile grabbed the new git version. Evidently the SID that ultimately executed the git command inside the included actions' dockerfile was not the same as the one that owned `/github/workspace` on the runner.<p>We were able to patch around using the new `safe.directory` option, but I'm curious to see if there's more fallout since CI/CD environments in particular create this sort of shared repository.