13 ms·
Git: Malicious repositories can execute remote code while cloning
- jolmg 6y ago> This vulnerability affects platforms with case-insensitive filesystems... What kind of platforms use case-insensitive filesystems?
- Operyl 6y agomacOS, to name one. It appears NTFS is also vulnerable according to the posting.
- pcthrowaway 6y agoAshamed to admit (as an OSX user) that I didn't even realize the FS was case-insensitive (having migrated from years of Linux usage to a non-Linux desktop). It does a good job of hiding this from the user (filenames are still listed with cases, and bash autocompletion completes to the correct case as well)
- caymanjim 6y agoMacOS by default uses a "case-preserving case-insensitive" filesystem, so you can create files with mixed case, but you can't create two files with the same name and different case. It's one of MacOS's more-egregious crimes against Unix. Fortunately it doesn't manifest that often, but it rears its head often enough to be a problem.
- deleted 6y ago[deleted]
- leephillips 6y agoIt may be a crime, but is the result of a set of compromises in the design of the OSX filesystem, which had to work with a BSD variant while also being compatible with pre-OSX days. I think it’s one thing they actually did an elegant job with. EDIT: This document describes some of the challenges: https://www.usenix.org/legacy/publications/library/proceedings/usenix2000/invitedtalks/sanchez_html/sanchez.html https://www.usenix.org/legacy/publications/library/proceedin...
- EamonnMR 6y agoThis is the first article I've found that does a decent job of explaining what a resource fork really is.
- _jal 6y ago> It's one of MacOS's more-egregious crimes against Unix. Nah. Using a file system means putting up with its semantics. HFS+ was case-insensitive; they were deploying an upgrade to millions of existing filesystems. If you mount, say, an NFS volume, MacOS does the expected thing.
- ComputerGuru 6y agoThat’s the same as Windows, but Windows enables making directories case sensitive on a directory by directory basis.
- Ancapistani 6y ago> Fortunately it doesn't manifest that often, but it rears its head often enough to be a problem. IIRC, one place where it does rear its head in when a file is renamed in a git commit to a value that downcases to the same value as the prior name. For example `Foo.txt`->`foo.txt`. I have `core.ignorecase = true` in my `.gitconfig` for this very reason.
- geofft 6y agoThe extraordinarily frustrating case is where you're working on a repository that has multiple files that differ only by case. Git will check out one of them, then overwrite it with the other. The Linux kernel is one of them: several of the headers that get installed to /usr/include/linux/netfilter have conflicts on a case-insensitive filesystem. https://github.com/torvalds/linux/tree/master/include/uapi/linux/netfilter https://github.com/torvalds/linux/tree/master/include/uapi/l... Debhelper used to be one of those until I convinced them to change it: they had a Debian/ directory for the Perl module Debian::Debhelper as well as a debian/ directory for the packaging metadata. https://bugs.debian.org/873043 https://bugs.debian.org/873043 (I suspect I'm a little unusual in wanting to have checkouts of Linux and Debhelper on my Mac homedir.)
- dreamcompiler 6y agoThe fact that Linux is case-sensitive is the egregious crime. It's a nasty holdover from circa-1970 Unix when case-folding was an expensive operation.
- akersten 6y agoCase-senitivity is not a "nasty holdover", it is a good design decision that continues to be proven correct (case in point, this bugfix for case-insensitive filesystems). Why would you introduce complexity into the filesystem to try to normalize file names when you can simply, not? I mean, have you _seen_ the mess that is Unicode normalization? Hundreds of different glyphs or whatever that are all considered equivalent, but are actually composed of different bytes. The filesystem should try to make sense of all that, and consider them equivalent paths? Even if you say "well, just capitalization, not Unicode normalization," there's the whole German letter ẞ => ss (or is it ß?) and similar friends like the Turkish dotted I that have popped up as articles on HN. Absolutely glad Linux filesystems by and large do not attempt to take that on, and treat paths as a bucket of bytes instead. All for what benefit - so you can type File.txt in the terminal and have the OS find file.txt? That is much more appropriate for the Application layer to resolve, rather than the filesystem. Bugs like this come from over-engineering. Filesystems should be simple, and follow the principle of least surprise.
- dreamcompiler 6y agoIt bugs me to see foo.c and Foo.c as separate files in a directory listing. I like the fact that MacOS doesn't allow this situation to ever happen. Not taking on that problem means it's left to the user to figure out what's going on when similar glyphs occur.
- shp0ngle 6y agowasn't this fixed with their new Apple FS? Wait I'll try ...nope, after `touch makefile` and `touch Makefile`, I still see just `makefile`. OK
- deleted 6y ago[deleted]
- oars 6y agoI'm in the same boat - used MacOS for the past 6 years, including the terminal nearly everyday! :d
- Cloudef 6y agoOSX has even more annoying problem that it decomposes unicode: https://stackoverflow.com/questions/5581857/git-and-the-umlaut-problem-on-mac-os-x https://stackoverflow.com/questions/5581857/git-and-the-umla... Many fun times trying to copy/move/remove a file and not being able to do so because the input and name stored on fs is actually different bytewise... Seems like linux has the only sane filesystems not trying to mangle paths at all.
- jrochkind1 6y agoIf linux doesn't normalize unicode at all, can you have two different files that look like they are named `josé`, depending on if the é is decomposed or not?
- chungy 6y agoIf you use a file system that doesn't normalize lookups, yes you can.
- Cloudef 6y agoYes, for linux filenames are just bytes. Apart from / and NUL characters it doesnt care what you give it, nor does it mangle them anyway, its the only sane thing to do.
- Someone 6y agoThe only sane thing to do if you don’t care about how humans (as opposed to nerds) think. In the end, the file system doesn’t exist in isolation, it is there to support users, and most of them won’t care how many bytes “é” takes to store. Unix, by not even defining the way to interpret the bytes of file names (one can’t even assume that names consisting of only bytes that correspond to ASCII letters and digits should be interpreted as ASCII) makes it impossible to show file names to users. That’s insane.
- jolmg 6y ago> The only sane thing to do if you don’t care about how humans (as opposed to nerds) think. At the FS layer, I think that's better. Makes things simpler for programs. For non-techie humans, unicode can be normalized at upper levels, like the GUI file manager or toolkit library that does save dialogs, etc. That's if humans being confused because of lack of normalization of unicode is a real practical issue and not just something that can happen but never does.
- jnwatson 6y agoFYI, on MacOS, it is a property of the partition, so you can reformat and have a case-sensitive filesystem. Applications may subtly break if they weren't tested on such a filesystem, but I had used one for several years without too many issues.
- jamesog 6y agoSince the introduction of APFS I've taken to creating a new APFS volume formatted as case-sensitive, and put my git repositories there. This has mostly been useful for working on shared repositories where, say, a Linux user (or other user on a case-sensitive filesystem) pushes two branches, say `feature/foo` and `feature/Foo` which works fine for them, but on a case-insensitive filesystem, git gets very upset.
- jameshart 6y agoOnce spent way longer than I would have liked trying to debug an iOS app issue that couldn’t reproduce and debug in the emulator because iOS devices have a case-sensitive FS, macOS devices typically don’t, and the emulator was subject to the macOS file system’s conventions. Leaky abstractions all the way down.
- deleted 6y ago[deleted]
- rhinoceraptor 6y agoMacOS and Windows
- jolmg 6y agoI guess it shows that I haven't really used either of those in a long time.
- Jtsummers 6y agomacOS has defaulted to be case insensitive largely due to historical and perhaps usability reasons. You can opt to make it case sensitive (and I do, which broke Steam for several years but that also freed my time).
- emodendroket 6y agoWhen necessary you can make an auto-expanding volume that's case-sensitive and leave your host FS alone. I have not found that I really want to have differently-cased but otherwise identical filenames in the real world at any point though.
- dhosek 6y agoAges ago, I heard from co-workers at a company that I had left that there was an issue because of some file-naming in a PHP application that they were trying to run locally on a Mac. There was foo.php which was the interface and Foo.php which had a class definition in it. What idiot would name files like that? I said. You, they answered. I don't do that sort of thing anymore.
- earthboundkid 6y agoA bug that affects my teams once every few years is a developer will create a file named "A.txt" check it into Git, realize it should be "a.txt" and rename it, and then basically everything will shit the bed and you waste a day figuring out why nothing is working. A related bug is a developer will make a webpage called /a/ but link to /A/ and then the link will be broken in production. At this point, I have seen this same bug enough times to be able to fix it reasonably quickly, but it definitely wastes time for the team.
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- zo1 6y agoWindows. Its a notable problem with git + Windows that has gotten better over time but still leads to a lot of WTF moments. For many this event is the first time they hear that window's filesystem is case insensitive.
- rightbyte 6y agoIt is strange I haven't noticed earlier. Maybe it is just so unnatural to name files the same with different cases that I haven't tried.
- swiley 6y agoSometimes it feels like corporate IT creates more security problems than it solves: windows as development machines, solar winds, Fucking McAffee malware on everything.
- Foxboron 6y agoLinux these days actually. You can make ext4 case insesitive. https://www.collabora.com/news-and-blog/blog/2020/08/27/using-the-linux-kernel-case-insensitive-feature-in-ext4/ https://www.collabora.com/news-and-blog/blog/2020/08/27/usin... Note: I also learned this today. Had no clue.
- suifbwish 6y agoWhy the heck would anyone want that? That’s arguably worse than adding spaces in file names
- chungy 6y agoZFS has a case-insensitive option.
- floatingatoll 6y ago> if Git is configured globally to apply delay-capable clean/smudge filters (such as Git LFS) What is the simple test for whether this is the case or not? Is this a default-on scenario?
- goatinaboat 6y agoIs this a default-on scenario? No, LFS is something you would have to explicitly enable, however it is pretty common to do so if you want to store binary blobs in Git.
- ExtraE 6y agoGit for windows has LFS on by default.
- matheust 6y ago> What is the simple test for whether this is the case or not? As suggested in GitHub's announcement post[1], you can test this with the following: `git config --show-scope --get-regexp 'filter\..*\.process'` (replace the single quotes by double quotes on Windows Command Prompt) > Is this a default-on scenario? On Windows yes, because Git-for-Windows configures Git LFS by default. [1]: https://github.blog/2021-03-09-git-clone-vulnerability-announced https://github.blog/2021-03-09-git-clone-vulnerability-annou...
- dragonwriter 6y agoDoesn't Git-for-Windows default configure symbolic link support off, though? Or does this exploit work even in that case as long as the underlying file system supports symlinks?
- matheust 6y agoGit-for-Windows may turn symlink support on by default under some specific circumstances. As the repo's wiki [1] says: Short version: there is no exact equivalent for POSIX symlinks on Windows, and the closest thing is unavailable for non-admins by default unless Developer Mode is enabled and a relatively recent Windows 10 version is used. Therefore, symlink emulation support is only turned on by default when that scenario is detected. [1]: https://github.com/git-for-windows/git/wiki/Symbolic-Links https://github.com/git-for-windows/git/wiki/Symbolic-Links
- amelius 6y agoThis should be fixed especially for those who want to inspect the code in a repository before running it. But anyone should keep in mind that malicious repositories can do a lot of bad things after cloning, even without this bug.
- marcosdumay 6y agoIf you can't clone and then verify the code, a lot of things get much harder.
- stefan_ 6y agoThe commit that fixes this issue: https://github.com/gitster/git/commit/684dd4c2b414bcf648505e74498a608f28de4592 https://github.com/gitster/git/commit/684dd4c2b414bcf648505e... (Surprise, the root cause is a cache)
- softwaredoug 6y agoAnother cachelty
- medicineman 6y agoHe who would pun would pick a pocket.
- AbraKdabra 6y agoOh man...
- sethammons 6y agowell played. I think that just got added to my standard vocabulary. Caching has caused more errors and bugs that I've had to deal with than I can recall. My favorite was an off by one error where we returned nicely cached info -- just for the previous user who came through our system! :facepalm: That was a bad one.
- taf2 6y agoYeah but the speed.
- saganus 6y agoHere goes the obligatory > There are only two hard things in Computer Science...
- jholman 6y agoI can never remember what they are, though. To avoid this problem, I think I wrote them down on a post-it, but I had too many post-its on my desk so I got rid of them all, and now I can't remember.
- jfrunyon 6y agoGit: Malicious repositories can execute remote code while cloning on a case-insensitive filesystem with symlinks FTFY
- deleted 6y ago[deleted]
- vesinisa 6y agoReminds me of another git vulnerability from 2014 on case-insensitive filesystems: https://github.blog/2014-12-18-vulnerability-announced-update-your-git-clients/ https://github.blog/2014-12-18-vulnerability-announced-updat...
- caslon 6y ago> This vulnerability affects platforms with case-insensitive filesystems with support for symbolic links, when certain clean/smudge filters are configured globally (e.g. Git LFS). Can we get the title changed to "on macOS and Windows?" I was worried for a second, but this is meaningless.
- jonas21 6y agoWhy is it meaningless? Lots of people use Git on MacOS and Windows. I'd even be willing to bet that there are more people using Git on MacOS and Windows than Linux.
- SilverRed 6y agoAnd use git LFS and cloned a malicious repo? This bug has probably not affected a single user.
- jonas21 6y agoIsn't the whole point of announcing security patches so that people can update before they're exploited?
- SilverRed 6y agoSure, I'm just saying this isn't a big deal and its likely no one was hit.
- aiisjustanif 6y agoJust because there is not an active threat doesn’t make it any less of a vulnerability to be exploited.
- lucb1e 6y agoIt does if nobody uses it. You can't exploit Apache 2.4.2 proxy bugs if nobody runs Apache 2.4.2 in proxy mode. Of course, you should still update because you're a config change away from being vulnerable, but GP's point of it not being a big deal if (and only if, don't know if that's correct) nobody uses it stands.
- mateo411 6y agoI guess I'll have to stop running $ sudo git clone ...
- jrockway 6y agoI don't think that smugly not running as root saves normal users; while malware running as your user can't trash your laptop, they can get your Google cookie and read and send emails as you, spend your money, view your private photos, etc.
- fulafel 6y agoAnd it can run sudo as your user after you warm it up. Or use any number of frequently disclosed OS vulnerabilities for local privilege escalation.
- Wowfunhappy 6y ago> And it can run sudo as your user after you warm it up. How is it getting my root password?
- edgyquant 6y agoI set sudo to NOPASSWD, so it doesn’t need one for my workstation
- thelopa 6y agoSudo persists authorization for a short period of time so that you don’t need to re-authorize for back-to-back commands. Also, once they get ACE they can modify your bashrc to make sudo an alias for “sudo rm -rf / ;” or all sorts of other evil trickery.
- VMG 6y agoit could also alias sudo to some other command
- 6y ago
- toomim 6y agoWhat's an easy way to fix the default git installation on OSX?
- jhugo 6y agoWait for a macOS security update that includes it. If you don’t want to wait, macports and homebrew will both be patched much faster.
- jonahx 6y agobrew install git
- mdasen 6y agoI did a `brew install git` and then deleted /Library/Developer/CommandLineTools/usr/bin/git. You can't delete /usr/bin/git even with sudo (system integrity policy). After installing git via brew and removing the one in CommandLineTools, /usr/bin/git is showing the latest version. me@local % git --version git version 2.30.2 I don't know if this is recommended or if it will have negative consequences that i don't know about, but it seemed like the way I could accomplish it. Given that /usr/bin/git is working with the homebrew installed git, I'm hopeful that everything will be good.
- Zambyte 6y agoI don't use Mac, so I can't speak yo how the changes you made will affect your system. For future reference however, you should know that binaries are searched on your $PATH in order. Instead of deleting anything, you could have edited your $PATH variable so that the directory that brew stores binaries in is searched before other locations.
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- kazinator 6y agoThat could be any Git repository. Have you seen the mayhem that some of mine cause when you clone them and then type ./configure && make, like you have been socially engineered into doing?
- pontifier 6y agoIt doesn't even have to be there... The main reasons to clone a repo are because you're about to compile and run the code there, or you already have and need to fix something. I don't personally audit all the code I run, but I hope someone is doing it. That being said, source code being public is much better than the alternative of just downloading binaries from who knows where. I don't trust anything absolutely, and I don't see a way past it.
- minitech 6y agoThere is a huge difference between “clone a repo” and “clone a repo and run code from it”.
- jtsiskin 6y agoTechnically yes, but I can’t think of the last time I cloned a repo without then running code from it...
- minitech 6y agoWell, I clone repos to inspect code all the time, and when I run code, it’s usually not with the same permissions as the corresponding `git clone`. Maybe I should be better about sandboxing Git…
- friendzis 6y agoDepends on how you define "running code". 1. Download container description (Dockerfile) 2. Upon image build it "compiles things" (e.g. processes/assembles javascript) 3. Build fails, because it pulls architecture incompatible library (or does not pull architecture mandated library) 4. Fix build scripts, rebuild container image 5. Verify container 6. Pull repo 7. Reproduce changes, commit 8. Push Nothing apart clone-edit-push happens on the repo. The code can be executed on a remote, hardened, isolated system. With proliferation of containers I guess this scenario will become more and more common among ops people.
- fortran77 6y agoIsn't the bug really on case-insensitive file-systems that allow symlinks?
- jesboat 6y agoNo. Why would it be?
- akdor1154 6y agoTangential.. are there bug bounties available for vulns in open source projects?
- SuchAnonMuchWow 6y agoA lot of open source project owned by large corporations do. More independent projects sometimes does it to, for example curl.
- jordanmorgan10 6y agoIs nothing sacred anymore
- mbar84 6y agoConsidering how much I `pip install garbage`, this is perhaps not so critical for me.