lobsters score: 4 · tags: security, vcs
I immediately alerted Dropbox and Vercel’s security teams so they can hopefully take these accounts down before they snag someone. Sadly, they also were impersonating an unspecting development shop owner as part of the ruse.
Is there a reason not to involve law enforcement in this case? Seems like the author could have been significantly harmed if they weren’t already aware of this attack vector.
score 1 · canonical
Had something similar, though maybe less sneaky, happen to me. Wrote about it here: https://kraa.io/recruiter-scam
score 1 · canonical
I feel like Git would benefit from a mechanism similar to direnv where you need to run an “allow” command first before hooks will execute.
score 1 · canonical
Neither of which should be committed by users (examples are fine) so developers are free to set up or modify it to their content. One of my biggest peeves is being forced into someone else’s hooks or direnv setup which takes away my autonomy but can also leak into security. I write my own VCS hooks, but those are for me.
score 1 · canonical
It’s not possible to commit Git hooks into the repository. A helper script can generate these, but you’d need to run it first. Hooks are already purely local to a specific clone.
score 2 · canonical
In theory, but I have seen so many folks commit something like Husky or pre-commit hooks & demand you set these up.
score 1 · canonical
Can these hooks be secured? It looks like post-checkout could be on any repo hosted anywhere.
score 1 · canonical
This could be even worse. I assume git does a checkout after cloning a repository, this hook could be triggered right after a clone without your ability to review it.
Edit: I tried, and git refuses to checkout the file initially :
$ git clone bad-repo.got Cloning into 'bad-repo'... done. error: invalid path '.git/hooks/post-checkout' fatal: unable to checkout working tree warning: Clone succeeded, but checkout failed. You can inspect what was checked out with 'git status' and retry with 'git restore --source=HEAD :/'So I assume that you’re safe as long as you ALWAYS clone repositories with
git, and don’t retrieve the work tree from someone else (like the author was asked to).Nothing within git (the repository format) prevents you from commiting a hook though, so it’s up to the frontend to secure against it.
I also tried with
got, and it refuses to checkout the file as well. No idea aboutjjor other git frontends.
score 2 · canonical
It’s difficult for the format to do anything about this. You’d need to come up with a way of encoding a path which had no representation for paths starting with
.git/.This attack path has been known about for a long time. And git has refused to check out files at paths starting with
./gitfor as long as I remember.There was a bug on windows years ago due to its case insensitive FS.
Generally treat any .git directory that git itself has not created as a live grenade.
score 1 · canonical
This is the price for having one universal tool and for having a monoculture based on it. Separation of concerns (earlier Unix) is still a sound engineering principle. Competition also helps. Without someone stealing their user base, Git will never touch such issues, for the sake of maintaining compatibility.
It might be that it was not the developers who turned their backs at Mercurial, Fossil and others, but the Hubs and the Labs. Maybe JJ shows us a way out of this situation.
score 1 · canonical
I’ve been kicking it primarily with Darcs (still holding out for Pijul tooling). I have been trying to build tooling to help VCS polyculture too which usually ends up being one of the primary reasons folks stick with Git.
score 1 · canonical
They then shared a Dropbox folder that had several folders of Markdown files.
This should have been the red flag. Not the .git directory or hooks in it.
score 1 · canonical
Why is that a red flag? If you are a contractor, getting a project layout/requirements like that seems reasonable
score 1 · canonical
Welp I blame reading it… I dunno, without coffee. Maybe too much coffee?
I knew it was a git clone in a dropbox folder, and somehow my brain read that line (even when I quoted it in my comment) as “a folder that had several folders of Make files”, and immediately I had visions of crazy people who know what Make is, but also put those Make files in Dropbox.
As the great man said, egg and my face, are in alignment.
score 1 · canonical
An even more devious attack is to ship a
.git/configfile with thecore.fsmonitoroption set to a malicious command. This command gets executed by many different git operations, including very basic ones likegit status.This is rather nasty because several other programs like to implicitly run
git status, including IDEs,go build, and fancy shell prompt integrations that e.g. show the current branch. I disabled all of my git shell integrations and setGOFLAGS=-buildvcs=falseafter I learned aboutcore.fsmonitor.Note that git itself refuses to check out a
.gitdirectory from a remote repo so runninggit clone,git pull, etc. can never install a malicious config or hook, but if you install directory trees from any other source, like a tarball, a different VCS, or Dropbox (as in this article), you have to watch out for.gitdirectories.
score 1 · canonical
Damn! I wouldn’t have expected it to be so dangerous to clone a repository and perform basic operations on it. I really thought that this type of flow would have been safe.
score 1 · canonical
As I said in my comment, cloning a repo cannot install malicious config. It’s the other ways of installing directory trees that you have to be wary of.
score 1 · canonical
Running operations in a subdirectory can still own you unless you turn on an option that’s off by default. Specifically:
git clone ssh://git@host.example/helloworld.git cd helloworld git status # <-- Safe cd malicious_subdirectory git status # <-- Dangerous
score 1 · canonical
Ahhhh I see the distinction. If you clone it you’re fine, but if you e.g, download it from Dropbox, you get RCE. Tricky!
score 1 · canonical
This is not the first attack I read about on here that involves git hooks. IMO the implementation is kind of insane and lends itself very well to this kind of attack. git basically treats the local
.gitdirectory as trusted probably because it believes that git repositories can only come from aclone(orinit) operation, which has additional checks for hooks, but as we see here that is not always the case!I don’t like git hooks in general but I think a better trust model would look similar to direnv’s.
.envrcfiles must be explicitly allowed for them to run, and the hashes of the file and path of allowed.envrcfiles are stored in an allowlist in.local/share/direnv, which is (generally) outside of the bounds of any repo. It’s not perfect: if the.envrcfile containsuse flakeyou won’t get another prompt when theflake.nixfile changes, but I think it’d be a reasonable improvement.
score 1 · canonical
There is a feature on direnv main for this, marking files as changes require reallow. But they haven’t cut a new release since it was merged.
score 1 · canonical
I hate the entire existence of hooks for other reasons so this seems like a good push for me to configure git to never run them anywhere ever.
score 1 · canonical
Since I never use Git hooks, I have completely disabled them with:
git config --global core.hooksPath /dev/null
score 2 · canonical
I like the idea; but it looks like a malicious repo can reenable hooks in its config file:
[core] hooksPath = .git/hooksSo I guess this global deactivation switch probably won’t help against malicious repos?
score 1 · canonical
True. Mitigating this problem:
core.hooksPathis not inherited from cloned repos.An extremely cautionary move would be to never copy repos, always preferring cloning them.
score 1 · canonical
Cloning a repo is in fact the only safe way to get a repo from an untrusted source. Specifically, the Git project considers it a vulnerability if cloning a repo pwns you; they do not consider it a vulnerability if installing a repo a different way pwns you.
score 1 · canonical
deleted by creator

