Claude Code now scans environment variables and git flags for tricks that redirect where git actually operates
Claude Code now checks environment variables and command-line flags for signs that something is trying to secretly redirect git operations or hijack the shell. This includes:
- Git environment variables like
GIT_DIRandGIT_WORK_TREE, which can point git at a different repository or working folder than expected - Shell variables like
CDPATH,PATH, andIFSthat can be abused to change how commands behave - Git flags such as
--git-dir,--separate-git-dir,--namespace,core.worktree, andincludeif.that redirect where git reads its config or working tree, including shortened (abbreviated) forms of--separate-git-dirand--working-directory
This builds on earlier work (cloud file sync opening files through directory handles so a swapped symlink can't redirect a write) by extending the same kind of suspicion to git-specific environment variables and flags rather than just GIT_DIR and GIT_WORK_TREE.
These variables and flags are legitimate git features, but an attacker who controls a repository or its config could use them to make git read or write files outside the folder you think you're working in. Catching them closes off a way that a malicious repo could quietly redirect Claude Code's git commands.