Skip to content

Ask only for commands whose effects leave the sandbox #177

Closed

Description

@furedea-agent

Purpose

ADR-0034 says to ask only for effects that escape the sandbox, but the allowed-command guard still asks for any approved family whose form is not in the precise allowlist and for any run-time word. Replaying the 151 Bash commands run after #175 through the current hooks gives 58 non-allow verdicts; 56 of them are asks for commands that the sandbox already contains:

  • 44: a variable such as $W or $D passed to git, sed, gh, cat, or mkdir.
  • 7: git commit forms outside the commit pattern (for example -S).
  • 5: other unlisted forms (git branch -D, git branch -r, gh api ... --jq, sed -i '').
  • 1: zsh-only syntax.

Only 2 were real denials (a credential read and find -exec).

Scope

  • Commands whose effects stay on this machine pass unless a forbidden rule or the dangerous-Git guard denies them, regardless of form or run-time words.
  • Commands that change GitHub (git push, gh writes) keep their static checks and ask only when a run-time word hides what the check needs, such as the push destination.
  • Commands outside the sandbox (docker, herdr, watchman) and the existing ask prefixes are reviewed against the same rule.

Out of scope

  • Changing the forbidden rules or the dangerous-Git denials.
  • Merging, which stays with the user.

Acceptance criteria

  • Replaying the same 151 commands asks only where a run-time word hides a GitHub-affecting target, and still denies the 2 forbidden ones.
  • echo "$(rm -rf x)", a force push inside a loop, and pushes to main are still denied.
  • An ADR records the change, or ADR-0034 is amended.

Activity

  1. furedea-agent commented on Oct 17, 2026

    @furedea-agent
    ContributorAuthor

    Plan

    Principle: the hooks ask only where a run-time word hides what a check needs to see, and only for effects the sandbox cannot contain. Everything else passes unless a forbidden rule or the dangerous-Git guard denies it.

    1. Allowed guard (guard_command.py allowed).

      • Drop the "approved family, unlisted form" ask for commands whose effects stay local, and drop the run-time-word ask for local commands.
      • Keep precise forms only for GitHub-affecting families (gh api methods, gh writes, git push). A run-time word there asks.
      • Remove the local-command patterns from allowed_commands.json that no longer decide anything (commit, sed, branch, and so on).
    2. Dangerous-Git guard (guard_git.py). Ask for a run-time word only when the word can change the verdict:

      • a dynamic program or subcommand;
      • a dynamic word in git push (remote, refspec, or flags);
      • a dynamic word that could be a flag of a subcommand git_safety inspects (reset, clean, checkout, restore, branch, stash, rebase, and so on).

      git -C $W add, git -C $W diff, and a quoted -m "$MSG" pass.

    3. Unsupported syntax. zsh-only expansions such as ${(@f)...} still ask, since the parser cannot see the commands inside.

    4. Native ask prefixes (command_permissions.json). Move local, recoverable ones to allow: ln -s, git stash drop, git stash clear. Keep ask for:

      • irreversible local effects: rm, kill, pkill;
      • code fetched from the network: uv add, npm install, npx, nix run, nix shell, and so on;
      • GitHub or remote writes: gh pr merge, gh release, gh workflow run, git remote set-url;
      • tools outside the sandbox: docker, herdr control, terraform, esa.
    5. ADR. Record the inversion (allow by default inside the sandbox, ask only for hidden outward targets) as a new ADR that amends ADR-0034.

    Verification

    • TSDD tests per slice in tests/agents/hooks. Existing denial tests stay green: substitutions, clauses, shell heredocs, force push, push to main, and --no-verify.
    • Replay the 151 commands from the Issue through the new hooks. Expect only GitHub-target asks and the 2 denials.
    • Full uv run --frozen pytest tests/agents, ruff, ty, and lefthook.

    Assumptions

    • Agent Bash runs inside the sandbox, so local writes are confined to the worktree and temporary directories (ADR-0035).
    • Codex and other providers harden ask to deny, so fewer asks also means fewer denials there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions