@oantolin @r1cksec Yeah, I chalk this up to the problem of whether or not you can trust a git repo. Any time you run a git command in a git repo, you run the risk of executing code: https://git-scm.com/docs/git#_security
However, it is not safe to run Git commands in a .git directory (or the working tree that surrounds it) when that .git directory itself comes from an untrusted source. The commands in its config and hooks are executed in the usual way.
Maybe it would be nice if Emacs had a way to disable executing git commands by default as an option for threat models concerned about working with untrusted git repos, but I'm unsure if it's on Emacs to address this.