Git guard: set -a exports GIT_DIR too, so the exported-GIT_DIR hole stays open that way #67

Open
opened 2026-11-22 23:05:51 +00:00 by vesta · 0 comments
Member

Purpose (defect): a member can set -a; GIT_DIR=<clone>/.git; git push origin HEAD from the worktree place and the push reaches the clone's default branch, because the guard reads only the export GIT_DIR= way of exporting.

Refs macula-io/martha#53 (the exported GIT_DIR= hole, fixed by PR 66) and macula-io/martha#45 (the Git guard row). Found while writing #53's threat model, 2026-11-22, with real git 2.56.1 and real bash.

What happens

set -a (allexport) makes every assignment after it an exported one. A bare GIT_DIR=<path> standing as a command of its own is then given to the commands after it, exactly as an export GIT_DIR=<path> is:

set -a; GIT_DIR=<clone>/.git; git push origin HEAD

Probe, in a worktree place, against a clone whose origin's default branch is main:

set -a; GIT_DIR='<clone>/.git'; git rev-parse --absolute-git-dir
-> <clone>/.git          (an unexported bare assignment answers "not a git repository")

PR 66 reads export GIT_DIR=, export GIT_DIR, export -n, unset and the subshell's end, and states set -a as a limit rather than folding it in: it was outside #53's scope, which names the export form.

What it would take

The reader carries whether the line's shell has allexport on: set -a (or set -o allexport) turns it on, set +a (or set +o allexport) turns it off, and while it is on a bare GIT_DIR=<path> standing as a command of its own is exported as if export had been written. The same walk that PR 66 adds carries it, in the same shell state, and drops it nowhere else: set +a does not unexport what is already exported.

Guard code: a threat model first, red first, and mutants on the refusal. No new check.

Purpose (defect): a member can `set -a; GIT_DIR=<clone>/.git; git push origin HEAD` from the worktree place and the push reaches the clone's default branch, because the guard reads only the `export GIT_DIR=` way of exporting. Refs macula-io/martha#53 (the exported `GIT_DIR=` hole, fixed by PR 66) and macula-io/martha#45 (the Git guard row). Found while writing #53's threat model, 2026-11-22, with real git 2.56.1 and real bash. ## What happens `set -a` (allexport) makes every assignment after it an exported one. A bare `GIT_DIR=<path>` standing as a command of its own is then given to the commands after it, exactly as an `export GIT_DIR=<path>` is: set -a; GIT_DIR=<clone>/.git; git push origin HEAD Probe, in a worktree place, against a clone whose origin's default branch is `main`: set -a; GIT_DIR='<clone>/.git'; git rev-parse --absolute-git-dir -> <clone>/.git (an unexported bare assignment answers "not a git repository") PR 66 reads `export GIT_DIR=`, `export GIT_DIR`, `export -n`, `unset` and the subshell's end, and states `set -a` as a limit rather than folding it in: it was outside #53's scope, which names the `export` form. ## What it would take The reader carries whether the line's shell has allexport on: `set -a` (or `set -o allexport`) turns it on, `set +a` (or `set +o allexport`) turns it off, and while it is on a bare `GIT_DIR=<path>` standing as a command of its own is exported as if `export` had been written. The same walk that PR 66 adds carries it, in the same shell state, and drops it nowhere else: `set +a` does not unexport what is already exported. Guard code: a threat model first, red first, and mutants on the refusal. No new check.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
martha-ai/martha#67
No description provided.