The environment GitAegis runs Git in
Pinned GIT_CONFIG_*, GIT_TERMINAL_PROMPT=0, and core.hooksPath=/dev/null in Safe Mode.
One place where Git is started
Every Git command GitAegis runs goes through a single subprocess boundary. That is why this page can state the environment exactly: there is one function that spawns git, not two hundred call sites that could each forget something.
- Arguments are passed as an argv array, never as a shell string. No shell is involved, so nothing in a branch name or a path can be interpreted as a command.
- The working directory is pinned to the repository’s worktree.
- The environment is cleared and rebuilt from an allowlist, so the child inherits nothing that happened to be set in the parent.
- Every command has a timeout and an output cap, and stderr is credential-redacted before it reaches an error message or the journal.
The environment the child gets
The child’s environment is emptied first, then four variables are copied across if they are set, and two are set outright.
| Variable | Where it comes from |
|---|---|
PATH | Inherited. Git needs it for its own helpers. It is not used to find git itself: the runtime is an absolute path chosen at startup. |
HOME | Inherited, so your own global Git configuration is read as usual. |
TMPDIR | Inherited. |
SSH_AUTH_SOCK | Inherited, so an already-running ssh-agent works exactly as it does in a terminal. |
LC_ALL=C | Set. Machine-readable output has to be locale-stable to be parsed. |
GIT_TERMINAL_PROMPT=0 | Set. Git can never open a credential prompt behind the window; an operation that needs credentials your helper cannot supply fails with a message instead of hanging. |
Everything else is absent, including Git transport controls, and including any GIT_CONFIG_* that was set in the parent process.
Configuration pinned on every invocation
A repository’s own .git/config and .gitattributes are attacker-controlled data: repositories arrive in zip files, on shared drives, and as clones of somebody else’s fork. Several ordinary Git settings name a program that Git executes during a completely routine command. Three are neutralised on every invocation:
| Key and value | What it stops |
|---|---|
core.fsmonitor=false | A repository-declared file-system monitor program, which would otherwise run on every git status. |
core.pager=cat | A repository-declared pager program. |
protocol.ext.allow=never | The ext:: remote helper, which turns a URL into a command line. |
They are passed to the child through GIT_CONFIG_COUNT, GIT_CONFIG_KEY_<n> and GIT_CONFIG_VALUE_<n> rather than as -c arguments. Both routes carry the same, highest precedence (a repository cannot override either) but the environment leaves argv untouched, and argv is load-bearing here: GitAegis previews the exact command to you and journals it, so a process spawned with flags the plan never contained would make the recorded command a different command from the one that ran.
Your own global configuration is trusted and is not stripped. Only the repository’s is treated as untrusted, and because -c cannot tell the two apart, the neutralisation is limited to keys whose blast radius justifies it.
core.hooksPath=/dev/null, and when it applies
A hook is a program the repository asks Git to run. Disabling hooks wholesale would break the thing many people install GitAegis to keep (their own pre-commit checks) so the rule is split by what the command does.
| Situation | Hooks |
|---|---|
| A read-only subcommand, outside Safe Mode | Disabled. core.hooksPath=/dev/null is pinned for the read set below. |
| A write subcommand, outside Safe Mode | Your hooks run, as they should. A commit runs your pre-commit hook. |
| Any subcommand, in Safe Mode | Disabled, including the write subcommands a repair issues. In Safe Mode the index or HEAD is already known to be untrustworthy, so the promise is that no hook of the repository’s choosing runs at all. |
The read-only set, verbatim:
blame cat-file check-attr check-ignore
check-ref-format count-objects describe diff
diff-files diff-index diff-tree for-each-ref
hash-object log ls-files ls-tree
merge-base name-rev reflog rev-list
rev-parse shortlog show show-ref
status var write-treeSafe Mode covers what else that state locks. One limit is worth repeating here, because it is easy to assume the opposite: content filters are not sandboxed. A filter.<driver> declared by the repository’s own .gitattributes can still run during a repair that materialises the working tree. Git offers no way to disable filters wholesale from the command line, so the claim was retracted rather than faked. If a repository’s filters are themselves suspect, repair it from a shell.
Two flags that have no configuration equivalent
diff.<driver>.textconv and diff.external also name programs, and they run by default on the diff porcelain. Setting diff.external to the empty string makes Git try to execute "" and fail the whole command, so the only reliable neutralisers are per-command options:
git blame --no-textconv --no-ext-diff …
git diff --no-textconv --no-ext-diff …
git log --no-textconv --no-ext-diff …
git show --no-textconv --no-ext-diff …These are the one argv change GitAegis makes to a command, and they are appended after the subcommand so the first argument is still the subcommand a caller asked for.
Two more variables, on specific paths
GIT_OPTIONAL_LOCKS=0: set for Doctor’s evidence probes and for the read paths that would otherwise refresh the real index. Diagnosis must not rewrite the index it is examining, and a status read must not contend for.git/index.lockwith a mutation in flight.GIT_INDEX_FILE: pointed at a private copy of the index when GitAegis needs a tree from the current staged state.git write-treetakes an index lock even though it changes nothing, so it is aimed at a snapshot instead of the real file.
Timeouts and output caps
| Limit | Value |
|---|---|
| Default timeout | 30 seconds |
| Long timeout | 300 seconds, for network-facing work such as fetch |
| stdout cap | 8 MiB |
| stderr cap | 1 MiB |
Exceeding either is an error, not a truncation: a timeout ends as AEG-GIT-RUNTIME-0004 and an oversized output as AEG-GIT-RUNTIME-0005, both saying what was killed and what remains safe. Troubleshooting covers what to do when a large repository meets one of them.