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

Re: [PATCH v2 5/8] hook(clone protections): add escape hatch

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 20, 2024, 16:05 UTC
Message-ID
<5e0d660a-b1ee-2202-752c-d46d3b0c8a19@gmx.de>
In-Reply-To
<xmqqed9yob4v.fsf@gitster.g>
Hi,
On Sat, 18 May 2024, Junio C Hamano wrote:
> But considering that we are not talking about lifting vulnerability fix,
> it may make sense to do the (partial) revert all the way down to 2.39
> track but do the "fix in the next cycle" only for 2.45 and later (or
> even in 2.46 only, without even aiming to touch 2.45 track).

To ensure that I don't misunderstand you: You are talking about reverting 8db1e8743c0 (clone: prevent hooks from running during a clone, 2024-03-28), right?

It is _technically_ true that this is not a vulnerability fix. But only _technically_. Practically, it is preventing vulnerabilities from reaching the critical level.

Let's take the most recently-addressed critical vulnerability, CVE-2024-32002. I carefully crafted above-mentioned commit such that it would have prevent the Remote Code Execution attack vector noted in that CVE.

To put this into perspective: If this protection had been put in place before v2.39.4, the CVSS score of CVS-2024-32002 would not have been 9.1 (Critical), but instead 2.2 (Low).

In other words, even if a vulnerability was found, Git's users would have been safer with this defense-in-depth in place.

The same `post-checkout` hook attack vector likewise raised the severity of CVE-2021-21300, CVE-2019-1354, CVE-2019-1353, CVE-2019-1352, and CVE-2019-1349.

It also raised the severity of the vulnerability fixed in v1.8.5.6 (for which we did not obtain a CVE).

Based on past experience, we must expect the semi-steady trickle of Git vulnerabilities to continue, and having this defense-in-depth in place will invaluable in helping to keep the severity of those future vulnerabilities low.

Therefore reverting that commit would put Git's users at risk.

In combination with the fact that we have a path forward via the patches that are under discussion in this here mail thread, a path forward that avoids that risk and incurs an acceptable cost [*1*], the plan to revert 8db1e8743c0 instead should be questioned.

Ciao, Johannes

P.S.: A concern was raised about `safe.hook.sha256` not having tooling to generate those SHA-256 checksums, and putting a burden on 3rd-party tool developers.

However, tooling to generate SHA-256 checksums of files is ubiquitous, there is `sha256sum` and `openssl dgst -sha256`, just to name two tools that are widely available.

And it's not as if _Git users_ would have to generate those checksums. It would be a one-time cost for the developers whose tools install those hooks during a clone (Git offers no option to install hooks during cloning other than templates, which is not broken in v2.39.4, ..., v2.45.1).

Which brings me to that mysterious mention of tools other than Git LFS being potentially affected. It is quite dubitable that tools other than Git LFS use this method of changing the Git repository configuration in such a major way as to install hooks _while running a `smudge` filter_.

It must be put into doubt, too, that this method of abusing the `smudge` filter is the best design to address Git LFS' needs. A serious downside, for example, is that this Git LFS strategy is in conflict with user-provided `post-checkout` hooks that are copied via templates. A better design that comes immediately to mind would be to add a new, generic batched-smudge filter that Git LFS could use, and that would be configured in the system or user-wide config just like Git LFS' `smudge`/`clean` filters, without the need to play hacky games during a clone operation that are very similar to malicious attacks' strategies to abuse Git's hook feature to allow Remote Code Execution.

Previous: Junio C HamanoNext: Junio C Hamano
Message 31 of 54 in “Various fixes for v2.45.1 and friends”
  1. 0/8 Various fixes for v2.45.1 and friendsJohannes Schindelin via GitGitGadget, May 17, 2024
  2. 1/8 hook: plug a new memory leakJohannes Schindelin via GitGitGadget, May 17, 2024
  3. 2/8 init: use the correct path of the templates directory againJohannes Schindelin via GitGitGadget, May 17, 2024
  4. 3/8 Revert "core.hooksPath: add some protection while cloning"Johannes Schindelin via GitGitGadget, May 17, 2024
  5. 4/8 tests: verify that `clone -c core.hooksPath=/dev/null` works againJohannes Schindelin via GitGitGadget, May 17, 2024
  6. Junio C HamanoMay 18, 2024
  7. Johannes SchindelinMay 18, 2024
  8. 5/8 hook(clone protections): add escape hatchJohannes Schindelin via GitGitGadget, May 17, 2024
  9. Junio C HamanoMay 18, 2024
  10. 6/8 hooks(clone protections): special-case current Git LFS hooksJohannes Schindelin via GitGitGadget, May 17, 2024
  11. Junio C HamanoMay 18, 2024
  12. 7/8 hooks(clone protections): simplify templates hooks validationJohannes Schindelin via GitGitGadget, May 17, 2024
  13. 8/8 Revert "Add a helper function to compare file contents"Johannes Schindelin via GitGitGadget, May 17, 2024
  14. Junio C HamanoMay 17, 2024
  15. Johannes SchindelinMay 18, 2024
  16. 0/8 Various fixes for v2.45.1 and friendsJohannes Schindelin via GitGitGadget, May 18, 2024
  17. 1/8 hook: plug a new memory leakJohannes Schindelin via GitGitGadget, May 18, 2024
  18. 2/8 init: use the correct path of the templates directory againJohannes Schindelin via GitGitGadget, May 18, 2024
  19. 3/8 Revert "core.hooksPath: add some protection while cloning"Johannes Schindelin via GitGitGadget, May 18, 2024
  20. 4/8 tests: verify that `clone -c core.hooksPath=/dev/null` works againJohannes Schindelin via GitGitGadget, May 18, 2024
  21. 5/8 hook(clone protections): add escape hatchJohannes Schindelin via GitGitGadget, May 18, 2024
  22. Jeff KingMay 18, 2024
  23. Junio C HamanoMay 18, 2024
  24. Jeff KingMay 18, 2024
  25. Johannes SchindelinMay 18, 2024
  26. Johannes SchindelinMay 18, 2024
  27. Jeff KingMay 18, 2024
  28. Johannes SchindelinMay 18, 2024
  29. Jeff KingMay 18, 2024
  30. Junio C HamanoMay 19, 2024
  31. Johannes SchindelinMay 20, 2024
  32. Junio C HamanoMay 20, 2024
  33. Johannes SchindelinMay 20, 2024
  34. Junio C HamanoMay 20, 2024
  35. Johannes SchindelinMay 20, 2024
  36. 6/8 hooks(clone protections): special-case current Git LFS hooksJohannes Schindelin via GitGitGadget, May 18, 2024
  37. 7/8 hooks(clone protections): simplify templates hooks validationJohannes Schindelin via GitGitGadget, May 18, 2024
  38. 8/8 Revert "Add a helper function to compare file contents"Johannes Schindelin via GitGitGadget, May 18, 2024
  39. Junio C HamanoMay 18, 2024
  40. Johannes SchindelinMay 18, 2024
  41. Johannes SchindelinMay 18, 2024
  42. 0/6 Various fixes for v2.45.1 and friendsJohannes Schindelin via GitGitGadget, May 20, 2024
  43. 1/6 hook: plug a new memory leakJohannes Schindelin via GitGitGadget, May 20, 2024
  44. 2/6 init: use the correct path of the templates directory againJohannes Schindelin via GitGitGadget, May 20, 2024
  45. 3/6 Revert "core.hooksPath: add some protection while cloning"Johannes Schindelin via GitGitGadget, May 20, 2024
  46. 4/6 tests: verify that `clone -c core.hooksPath=/dev/null` works againJohannes Schindelin via GitGitGadget, May 20, 2024
  47. 5/6 clone: drop the protections where hooks aren't runJohannes Schindelin via GitGitGadget, May 20, 2024
  48. 6/6 Revert "Add a helper function to compare file contents"Johannes Schindelin via GitGitGadget, May 20, 2024
  49. Junio C HamanoMay 20, 2024
  50. Junio C HamanoMay 21, 2024
  51. Junio C HamanoMay 21, 2024
  52. brian m. carlsonMay 21, 2024
  53. Junio C HamanoMay 21, 2024
  54. Junio C HamanoMay 21, 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.