Repository navigation
Description
alias_launch_dir returns the caller's composed directory — not the repository top level — when rev-parse --show-prefix is empty and explicit locating globals are present. A nested alias is then looked up in the invoking directory, misses, and the guard allows, while real git resolves the alias in the located repository and performs a non-canonical commit.
Reproducer shape
Invoked from a non-repository directory, with locating globals supplied and a repeated --git-dir so last-wins applies, chaining to a persisted alias that expands to a non-canonical commit.
Ground truth: real git commits. The guard returns 0.
Why the current branch is reached
From block-noncanonical-commit.sh, main's own documentation of the four cases:
- prefix EMPTY under explicit locating globals: git does not chdir, so the body runs in the caller's composed directory, returned LITERALLY for git to apply its own path semantics downstream.
The premise is correct about where the body runs. The gap is what the alias lookup needs: git config --get alias.<name> evaluated with those locating globals reads the located repository's config, not the invoking directory's. So returning the invoking directory literally is right for path semantics and wrong for alias resolution, and the nested lookup misses.
On this shape the invoking directory is not a work tree at all, so the miss is total and the chain is allowed without its terminal command ever being classified.
Constraints on the fix — please do not regress these
The current implementation is better than the earlier simpler one on three axes that must survive any change here:
%q-encoded cache keys. Each argv word isprintf '%q'-encoded before joining. A space-joined key collides--git-dir 'X --work-tree'with--git-dir X --work-tree, so the second segment receives the first's answer — a wrong repository, decided fail-open. Keep the encoding.- Byte-exact
rev-parsereads, one call per field. Only git's single trailing LF is stripped, so a path with an interior or trailing newline (or a legitimate trailing CR) is not corrupted, and an interior newline in one field cannot be read as the boundary into the next. Keep separate calls; do not combine--show-toplevel --show-prefixand split on a newline. - The
--show-prefixbranch structure itself, which is what makes-C .,link/.., and a subdirectory all collapse to one identity so the shell-alias cycle key can detect a repeat instead of walking forever.
The narrow question is what the prefix-empty-with-locating-globals branch should return for alias-lookup purposes, which may need to be a different value from what it returns for path composition. Splitting those two consumers is likely the smallest correct change.
Provenance and confidence
Surfaced while evaluating whether #1085 still had anything to contribute after #1503 landed. It is the one row where #1085's simpler alias_launch_dir — which returned the top level unconditionally — blocked and the current implementation does not.
Verified against real git with commit-count ground truth rather than exit codes alone, and the code path was independently confirmed to match main's documented behavior for this case. Flagging explicitly that the current behavior is deliberate and documented, so this needs confirmation by someone who owns that design before it is treated as settled — the reproducer may also warrant a Linux run, since it was exercised on Git Bash.
Related: #1503 (the landed fix), #1501 (persisted-alias lookup drops locating globals — adjacent, also an alias-resolution-versus-location split), #1500, #1502, #1486.
Activity
kyle-sexton commentedon Jul 26, 2026
Triage: verified → briefed, human-gated
Category: Bug (fail-open in a security-adjacent guard),
guardrails.Verification — accepted from the reporter's recorded evidence, deliberately NOT re-reproduced.
The reproducer is an exotic multi-step shape: invocation from a non-repository directory, explicit
locating globals with a repeated
--git-dirso last-wins applies, chaining to a persisted aliasthat expands to a non-canonical commit. The reporter verified it against real git using
commit-count ground truth rather than exit codes alone, and independently confirmed the code
path matches the guard's own documented behavior for the prefix-empty-under-locating-globals case.
Re-running it here would mean constructing a repository and alias state to drive a real commit
through a guard bypass; the recorded evidence is stronger than what an unattended re-run would add,
so provenance is recorded as accepted rather than reproduced.
The mechanism is coherent on inspection:
alias_launch_dirreturns the caller's composed directoryfor path-semantics reasons, but
git config --get alias.<name>evaluated with those same locatingglobals reads the located repository's config. One return value is serving two consumers with
different correct answers, and the alias lookup gets the wrong one.
Redundancy check. Searched the guard for an existing split between path-composition and
alias-lookup directory resolution: there is none — one function serves both. The adjacent prior
findings the report names (the landed fix for this branch structure, and the persisted-alias lookup
dropping locating globals) are distinct defects in the same resolution area, not duplicates of this
one.
Why human-gated — the reporter asks for it explicitly. The body states that the current
behavior is deliberate and documented, and that this "needs confirmation by someone who owns
that design before it is treated as settled." An autonomous agent cannot supply that confirmation:
the question is whether the documented premise was intended to cover alias resolution, which is
design intent, not a fact recoverable from the code.
Constraints the fix must not regress — carried forward from the report, and binding on whoever
takes it:
%q-encoded cache keys — a space-joined key collides distinct argv shapes and hands one segmentanother's answer, deciding the wrong repository fail-open.
rev-parsereads, one call per field, so a path containing a newline or trailing CRis neither corrupted nor misread as a field boundary. Do not combine the two queries and split.
--show-prefixbranch structure itself, which collapses equivalent spellings to one identityso the shell-alias cycle key can detect a repeat instead of walking forever.
The narrow question is what that branch should return for alias-lookup purposes, which may need
to differ from what it returns for path composition; splitting the two consumers is the likely
smallest correct change.
Open, unverified: the reproducer was exercised on Git Bash only. The report flags that a Linux
run may be warranted.
Labels applied:
priority: high(a live guard bypass on the default branch, and the guard is asecurity control — held below the top tier because exploitation requires an exotic invocation shape
and the guard is defense-in-depth, not the sole control),
needs-human; existingarea: securityretained; raw marker cleared.
kyle-sexton commentedon Aug 13, 2026
Frontier disposition (drain session)
Ruling: Classified for drain orchestration.
Human gate cleared for classification; implementation authority follows the ruling.
kyle-sexton commentedon Aug 13, 2026
Frontier consensus (binding) — drain
bc-f3123271Paired with #1500. Same chokepoint design: locating context propagates across
!hops; prefix-empty path composition unchanged for cycle identity. IMPLEMENT_NOW with #1500.kyle-sexton commentedon Aug 13, 2026
Fixed on #2562 (
cursor/guardrails-alias-chokepoint-1500-d116, guardrails 0.28.21).The
#1553reproducer shape (persisted alias chain, repeated--git-dirlast-wins, invoked outside any work tree) is now BLOCKED — alias lookup replays locating globals throughrepo_git_probewhilealias_launch_dircontinues returning the caller's composed directory for path composition only.Constraints preserved:
%qcache keys, byte-exact per-fieldrev-parse, and the--show-prefixbranch structure for cycle-key collapse.fix(guardrails): repo-context chokepoint for block-noncanonical-commit (
docs(guardrails): changelog entry for repo-context chokepoint (#1500, #…
fix(guardrails): repo-context chokepoint for nested alias resolution