mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
devvm ran git on the host bare: --clone's git status could run a repo's core.fsmonitor or filters, its push, fetch, update-ref and remote remove the repo's hooks, and git could ask on devvm's terminal or follow GIT_DIR from devvm's environment. internal/hostgit is now the one runner (Command, Output, Status), with its settings as GIT_CONFIG_COUNT pairs: core.fsmonitor=false, core.hooksPath=/dev/null, core.alternateRefsCommand=true, hook.EVENT.enabled=false for every githooks(5) event, protocol.allow=never with protocol.ssh.allow=always; and, for a command with -C DIR, hook.NAME.enabled=false and filter.NAME's clean/smudge/process emptied with required=false for each hook and filter driver DIR's config names. It drops every GIT_* variable and relative PATH folders, and sets GIT_TERMINAL_PROMPT=0, GIT_NO_LAZY_FETCH=1 (a repo that says it's a partial clone fetches nothing, with its core.sshCommand or ssh), GIT_SSH_COMMAND=false (no ssh but gitSSH's) and GIT_SSH_VARIANT=ssh; maintenance.auto=false and gc.auto=0. Status adds --no-optional-locks and --ignore-submodules=all. Callers: gitprotect (git, ignoreSubmodules), project.SSHRemote, vm/sync's gitConfig, vm/clone (hostGit, gitSSH, saveFetched, the uncommitted-changes status). gitSSH takes the VM: ssh with BatchMode, StrictHostKeyChecking, devvm's known hosts only, HostKeyAlias=VM, ForwardAgent=no and ClearAllForwardings=yes, so a url.*.insteadOf reaches only the VM with its pinned key. The seed push adds --no-verify, --no-recurse-submodules and --no-signed; rm's fetch --no-recurse-submodules. Not neutralized: an include.path can make gitConfig read user.name/email from another git-config file (sent to the VM as its identity), and a FIFO as a config file hangs git until Ctrl+C; neither runs code. A VM swapping the repo's config between repoOff's listing and the command could hide a filter from it, and a --clone VM's root (its host key) working with another VM that writes the repo could send the push to a server of theirs; both documented in internals/git-protection. Tests, each with plain git first running what the hardened one doesn't: hostgit's TestCommandNoFsmonitor, TestCommandNoHooks (reference- transaction, pre-push, from .git/hooks and a core.hooksPath; path, file:// and ext:: pushes refused), TestCommandNoConfigHooks (hook.NAME.*), TestCommandIgnoresGitEnv (GIT_DIR, GIT_WORK_TREE; environ), TestCommandNoLazyFetch (a partial clone's core.sshCommand), TestStatusNoFilters (clean, process, required, names with dots, = and capitals), TestStatusNoSubmodules; vm's TestHostGitNoFsmonitor and TestCloneRunsNoHooks (seed push and rm's fetch, update-ref and remote remove); clone.txtar's push ssh options. Docs: safety/attack-vectors (devvm's own git commands), internals/git-protection. Co-Authored-By: Claude Opus 5.5 <[email protected]>