Skip to content
Agents tracked: 504 Releases (7d): 733 Agent status: 1 with issuesSince last limit reset: Claude 12d · Codex 10d For AI agents: Markdown Updated Nov 23, 2026

Coding agent safety: sandboxes, approvals and hooks

What a coding agent can do on your machine without asking depends on three things: whether commands run in a sandbox, which approval mode you are in, and whether you can block actions with your own hooks. Here is how the main agents handle each, from their own documentation (checked Oct 9, 2026).

AgentSandboxOut of the boxHooks
OpenAI Codex built-in
OS-enforced sandbox (Seatbelt on macOS, bwrap+seccomp on Linux, native on Windows): read-only, workspace-write or danger-full-access; no network and writes limited to the workspace by default.
In a git repo: edits and runs commands inside the workspace sandbox and asks for anything beyond it; read-only in untrusted folders. Yes
Cursor built-in
In Auto-review mode shell commands run in an OS sandbox where possible (Seatbelt on macOS, Landlock/Bubblewrap on Linux), with network blocked by default.
Auto-review is the recommended default: allowlisted commands run, others run sandboxed or go to a classifier or an approval prompt. Yes
Google Antigravity built-in
Terminal sandbox (macOS Seatbelt, Linux namespaces) on in the Default preset on macOS and Linux; opt-in on Windows and in the CLI.
In the Default preset, workspace edits and sandboxed commands run without prompting; anything outside needs approval. Yes
OpenHands built-in
Runs the agent in a Docker sandbox by default; a process runtime runs it on the host without isolation.
The CLI asks for confirmation before actions. Yes
Claude Code optional
OS-level Bash sandbox (Seatbelt on macOS, bubblewrap on Linux/WSL2), off by default; turn on with /sandbox or sandbox.enabled. Not available on native Windows.
Asks before file edits and before shell commands, except a built-in set of read-only commands. Yes
GitHub Copilot optional
VS Code's agent terminal sandbox is off by default (chat.agent.sandbox.enabled); Copilot CLI has an opt-in /sandbox; copilot --cloud runs in a remote isolated environment.
Asks before terminal commands except common read-only ones, and before edits to sensitive files. Yes
Gemini CLI optional
Off by default; enable with --sandbox (macOS Seatbelt, Docker/Podman, gVisor or LXC).
Asks before shell commands and file writes. Yes
Goose optional
Opt-in macOS Seatbelt sandbox for Goose Desktop (GOOSE_SANDBOX=true).
Runs freely: Autonomous mode is the default. Yes
OpenCode none
No sandbox documented; a permission limits access to paths outside the working directory.
Runs freely: most permissions default to allow (paths outside the project ask; .env reads are denied). Yes
Cline none
No sandbox documented.
Asks before file edits and commands unless that Auto Approve category is on. Yes
Kiro none
No local sandbox documented; Kiro Web runs each task in an isolated cloud sandbox.
Autopilot edits files without per-step approval; shell commands ask, except allowed read-only commands. Yes
Aider none
No sandbox documented.
Edits files directly and commits each change to git; offers to run the shell commands it suggests. Not documented
Amp none
No local sandbox documented; threads can run in Orbs, remote isolated machines.
Runs freely: Amp does not ask for approval before running tools. Yes

built-in: commands run in an OS sandbox by default · optional: a sandbox you can turn on · none: no sandbox documented, so the agent runs with your permissions. Approval modes and sources are on each agent's page.

A safe default setup

  • Keep approvals on for shell commands until you have seen how the agent behaves in your project; allow-list the read-only commands you run often.
  • Turn on the sandbox where the agent has one, and keep network access off unless a task needs it.
  • Avoid "skip all permissions" or "yolo" modes outside a disposable container or VM.
  • Use a pre-tool hook to block what must never happen (deleting outside the repo, pushing to main, touching secrets).

When it goes wrong anyway: agents gone wrong.

AI coding agent security: how to read this table

AI coding agent security comes down to what the agent can do on your machine without asking. The table above answers that for the main coding agents in three columns, taken from each vendor's documentation and dated at the top of the page:

  • Sandbox: built-in means commands run in an OS-level sandbox by default; optional means a sandbox exists but you have to switch it on; none means no sandbox is documented, so the agent acts with your own user permissions.
  • Out of the box: what the agent does before you change any setting, for example asking before shell commands or running freely.
  • Hooks: whether you can run your own script before a tool call and block it.

Defaults change between releases. Each agent's page, such as Claude Code or OpenAI Codex, lists the approval modes and the official pages they came from, and What's new summarises release notes when a default moves.

Claude Code permissions: modes and allow rules

Claude Code shows how approval settings work in practice. According to its permissions documentation, it has these permission modes:

  • default (Manual): asks on first use of each tool.
  • acceptEdits: accepts file edits and common filesystem commands inside the working directory.
  • plan: reads and explores but does not edit source files.
  • auto: no routine prompts; a background classifier checks actions such as shell commands and network requests.
  • dontAsk: denies anything that would otherwise prompt, unless a rule already allows it.
  • bypassPermissions: skips prompts; the docs say to use it only in containers or VMs.

On top of modes sit allow, ask and deny rules, managed with /permissions or in settings.json. They are evaluated deny first, then ask, then allow, so a deny rule like Bash(rm *) always wins over a narrower allow rule. Answering "Yes, and don't ask again" to a shell command saves a rule for that repository. One point worth remembering for any agent: the docs state that rules are enforced by Claude Code, not by the model, so a line in CLAUDE.md asking the agent to be careful is not a permission setting. Its Bash sandbox is separate from all this and is off by default.

AI agent sandbox vs permissions

Permissions decide whether an action runs. A sandbox limits what a running command can reach: which folders it can write to and whether it can open network connections. The two fail in different ways. After an hour of prompts, people approve things without reading them; a sandbox still holds when that happens. A sandbox, in turn, does nothing about a bad edit inside your project, which is what approvals and code review are for. Where an agent has no local sandbox, running it in a container or VM gives you the same boundary.

Prompt injection and other common pitfalls

  • Untrusted text in context. Issues, pull request comments, web pages, package READMEs and MCP tool output can all carry instructions. Keep network access off unless a task needs it, and deny reads of .env files and other secrets.
  • Too many MCP servers. Each one adds tools the agent can call. Connect only the ones you use and check what each can do.
  • Credentials in the environment. A full-access agent can use any token your shell can. Use scoped, short-lived keys.
  • Merging unread code. Review the diff before it reaches main, and use a pre-tool hook to block pushes to protected branches.

For real incidents, with sources, see agents gone wrong.

Frequently asked questions

Do AI coding agents run commands in a sandbox by default?

Some do and most do not. In the table above, agents marked built-in run commands in an OS sandbox by default, optional means you have to turn the sandbox on, and none means the agent runs with your own user permissions.

What are the Claude Code permission modes?

Claude Code's docs list default (labelled Manual), acceptEdits, plan, auto, dontAsk and bypassPermissions. You switch modes in a session or set defaultMode in a settings file to change how new sessions start.

How do Claude Code allow rules work?

Allow, ask and deny rules are managed with /permissions or in settings.json. They are checked in the order deny, then ask, then allow, so a broad deny rule blocks a call even when a narrower allow rule matches it.

Is it safe to skip all permission prompts in a coding agent?

Only in a disposable container or VM. Claude Code's own docs say to use bypassPermissions only in isolated environments where it cannot cause damage, and the same advice holds for other agents' yolo or full-access modes.

What is prompt injection in an AI coding agent?

It is text the agent reads, such as an issue, a web page or a tool result, that contains instructions the agent then follows. With shell and network access, that can mean running commands or sending secrets you never asked for.

Is a sandbox better than approval prompts?

They do different jobs, so use both where you can. Approvals decide whether an action runs; a sandbox limits what a running command can reach, and it still holds when you approve something you should not have.