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

Re: [PATCH v2 2/2] setup: allow Git.pm to do unsafe repo checking

From
Jeff King <peff@peff.net>
Date
Oct 22, 2022, 20:55 UTC
Message-ID
<Y1RY38RULkqd9pBN@coredump.intra.peff.net>
In-Reply-To
<221022.86eduzeiek.gmgdl@evledraar.gmail.com>
On Sat, Oct 22, 2022 at 09:45:14PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 17 quoted lines
> The vulnerability safe.directory was supposed to address was one where
> you'd set your fsmonitor hook via a config variable, so running "diff",
> "status" etc. would unexpectedly execute arbitrary code.
> 
> Especially on Windows where apparently the equivalent of the root of a
> shared mounted volume routinely has global write permissions (user's
> subdirectories being less permissive).
> 
> An alternative I raised on the security list was to narrowly target just
> the fsmonitor config, since that was the vulnerability.
>
> [...]
>
> I'm unaware of any other variable(s) that provide a similar vector, and
> safe.directory is encouraging users (especially in core.sharedRepository
> settings) to mark a dir as "safe", and we'd then later have an exploit
> from a user with rw access who'd use the fsmonitor hook vector.
Here are a few off the top of my head that you can trigger via git-diff:
  - core.pager will run an arbitrary program
  - pager.diff will run an arbitrary program
  - diff.*.textconv runs an arbitrary program; you need matching
    .gitattributes, but those are under the control of the repository.
    (not diff.*.command, though, as you need to pass --ext-diff)
  - browser/man paths if you run "git diff --help"

And of course as you expand the set of commands there are more options. E.g., credential helper commands if you do anything that wants auth, interactive diff-filter for "add -p", hooks for git-commit, git-push, etc. Those commands are less likely to be run in an untrusted repository than inspection commands like "status" or "diff", but the boundary is getting quite fuzzy.

fsmonitor _might_ be the only one that is triggered by git-prompt.sh, because it has a limited command palette, generally reads (or sends to /dev/null) the stdout of commands (preventing pager invocation), and doesn't do text diffs (so no textconv). Even if true, I'm not sure if that's a good place to draw the line, though. People do tend to run "git log" themselves.

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 16 of 23 in “Git.pm: add semicolon after catch statement”
  1. 0/1 Git.pm: add semicolon after catch statementMichael McClimon, Oct 16, 2022
  2. 1/1 Git.pm: add semicolon after catch statementMichael McClimon, Oct 16, 2022
  3. Jeff KingOct 16, 2022
  4. Michael McClimonOct 17, 2022
  5. Jeff KingOct 17, 2022
  6. Michael McClimonOct 18, 2022
  7. Johannes SchindelinNov 10, 2022
  8. Jeff KingNov 10, 2022
  9. 0/2 Fix behavior of Git.pm in unsafe bare repositoriesMichael McClimon, Oct 22, 2022
  10. 1/2 Git.pm: add semicolon after catch statementMichael McClimon, Oct 22, 2022
  11. 2/2 setup: allow Git.pm to do unsafe repo checkingMichael McClimon, Oct 22, 2022
  12. Junio C HamanoOct 22, 2022
  13. Jeff KingOct 22, 2022
  14. Junio C HamanoOct 22, 2022
  15. Ævar Arnfjörð BjarmasonOct 22, 2022
  16. Jeff KingOct 22, 2022
  17. Ævar Arnfjörð BjarmasonOct 24, 2022
  18. Jeff KingOct 24, 2022
  19. Jeff KingOct 22, 2022
  20. Jeff KingOct 22, 2022
  21. Michael McClimonOct 22, 2022
  22. Jeff KingOct 24, 2022
  23. Junio C HamanoOct 22, 2022

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.