git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] Revert defense-in-depth patches breaking Git LFS

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 14, 2024, 19:07 UTC
Message-ID
<0f7597aa-6697-9a70-0405-3dcbb9649d68@gmx.de>
In-Reply-To
<20240514181641.150112-1-sandals@crustytoothpaste.net>
brian,
On Tue, 14 May 2024, brian m. carlson wrote:
Show 28 quoted lines
> The recent defense-in-depth patches to restrict hooks while cloning
> broke Git LFS because it installs necessary hooks when it is invoked by
> Git's smudge filter.  This means that currently, anyone with Git LFS
> installed who attempts to clone a repository with at least one LFS file
> will see a message like the following (fictitious example):
>
> ----
> $ 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 :/'
> ----
>
> This causes most CI systems to be broken in such a case, as well as a
> confusing message for the user.

When using `actions/checkout` in GitHub workflows, nothing is broken because `actions/checkout` uses a fetch + checkout (to allow for things like sparse checkout), which obviously lacks the clone protections because it is not a clone.

Show 5 quoted lines
> It's not really possible to avoid the need to install the hooks at this
> location because the post-checkout hook must be ready during the
> checkout that's part of the clone in order to properly adjust
> permissions on files.  Thus, we'll need to revert the changes to
> restrict hooks while cloning, which this series does.

Dropping protections is in general a bad idea. While previously, hackers wishing to exploit weaknesses in Git might have been unaware of the particular attack vector we want to prevent with these defense-in-depth measurements, we now must assume that they are fully aware. Reverting those protections can be seen as a very public invitation to search for ways to exploit the now re-introduced avenues to craft Remote Code Execution attacks.

I have pointed out several times that there are alternatives while discussing this under embargo, even sent them to the git-security list before the embargo was lifted, and have not received any reply. One proposal was to introduce a way to cross-check the SHA-256 of hooks that _were_ written during a clone operation against a list of known-good ones. Another alternative was to special-case Git LFS by matching the hooks' contents against a regular expression that matches Git LFS' current hooks'.

Both alternatives demonstrate that we are far from _needing_ to revert the changes that were designed to prevent future vulnerabilities from immediately becoming critical Remote Code Executions. It might be an easier way to address the Git LFS breakage, but "easy" does not equal "right".

I did not yet get around to sending these patches to the Git mailing list solely because I am still busy with a lot of follow-up work of the embargoed release. It was an unwelcome surprise to see this here patch series in my inbox and still no reply to the patches I had sent to the git-security list for comments.

I am still busy wrapping up follow-up work and won't be able to participate in this here mail thread meaningfully for the next hours. I do want to invite you to think about alternative ways to address the Git LFS issues, alternatives that do not re-open weaknesses we had hoped to address for good.

I do want to extend the invitation to work with me on that, for example by reviewing those patches I sent to the git-security mailing list (or even to send them to the Git mailing list for public review on my behalf, that would be helpful).

Ciao, Johannes

Previous: brian m. carlsonNext: brian m. carlson
Message 4 of 14 in “Revert defense-in-depth patches breaking Git LFS”
  1. 0/2 Revert defense-in-depth patches breaking Git LFSbrian m. carlson, May 14, 2024
  2. 2/2 Revert "core.hooksPath: add some protection while cloning"brian m. carlson, May 14, 2024
  3. 1/2 Revert "clone: prevent hooks from running during a clone"brian m. carlson, May 14, 2024
  4. Johannes SchindelinMay 14, 2024
  5. brian m. carlsonMay 14, 2024
  6. Joey HessMay 22, 2024
  7. Johannes SchindelinMay 27, 2024
  8. Joey HessMay 28, 2024
  9. Jeff KingMay 29, 2024
  10. Johannes SchindelinMay 29, 2024
  11. Junio C HamanoMay 29, 2024
  12. Jeff KingMay 30, 2024
  13. Joey HessMay 24, 2024
  14. Junio C HamanoMay 28, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.