threatdeck
Live 13:45 UTC ·

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.

Approval and sandbox controls (vendor documentation, November 2026)
ToolApprovalsOS sandbox
Claude CodeAllow, 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 CodexApproval 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]
CursorTerminal 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].

  1. Disable bypass modes centrally; allow them only in disposable containers.
  2. Put destructive and network commands under deny or ask rules, never broad allow rules.
  3. Turn the sandbox on with failIfUnavailable, and deny reads of ~/.ssh, ~/.aws and similar paths.
  4. Never allowlist interpreters (python, node, bash -c) or commands that execute their arguments.

Try it on ThreatDeck

Self-check

4 questions

Pick an answer to see whether it is right and why. Only your score is saved, in this browser.

  1. Claude Code has an allow rule Bash(aws s3 ls) and a deny rule Bash(aws *). What happens when the agent runs aws s3 ls?
  2. What made CVE-2025-53773 in GitHub Copilot for VS Code possible?
  3. Why is allowlisting grep by prefix risky, as the Gemini CLI research showed?
  4. Why set sandbox.failIfUnavailable in Claude Code?

References

  1. Configure permissions. Anthropic (Claude Code docs).
  2. Sandboxing. Anthropic (Claude Code docs).
  3. Agent approvals & security (Codex). OpenAI.
  4. Agent Security. Cursor docs.
  5. GitHub Copilot: Remote Code Execution via Prompt Injection (CVE-2025-53773). Johann Rehberger (Embrace The Red), 2025-08-12.
  6. Code Execution Through Deception: Gemini AI CLI Hijack. Tracebit, 2025-07-28.
Completing the self-check also marks the lesson complete. Saved in this browser only.

Following

Follow the vendors, products, AI tools, techniques and actors you care about. Matching stories, CVEs and exploited bugs are marked, a Following tab appears in the feed, and returning visits show what changed. Saved only in this browser.

Presets

Get updates

A personal RSS feed of new stories on everything you follow. Paste it into any feed reader, Slack or Teams RSS app.