Learn / Securing AI coding assistants in an organisation
Lesson 2 of 610 minReviewed
Permissions, approval modes and sandboxing
Compare the approval and sandbox controls in Claude Code, Codex and Cursor, and learn from two real bypasses why approvals alone do not contain an agent.
Every coding agent decides, per action, whether to run it, ask the developer, or refuse. Approval prompts are the first control most teams rely on, which makes them the first thing an attacker who controls the agent's input tries to get around.
| Tool | Approvals | OS sandbox |
|---|---|---|
| Claude Code | Allow, ask and deny rules; modes default, acceptEdits, plan, auto, dontAsk, bypassPermissions [1] | Off by default; Seatbelt on macOS, bubblewrap on Linux and WSL2 [2] |
| OpenAI Codex | Approval policies on-request and never, plus a granular policy [3] | Modes read-only, workspace-write, danger-full-access; network off by default in workspace-write [3] |
| Cursor | Terminal commands need approval by default; Run Modes range from an allowlist to an auto-review classifier [4] | Not described on the agent security page [4] |
How Claude Code rules combine
Rules are evaluated deny first, then ask, then allow, and the first match wins regardless of specificity. A deny rule for Bash(aws *) blocks aws s3 ls even if a narrower allow rule names it; an allow rule cannot carve an exception out of a deny [1]. Write the dangerous patterns as deny or ask rules and keep allow rules for specific, low-risk commands.
bypassPermissions skips prompts, including for writes to protected paths such as .git and .claude, and the documentation says to use it only in isolated containers or VMs. Setting permissions.disableBypassPermissionsMode to "disable" prevents the mode, and is most useful in managed settings where users cannot override it [1]. Codex has an equivalent switch: --yolo, an alias of --dangerously-bypass-approvals-and-sandbox, removes both approvals and the sandbox [3].
Two ways approvals have failed
The agent edits its own policy. In CVE-2025-53773, a prompt injection could get GitHub Copilot in VS Code to write "chat.tools.autoApprove": true into .vscode/settings.json, which turned off confirmations and let it run shell commands; Microsoft fixed it in the August 2025 Patch Tuesday release [5]. Files that govern approvals must themselves need approval. Cursor now requires approval before the agent edits configuration files [4], and Claude Code prompts for writes to .claude and .git in every mode except bypass [1].
Prefix allowlists. Tracebit showed that Gemini CLI matched allowlisted commands too loosely: once a user approved grep, a command that started with grep and chained a second command ran without a prompt, and padding with whitespace hid the rest from the display. The instructions arrived in a repository README. Google fixed it in v0.1.14 on 25 July 2025 [6]. Allowlisting an interpreter or a command that accepts arbitrary arguments is effectively allowlisting everything.
What a sandbox adds, and what it does not
Claude Code's sandbox limits writes to the working directory, a temp directory and directories you add, and sends network traffic through a local proxy whose allowed-domain list starts empty. Reads stay broad by default, so credential directories need explicit deny entries or sandbox.credentials. Without sandbox.failIfUnavailable, Claude Code runs commands unsandboxed when the platform cannot start the sandbox [2].
- Disable bypass modes centrally; allow them only in disposable containers.
- Put destructive and network commands under deny or ask rules, never broad allow rules.
- Turn the sandbox on with
failIfUnavailable, and deny reads of~/.ssh,~/.awsand similar paths. - Never allowlist interpreters (
python,node,bash -c) or commands that execute their arguments.
Try it on ThreatDeck
- Claude Code hardening generator Generate a settings file with deny rules, bypass disabled and the sandbox enforced.
- Detection: AI CLI started with a bypass flag Find sessions launched with `--dangerously-skip-permissions`, `--yolo` and similar flags.
- Detection: bypassPermissions sessions Use Claude Code telemetry to spot sessions running with prompts disabled.
- nono on the radar A kernel-enforced sandbox for limiting what a coding agent can read, write and reach.
Self-check
4 questionsPick an answer to see whether it is right and why. Only your score is saved, in this browser.
-
Claude Code evaluates deny, then ask, then allow, and the first match decides. Specificity does not change the order, so the broad deny blocks the call.
-
Injected instructions got the agent to set
chat.tools.autoApprovein.vscode/settings.json, disabling confirmations. The general lesson: files that control approvals must not be editable without approval. -
Loose matching treated the whole command line as approved because it began with
grep, so a chained command ran too. Approvals must parse the full command, and interpreters should never be allowlisted. -
The sandbox is a containment layer you are counting on. Failing closed means a missing dependency stops the session instead of silently removing the boundary.
References
- Configure permissions. Anthropic (Claude Code docs).
- Sandboxing. Anthropic (Claude Code docs).
- Agent approvals & security (Codex). OpenAI.
- Agent Security. Cursor docs.
- GitHub Copilot: Remote Code Execution via Prompt Injection (CVE-2025-53773). Johann Rehberger (Embrace The Red), 2025-08-12.
- Code Execution Through Deception: Gemini AI CLI Hijack. Tracebit, 2025-07-28.