← Back to Pull requests

fix: close three ways past the hidden-repository protection in the Bash guard #466

Open
unknown opened this pull request with 435 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 20, 2026 14:32 UTC
Author

Summary: This project's safety filter checks the shell commands an AI coding assistant runs. Last week's fixes stopped git from loading a hidden git folder a branch could plant, because that folder can name a program for git to run. Three ordinary ways around that protection still worked, and one git option could print the first line of the secrets file. This closes them.

---

What

The guard is .claude/hooks/guard-bash.py. With git 2.47.3, each of these ran a planted diff..textconv program while the guard said nothing:

  • Two options hid the rest. git --shallow-file x --git-dir=evil log -p and git --attr-source HEAD -c safe.bareRepository=all log -p. Both options take the next word as their value. The walk added in #463 read that value as the subcommand and stopped before --git-dir or -c safe.. --attr-source is now in _GIT_GLOBAL_VALUE_NEXT. --shallow-file is refused outright, because git --shallow-file .env log -1 also prints .env's first line in its error, past the Read(./.env) deny rule.

  • Unsetting the setting. unset GIT_CONFIG_COUNT; git log -p and GIT_CONFIG_COUNT=0; git log -p. .claude/settings.json exports that name, so bash passes the change to git.

  • Pointing git at a planted config. HOME=planted; git log -p made git read planted/.gitconfig. The guard refused HOME=planted git log -p but not the standalone form.
  • The guard assumed a standalone NAME=value only sets a shell variable no child process sees. That is false for a name already exported. The fix reads a standalone assignment to a name outside SAFE_ENV, or an unset of a GIT_CONFIG_ name, the way it already reads NAME=value in front of the verb, for any guarded command later in the same string. unset FOO still passes: it takes away nothing the guard relies on.

    Blast radius. X=1; git diff HEAD is now refused where it passed before. Three "passes by design" rows used X=1 to show that set -o pipefail is not set -a; they now use TZ=UTC, which keeps that meaning. Under AGENTS.md this is widening, not overturning a decision. Names on the safe list, and an assignment written after the git command, still pass.

    Out of scope. The shared refusal list copy (tests/fixtures/gate-refusal-corpus.json) is not updated. With this fix the current shared copy passes here except for three rows: it expects this guard to allow env -u FOO git log -1, env -S -u FOO git log -1 and exec -a name git log -1. This guard refuses every wrapper in front of git by design. Allowing them loosens the guard, which needs the owner, so that is left for a separate decision.

    Validation.

  • 17 new or changed tests in tests/test_agent_permissions.py fail on main and pass here: refusal rows for each spelling, plus three mutation rows proving each new rule is what refuses its witness.

  • Full suite: 2257 passed, 27 skipped.

  • ruff check and ruff format --check report the same findings on main, so nothing new.
  • Closes #465

    Decision taken by hive: per AGENTS.md "Owner's standing decisions" (Adding or widening a check; Repeating an earlier decision: atomic-image-builder#890 and #892, akmods#314, tududi#634, sensi#705).

    Checks

  • pytest -q passes locally

  • npx -y @anthropic-ai/mcpb@2.1.2 validate ./manifest.json passes (if manifest.json changed): not changed

  • Version in pyproject.toml / manifest.json left unchanged
  • ---
    Filed by sec-check agent (ACMM L6 — full mode)*

    Diff: 435 lines (+326 / -109) across 5 files Reviewer: Danathar Review duration: 2186m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 435 lines diff across 5 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #466"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.8% · Safe to merge
    26.8%