Repository navigation
Description
block-noncanonical-commit on main exits 139 on a wrapped cd builtin
This is a crash in the shipped guard, independent of any open PR. Exit status 139 is 128+11 — SIGSEGV. Reproduced against origin/main's guard (guardrails 0.16.3), not a branch build:
fixture:
outer repo git config alias.a '!command cd child && git a'
child repo git config alias.a 'commit --allow-empty -m bypass'
$ echo '{"tool_name":"Bash","tool_input":{"command":"git a"},"cwd":"<outer>"}' \
| bash plugins/guardrails/hooks/block-noncanonical-commit.sh
exit 139
A PreToolUse hook that dies on a signal is worse than one that returns a wrong answer: the exit status is not 0 or 2, so the harness sees neither a clean allow nor a deliberate block. Whatever it does with that is not a decision the guard made. Worth confirming what Claude Code treats a signal-death hook as before deciding severity — if it is treated as non-blocking, this is a fail-open triggered by an attacker-chosen alias body.
Reproduced on git version 2.54.0.windows.1, OSTYPE=cygwin (Git Bash). Needs confirming on Linux/macOS — it may be host-specific, which is itself worth knowing.
Secondary: the wrapped-cd form is not recognized at all
Independently of the crash, command cd <dir> and builtin cd <dir> are literal directory changes that no guard in this family classifies. Real git relocates and commits in the destination:
real git guard should main (branch)
command cd child commits block (2) 139 0
Neither blocks. This is a specific instance of the broader relocation gap tracked in #1486 — the guard does not evaluate shell relocation, and wrapper builtins are one of the forms a real fix would have to handle. It is listed there among the four findings that a reverted attempt drew.
Filing separately from #1486 because the crash is not about relocation semantics at all, ships in main today, and should be triaged on its own timeline.
Suggested first steps
- Confirm the exit-139 reproduction on a Linux runner and pin down which statement dies — the fixture is small and the guard runs under
set -uo pipefail, so a candidate is an unguarded array/parameter expansion reached only on this path. - Confirm how the harness treats a signal-death PreToolUse hook (allow, block, or error), which sets the real severity.
- The recognition gap can then be handled with guardrails: block-noncanonical-commit analyzes the wrong repository when a
!alias body relocates the process (cd) #1486 rather than here.
Related
- guardrails: block-noncanonical-commit analyzes the wrong repository when a
!alias body relocates the process (cd) #1486 — thecdrelocation gap, includingcommand cd/builtin cdamong the forms a real fix must handle. - hook-utils: shared helpers degrade silently to permissive answers (fail-open defaults in the SSOT lib) #1487 — fail-open defaults in the shared
hook-utils.sh. - guardrails: block-dangerous-git resolves lease hash-width for the wrong repository across a
!alias hop #1469 —block-dangerous-git'srepo_oid_width()resolving the wrong repository across a!alias hop.
Activity
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Triage: verified — human-gated
Core defect: confirmed real, and broader than the title states. Traced
check_segment()inblock-noncanonical-commit.shend to end for the persisted (!-prefixed, config-stored) shell-alias path (thegit config --get alias.$subbranch, guarded only byHOOK_NO_ALIAS). There is no cycle or recursion-depth guard anywhere in this file for that path — no seen-set, no depth counter, nothing analogous to the one-levelHOOK_NO_ALIAScap that bounds the inline (-c) alias case. Each!-body reparse is a freshhook::bash_parse_segments … check_segmentcall with no memory of prior frames.In the reported fixture,
effective_dir()composes its probe directory fromHOOK_CWD(the hook payload's cwd, captured once) plus any-Cin the current segment's own words — it has no awareness of a shellcd, wrapped or not. So after the alias body'scommand cd child && git areparses into two segments, the second segment (git a) still probesalias.ain the outer repo (becauseeffective_dirnever moved), finds the same alias string again, and reparses it again — forever. That's an unbounded recursivecheck_segmentchain with no termination condition, which is what exhausts the stack and produces the OS-delivered SIGSEGV -> bash-reported exit 139.Correction: the
cdis not actually load-bearing for the crash itself. The same infinite loop reproduces with a bare self-referential persisted alias and nocdat all — e.g.git config alias.a '!git a'thengit a— because the persisted-alias lookup has no cycle detection independent of directory tracking. Thecd/commandwrapper in this issue's fixture is what makes the loop land on a cross-repo commit (tying it to #1486's relocation gap), but the crash mechanism itself is a plain missing-cycle-guard bug in the alias-resolution recursion, not specifically acd-parsing gap. Worth knowing because a fix aimed only at recognizingcommand/builtin cdwould not close the crash — the missing piece is a seen-set/depth cap on the persisted-alias chain, independent of whether any relocation occurs.Severity-determining question, resolved against the current docs, not assumption. Fetched
https://code.claude.com/docs/en/hooksthis session (per this repo's fresh-docs mandate) and confirmed the exit-code contract directly:And explicitly: "Claude Code treats exit code 1 as a non-blocking error and proceeds with the action, even though 1 is the conventional Unix failure code. If your hook is meant to enforce a policy, use
exit 2." Exit 139 (a signal-terminated process) is neither 0 nor 2, so it falls under "any other exit code."Confirmed: FAIL-OPEN. The crash does not block the tool call —
PreToolUseonly blocks on a literal exit code 2, and a signal death reports 128+signal, never 2. The underlyinggit a(the non-canonical, cross-repo commit in the fixture) proceeds exactly as if the guard had explicitly allowed it, with only ahook errortranscript notice (not a block message) as the visible trace. This makes the crash strictly more dangerous than a wrong-verdict bug: it is a guaranteed, deterministic bypass triggerable by any self-referential (or relocation-then-repeat) persisted shell alias — no cross-repo hash-format collision or other narrow precondition required, unlike #1469.Why human-gated, not autonomous-eligible. Closing this safely requires designing a cycle/depth-detection primitive for the alias-resolution recursion — precisely the class of "no existing mechanism in this codebase, and a prior attempt at adjacent machinery (
f3c221d024) was reverted after shipping regressions" situation that #1486 was already ruled human-gated for. It is also entangled with the "single chokepoint for repository-resolution state across recursivecheck_segmentcalls" design question #1500 raises (the same recursive-call argv truncation that dropscd-relocation context also drops other locating globals) — not an isolated, bounded bug fix.Priority. Setting
priority: high, consistent with thepriority: highalready applied to #1469 and #1486 for the same reasoning (significant, demonstrated guard-defeat; notpriority: criticalbecause there's no active/observed in-the-wild exploit, only a reliably reproducible one requiring an attacker or careless user to have already defined a relocating/self-referential alias). Flagging for the human reviewer that this instance is arguably the most severe of the cluster: unlike #1469/#1486, it needs no cross-repo hash-format coincidence — any self-referential persisted!alias triggers it — so it may warrantpriority: criticalon reconsideration; deferring that call to the maintainer rather than defaulting it myself.Cluster synthesis — one structural defect, five findings
This is now the fifth open, verified finding pointing at the same trust boundary in the
block-noncanonical-commit/block-dangerous-gitguard family, all filed and triaged in this session:!alias hop #1469 —block-dangerous-git'srepo_oid_width()resolves lease hash-width against the wrong repository across a!alias hop. (human-gated,priority: high)!alias body relocates the process (cd) #1486 —block-noncanonical-commitanalyzes the wrong repository when a!alias body relocates the process viacd. (human-gated,priority: high)cdbuiltin in a shell-alias body #1495 (this issue) — the persisted-alias resolution recursion has no cycle guard at all and crashes (SIGSEGV / exit 139), which is fail-open per the harness's own exit-code contract.check_segmentcall for an inline-alias expansion (${w[@]:0:gi+1} … ${w[@]:sub_idx+1}) drops--git-dir/--work-tree/-centirely when composing the nested argv — confirmed by direct read ofcheck_segment(), the lines composing the recursive call.git config --get alias.$subprobe never replays--git-dir/--work-tree(only-C, viaeffective_dir()).Every one of these is the same underlying boundary stated explicitly in #1486's and #1500's own "Related" sections: this guard family does static matching over the literal command string, tracks repository identity per-segment rather than propagating it through recursion, and was never designed to survive a
!alias hop or acd. Patching each guard/each call site individually (as these five issues are scoped) risks a sixth and seventh instance of the same class — the same pattern #1486 already flagged forblock-dangerous-git's own documented compound-cdresidual.Recommendation for the human decision-maker: treat this as one architectural review — most likely resolved by the single-chokepoint design #1500 proposes (a resolved-repository-identity value threaded through every recursive
check_segment/alias-expansion call, replayed on every git probe that answers a repository question) — rather than five independent PRs. #1500 is the natural design carrier since its fix-direction section is the only one that names the general mechanism; #1469, #1486, #1495, and #1501 each become verification fixtures once that mechanism exists. I have not addedblocked-byedges between these issues: each issue explicitly scopes itself as independently valuable/fixable ("worth doing regardless of how that design lands" — #1501; "filed separately... on its own timeline" — #1495), so a hard dependency edge would misrepresent their own stated scope. This paragraph is the flag for a human to make that judgment call explicitly, since I'm not authorized to restructure the two already-triaged items (#1469, #1486) or unilaterally decide the cluster should be merged into one carrier.Role-label note:
.work-item-tracker.jsonhas noconfig.role_labelsentry, so the canonical human-gated role resolves to its documented default (needs-human).Outcome: labels normalized off
priority: needs-triage; applyingpriority: high+needs-human.area: securityretained. Type was already nativeBug.kyle-sexton commentedon Aug 13, 2026
Frontier disposition (drain session)
Ruling: Close as not planned for this drain wave.
SIGSEGV (exit 139) on wrapped
cdin alias bodies is a live crash but structurally the same compound-shell class as carrier #1500. Fix and regression belong in that coordinated guard pass, not a parallel tracker slot.Re-open trigger: Crash repro still passes on main after #1500 closes.
fix(knowledge): pass --asr-python from every source and point the av …