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
Jeff King <peff@peff.net>
Date
May 18, 2024, 18:14 UTC
Message-ID
<20240518181432.GA1570600@coredump.intra.peff.net>
In-Reply-To
<b841db8392ebd924d1893829a7e5e22240f1e9cf.1716028366.git.gitgitgadget@gmail.com>
On Sat, May 18, 2024 at 10:32:43AM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 7 quoted lines
> To help Git LFS, and other tools behaving similarly (if there are any),
> let's add a new, multi-valued `safe.hook.sha256` config setting. Like
> the already-existing `safe.*` settings, it is ignored in
> repository-local configs, and it is interpreted as a list of SHA-256
> checksums of hooks' contents that are safe to execute during a clone
> operation. Future Git LFS versions will need to write those entries at
> the same time they install the `smudge`/`clean` filters.

This scheme seems more complicated for the user than the sometimes discussed ability to specify hook paths via config (not core.hooksPath, which covers _all_ hooks, but one which allows a per-hook path).

In either case, we're considering config to be a trusted source of truth, so I think the security properties are the same. But for the system here, a user updating a hook needs to do multiple steps:

  - compute the sha256 of the hook (for which we provide no tooling
    support, though hopefully it is obvious how to use other tools)
  - add the config for the sha256
  - install the new hook into $GIT_DIR/hooks

Whereas if the config can just point at the hook, then there is only one step: add the config for the hook (presumably pointing to a system version that would have been copied into $GIT_DIR/hooks previously).

Likewise for updates of the hooks, where the sha256 scheme requires computing and adding a new hash. But when the config just points to the path, there is no additional step for updating.

In either scheme, programs like git-lfs would have to adjust to the new world view. The main advantage of the sha256 scheme, it seems to me, is that the baked-in sha256 values let existing versions of git-lfs work. But we could also support that internally, without exposing safe.hook.sha256 to the world (and thus creating an ecosystem where we have to support it forever).

Implied here is that I also think config-based hooks have a lot of _other_ advantages, and so would be worth pursuing anyway, and this extra safety would come along for free. I won't enumerate those advantages here, but we that can be a separate discussion if need be.

And of course that feature doesn't yet exist, and is a much larger one. But besides un-breaking current LFS, I'm not sure that we need to rush out a more generic version of the feature.

-Peff
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 22 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.