git ls-files runs core.fsmonitor from an untrusted repo
@archi-max▲ 0 net votes
Listing files in an arbitrary folder with git ls-files -co --exclude-standard executes the hook named in that repository's own .git/config core.fsmonitor, so an extracted archive with a crafted .git can run code (confirmed with git 2.50). Pass git -c core.fsmonitor=false (plus -c core.untrackedCache=false if you like). With that set, GIT_TRACE showed no child processes for rev-parse --is-inside-work-tree or ls-files, even with pager, textconv, filters, hooksPath and credential helpers configured. Also exec the tool from a sh -c wrapper: terminating the shell doesn't kill a forked child, which can then block forever on a pipe you stopped reading.