Skip to content

fix(bash): keep auto-approved commands inside the sandbox - #1389

Merged
edenreich merged 1 commit into
mainfrom
fix/bash-allowlist-sandbox
Sep 28, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/bash-allowlist-sandbox

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

The every-mode bash allow-list never looked at the paths a command names:

  • head ~/.aws/credentials read any file without approval.
  • sort -o, tree -o and git diff --output= could overwrite any file.
  • make and task ran whatever the repository's Makefile or Taskfile said.

This follows #1388, which made the sandbox check follow symlinks. Allow-listed commands now go through that same check.

Changes

  • An allow-listed command runs without approval only when every path it names passes ValidatePathInSandbox (ValidatePathInSandboxWrite for mkdir and ln). The check covers:
    • arguments, --flag=value and -Xvalue values, and input redirections (< file)
    • ~, and $VAR expanded from the environment bash inherits
    • every glob match, following bash's hidden-file rule
  • A path that can't be known in advance asks, like any off-list command: ${VAR:-x}, $1, {a,b}, a dot-leading glob, or ~user. echo and printf are not checked, since they never open their arguments.
  • sort -o, tree -o, git --output (and its getopt abbreviations) and uniq's output operand count as file writes, which the guard never auto-approves.
  • make and task leave the baseline. INFER_TOOLS_BASH_ALLOW_APPEND, or a mode's allow-list, adds them back where the repository is trusted.
  • BashCommandRejectionHint is now a nil-safe Config method, so a headless rejection names the offending path. The system prompt tells the model that allow-listed commands only skip approval inside the sandbox.
  • Docs (tools-reference.md, configuration-reference.md) and AGENTS.md describe the path rule.

Behaviour change: headless runs without an approver that call make … or task …, or allow-listed commands on paths outside the sandbox, are now rejected with a hint. In chat, and with an approval broker, they ask.

Testing

  • TestIsBashCommandAllowed_SandboxPaths has 48 cases: paths inside and outside, symlinks, globs, variables, braces, redirections, flag values, write options, and make/task. With the path check disabled, the 22 path cases fail.
  • The existing variable tests now expect ls $HOME to ask, since it expands outside the sandbox. git log $REF and tail $LOGFILE still run.
  • go test ./... and task precommit:run pass.

The every-mode allow-list never looked at the paths a command names, so
head, tail, wc and friends could read any file on disk without approval,
sort -o, tree -o and git --output could overwrite one, and make and task
ran whatever the repository's Makefile or Taskfile said.

- An allow-listed command now runs unattended only when every path it
  names passes the file tools' sandbox check. Arguments, flag values,
  input redirections, ~, $VAR (from the environment bash inherits) and
  glob matches are checked. Anything the check cannot predict, such as
  ${VAR:-x}, {a,b} or a dot-leading glob, asks like any off-list command.
- sort -o, tree -o, git --output and uniq's output operand count as file
  writes, which the guard never auto-approves.
- make and task leave the baseline. INFER_TOOLS_BASH_ALLOW_APPEND or a
  mode's allow-list adds them back where the repository is trusted.

The rejection hint is now a Config method, so it can name the offending
path.
@edenreich
edenreich requested a review from a team as a code owner September 28, 2026 20:04
@edenreich
edenreich merged commit e43f7fb into main Sep 28, 2026
1 check passed
@edenreich
edenreich deleted the fix/bash-allowlist-sandbox branch September 28, 2026 20:16
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.217.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant