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

Re: Git clone reads safe.directory differently?

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 30, 2024, 22:49 UTC
Message-ID
<xmqqv80m8pha.fsf@gitster.g>
In-Reply-To
<Zqlo-i8uCb1Yr4Jm@tapette.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> I think if we're using --no-local (that is, if we're using upload-pack
> instead of creating symlinks), then we should not complain about the
> repository ownership.  It's supposed to always be safe to clone or fetch
> from an untrusted repository, and we shouldn't complain about that.

The safety is promised by "git fetch" when you fetch from some other machine because the only thing you will be seeing from that untrusted source is a bytestream that is the packfile, plus the tips of their histories---nothing runs as yourself in this exchange other than what you control, i.e. "git fetch", locally defined hooks and filters defined by your configuration.. They cannot affect your configuration file and hooks that may name extra programs that may run as you while fetching or cloning.

When you are using "--no-local" on the same machine, I do not think there is any guarantee that "upload-pack" side is safe. And that is where the safe.directory thing needs to kick in.

Stepping into an untrusted repository and running git operations opens up the user the Git process runs as to attacks by the untrusted repository, i.e. you may invoke hooks on the upload-pack side, defined in the source repository that is controlled by others, and that is where the safe.directory thing kicks in. You need to declare that you trust that source repository.

Previous: brian m. carlsonNext: Junio C Hamano
Message 7 of 21 in “Git clone reads safe.directory differently?”
  1. W. Michael PetulloJul 27, 2024
  2. Jeff KingJul 27, 2024
  3. W. Michael PetulloJul 28, 2024
  4. Jeff KingJul 28, 2024
  5. W. Michael PetulloJul 30, 2024
  6. brian m. carlsonJul 30, 2024
  7. Junio C HamanoJul 30, 2024
  8. Junio C HamanoJul 30, 2024
  9. brian m. carlsonJul 30, 2024
  10. Jeff KingJul 31, 2024
  11. Junio C HamanoJul 31, 2024
  12. Junio C HamanoJul 31, 2024
  13. Jeff KingAug 1, 2024
  14. Junio C HamanoAug 1, 2024
  15. brian m. carlsonAug 1, 2024
  16. Junio C HamanoAug 1, 2024
  17. Jeff KingAug 5, 2024
  18. W. Michael PetulloAug 5, 2024
  19. Junio C HamanoAug 5, 2024
  20. Jeff KingAug 1, 2024
  21. Jeff KingJul 31, 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.