You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
guardrails: both git guards recurse into aliases git itself refuses (environment-changing global in a non-shell expansion) #1502
Both git guards recurse into the terminal command of a non-shell alias whose expansion begins with an environment-changing global (-C, and the sibling locating globals). Git refuses such an alias outright, so the terminal command never runs — but the guards analyze it and block, surfacing a guard verdict for a command git itself would reject.
No legitimate work is refused. The command git rejects with exit 128 does not execute under either verdict, so the only observable cost is that a user typing such an alias chain sees the guard's message instead of git's fatal:. This is categorically different from a false positive that blocks a genuine canonical commit.
The control row is why this is not a regression relative to the default branch: on the legitimate two-hop chain the pre-#1085 guard returns 0, because it lacks the alias-chain traversal work entirely — so it allows both the harmless case and the real bypass. The hardened guard blocks both: one correctly, one unnecessarily. On that pair the hardened guard is substantially better, not worse.
Fix direction
Detect git's environment-changing globals in a non-shell alias expansion and stop before recursively analyzing its terminal command. The recursion is duplicated, so the fix belongs in both plugins/guardrails/hooks/block-dangerous-git.sh and plugins/guardrails/hooks/block-noncanonical-commit.sh.
Take the locating-option set from the existing shared extractor rather than writing a third list — a divergent hand-rolled list was itself the cause of an earlier finding on #1085 (first-match instead of collect-all-in-order aimed the identity probe at the wrong repository).
Provenance
Surfaced by external review on #1085 at block-dangerous-git.sh:534 and verified empirically before routing. Resolved on that PR as a documented residual rather than fixed, because every finding #1085 did fix was a fail-open bypass with a fixture, and an over-refusal of a command git will not run did not warrant holding that hardening.
Verification: confirmed. Read both hooks directly.
plugins/guardrails/hooks/block-dangerous-git.sh (inline-alias re-expansion, alias_rc == 0 branch, git-alias case) and plugins/guardrails/hooks/block-noncanonical-commit.sh (same shape, inline_alias_handled branch) both call hook::env_s_split "$exp" and immediately recurse into check_segment on the expansion with no check for whether $exp's first token is one of git's environment-changing globals (-C, --git-dir, --work-tree, --namespace, …) before recursing. Both files already carry a -C | --git-dir | --work-tree | --namespace case elsewhere (e.g. block-dangerous-git.sh:268), confirming the locating-option set this issue asks to reuse already exists as a shared list rather than needing a third hand-rolled copy.
The ground-truth claim (git refuses a non-shell alias whose expansion opens with an environment-changing global, fatal: alias 'b' changes environment variables, exit 128) is git's own documented alias-safety behavior and is consistent with both guards' existing fail-closed handling of the sibling --config-env alias case immediately above this code path.
Severity assessment holds: this is over-refusal of a command git itself already refuses, not a bypass. Fails safe.
Closing as an accepted limitation (fail-safe over-block), per the issue's own severity rating and fix direction.
Evidence: Git refuses environment-changing global aliases (fatal: alias changes environment variables); the guards may still analyze the terminal command and surface a block verdict for a command git would never run. The issue documents this as cosmetic, fails safe — no legitimate work is refused.
Activity
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Triage
Verification: confirmed. Read both hooks directly.
plugins/guardrails/hooks/block-dangerous-git.sh(inline-alias re-expansion,alias_rc == 0branch, git-alias case) andplugins/guardrails/hooks/block-noncanonical-commit.sh(same shape,inline_alias_handledbranch) both callhook::env_s_split "$exp"and immediately recurse intocheck_segmenton the expansion with no check for whether$exp's first token is one of git's environment-changing globals (-C,--git-dir,--work-tree,--namespace, …) before recursing. Both files already carry a-C | --git-dir | --work-tree | --namespacecase elsewhere (e.g.block-dangerous-git.sh:268), confirming the locating-option set this issue asks to reuse already exists as a shared list rather than needing a third hand-rolled copy.fatal: alias 'b' changes environment variables, exit 128) is git's own documented alias-safety behavior and is consistent with both guards' existing fail-closed handling of the sibling--config-envalias case immediately above this code path.Classification
priority: low— the issue's own severity section is explicit ("cosmetic, fails safe... categorically different from a false positive that blocks a genuine canonical commit"), and no legitimate work is refused. Lower than the sibling cluster (guardrails: block-dangerous-git resolves lease hash-width for the wrong repository across a!alias hop #1469, guardrails: block-noncanonical-commit analyzes the wrong repository when a!alias body relocates the process (cd) #1486, guardrails: block-noncanonical-commit on main exits 139 (SIGSEGV) on a wrappedcdbuiltin in a shell-alias body #1495, guardrails: block-noncanonical-commit resolves the repository at the outer invocation when the nested one determines it #1500, guardrails: persisted-alias lookup drops --git-dir/--work-tree, missing a non-canonical commit (shared gap with main) #1501), which are real fail-open bypasses or crashes.!alias hop #1469/guardrails: block-noncanonical-commit analyzes the wrong repository when a!alias body relocates the process (cd) #1486/guardrails: block-noncanonical-commit on main exits 139 (SIGSEGV) on a wrappedcdbuiltin in a shell-alias body #1495/guardrails: block-noncanonical-commit resolves the repository at the outer invocation when the nested one determines it #1500/guardrails: persisted-alias lookup drops --git-dir/--work-tree, missing a non-canonical commit (shared gap with main) #1501 on the same shared surface.Labels applied:
priority: low,needs-human(role labels resolved from tracker defaults — noconfig.role_labelsoverride in.work-item-tracker.json).priority: needs-triagecleared.Related: #1500, #1501, #1486, #1495, #1469 (same alias-recursion surface; not a blocking dependency — independently fixable).
kyle-sexton commentedon Aug 12, 2026
Closing as an accepted limitation (fail-safe over-block), per the issue's own severity rating and fix direction.
Evidence: Git refuses environment-changing global aliases (
fatal: alias changes environment variables); the guards may still analyze the terminal command and surface a block verdict for a command git would never run. The issue documents this as cosmetic, fails safe — no legitimate work is refused.Tracking closed; a future optimization could stop recursion before analyzing git-refused alias bodies.