Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent Git security releases break git clone on repositories using LFS #5749

Closed
bk2204 opened this issue May 14, 2024 · 3 comments
Closed

Recent Git security releases break git clone on repositories using LFS #5749

bk2204 opened this issue May 14, 2024 · 3 comments
Labels

Comments

@bk2204
Copy link
Member

bk2204 commented May 14, 2024

Git has recently released several security releases that introduce a regression when using git clone on a repository with Git LFS. When cloning, a message like the following occurs, and LFS files are not checked out:

$ git clone https://github.com/octocat/xyzzy.git
Cloning into 'pull-bug'...
remote: Enumerating objects: 1275, done.
remote: Counting objects: 100% (343/343), done.
remote: Compressing objects: 100% (136/136), done.
remote: Total 1275 (delta 221), reused 327 (delta 206), pack-reused 932
Receiving objects: 100% (1275/1275), 290.78 KiB | 2.88 MiB/s, done.
Resolving deltas: 100% (226/226), done.
Filtering content: 100% (504/504), 1.86 KiB | 0 bytes/s, done.
fatal: active `post-checkout` hook found during `git clone`:
        /home/octocat/xyzzy/.git/hooks/post-checkout
For security reasons, this is disallowed by default.
If this is intentional and the hook should actually be run, please
run the command again with `GIT_CLONE_PROTECTION_ACTIVE=false`
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Note that this message and the nonzero exit status also affect users using GIT_LFS_SKIP_SMUDGE=1, such as many CI systems, so this can't be used as a workaround. Users can set the environment variable GIT_CLONE_PROTECTION_ACTIVE=false globally, which will disable this check, or if the repository has already been cloned, users can use git lfs pull to fix the repository and the hooks. (Note that setting the GIT_CLONE_PROTECTION_ACTIVE=false environment variable disables the defense-in-depth measure outlined below.)

Ultimately, this is a regression in Git that was introduced as a defense-in-depth measure. The problem is in Git and cannot be worked around in Git LFS itself without a substantial loss of functionality. The Git developers are aware of the problem and discussion about how to solve it is underway or will be underway shortly on the mailing list. If you're interested, you can follow the discussion there or post yourself (please note that only plain text mail is allowed; no HTML parts can be sent at all).

We realize this has a big impact and we're working with the Git developers to get it fixed as quickly as possible. In the mean time, distributors and users can revert the following non-essential patches, which will solve the problem:

  • clone: prevent hooks from running during a clone
  • core.hooksPath: add some protection while cloning

Since this is a Git bug and not a Git LFS bug, most discussion about this issue should take place on the Git list, and not on the Git LFS GitHub page. Please refrain from opening issues on this matter on the Git LFS issue tracker. If there is productive discussion about topics that aren't suitable for the Git list (e.g., workarounds), please discuss those in the Git LFS discussions.

We'd also like to encourage people to participate in the respective communities in a positive way and in conjunction with the Git LFS Code of Conduct and the Git Code of Conduct.

@bk2204 bk2204 pinned this issue May 14, 2024
@git-lfs git-lfs locked and limited conversation to collaborators May 14, 2024
@bk2204
Copy link
Member Author

bk2204 commented May 14, 2024

The reverted patches have been sent to the Git list.

@bk2204
Copy link
Member Author

bk2204 commented May 22, 2024

A new series which will soon be merged to the Git maintenance branches has been proposed, which should address this issue and will be included in a 2.45.2 and various other versions.

@bk2204
Copy link
Member Author

bk2204 commented Jun 3, 2024

Git 2.45.2 has been released, which should fix Git LFS.

@bk2204 bk2204 closed this as completed Jun 3, 2024
@bk2204 bk2204 unpinned this issue Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant