Skip to content

Agent can bypass sandbox when combining --sandbox with --dangerously-skip-permissions #36

Description

@danielmewes

Reproduction step:

mkdir /tmp/workspace
cd /tmp/workspace
agy --sandbox --dangerously-skip-permissions -p "Run 'echo test > /tmp/outside_workspace.txt'"
cat /tmp/outside_workspace.txt
Image

What I expect: Due to the sandbox, the agent and any terminal command it runs should be unable to write outside of its workspace.

What actually happens: The initial bash tool call fails, but with a hint to the model to pass bypassSandbox: true. The model then follows this suggestion, and successfully runs the command that writes outside the workspace.

The issue appears to be that --dangerously-skip-permissions does not only auto-approve "regular" permission requests, but also auto-approves the prompt for whether the agent is allowed to bypass the sandbox.

This is very unexpected. With Gemini CLI, it was common to combine --yolo with --sandbox to get the safety of the sandbox, without having to worry about permissions.
Other harnesses, such as Claude Code, also work as expected when combining --dangerously-skip-permissions with their respective sandboxing flags, when configured correctly.

With Antigravity CLI, --dangerously-skip-permissions appears to make --sandbox completely ineffective.

IMO this is a pretty major security issue, since it's quite unexpected and a regression from Gemini CLI (at least it was unexpected to me).

Proposed fix: Disallow bypassSandbox without explicit user confirmation, even when --dangerously-skip-permissions is enabled. In headless mode (-p), never allow bypassSandbox.

Metadata

Metadata

Labels

bugSomething isn't workingcomp:agent capabilitiesBackground Tasks & Subagents, Permissions, SandboxsecurityTo flag token exposure or internal instruction leaks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions