
TL;DR
How Claude Code, Cursor, Codex, GitHub Copilot, Aider, and Windsurf handle permissions, sandboxing, credential protection, and prompt injection. A structured comparison for engineering teams evaluating agent security.
Direct answer
How Claude Code, Cursor, Codex, GitHub Copilot, Aider, and Windsurf handle permissions, sandboxing, credential protection, and prompt injection. A structured comparison for engineering teams evaluating agent security.
Best for
Developers comparing real tool tradeoffs before choosing a stack.
Covers
Verdict, tradeoffs, pricing signals, workflow fit, and related alternatives.
Every AI coding agent has a different answer to the same hard question: how much access should an LLM-driven process have to your filesystem, network, and credentials?
The answer determines whether your team uses these tools safely or treats each agent session as a trust exercise. As coding agents become more autonomous with auto-mode, background execution, and headless CI integration, the security model is no longer a footnote - it is the deciding factor for production use.
This guide compares the security architecture of six major coding agents: Claude Code, Cursor, Codex (OpenAI), GitHub Copilot, Aider, and Windsurf. Each takes a fundamentally different approach to permissions, sandboxing, and credential management.
| Tool | Security Docs |
|---|---|
| Claude Code | docs.anthropic.com/en/docs/claude-code/security |
| Claude Code Permissions | docs.anthropic.com/en/docs/claude-code/permissions |
| Claude Code Sandboxing | docs.anthropic.com/en/docs/claude-code/sandboxing |
| Cursor Security | docs.cursor.com/get-started/security |
| OpenAI Codex Docs | platform.openai.com/docs/codex |
| GitHub Copilot Security | docs.github.com/en/copilot |
All links verified July 28, 2026.
Agent security models sit on a spectrum from "trust the user to review every action" to "enforce boundaries at the OS level." Every tool is moving toward more granular, enforceable controls, but they started from different places and the details matter.
| Security Feature | Claude Code | Cursor | Codex | Copilot | Aider | Windsurf |
|---|---|---|---|---|---|---|
| Read-only mode | Yes (Plan mode) | Yes (Agent plan first) | N/A (sandboxed) | No | No (manual review) | Yes (Cascade flow) |
| Granular file permissions | Yes (gitignore patterns) | Limited | Via sandbox | No | No | No |
| Network access control | Yes (sandbox proxy) | No | Full isolation | No | No | No |
| Credential masking | Yes (sandbox credentials) | No | No | No | No | No |
| Prompt injection detection | Yes | Unknown | Unknown | Unknown | No | Unknown |
| Auto-approve mode | Yes (auto, acceptEdits) | Yes (Agent mode) | N/A (cloud) | Yes (Agent mode) | Yes (--yes) | Yes |
| Bash sandboxing | Yes (bubblewrap/Seatbelt) | No | N/A (cloud) | No | No | No |
| MCP permission controls | Yes (per-server rules) | Yes | N/A | N/A | N/A | No |
Claude Code has the most developed security architecture of any local coding agent, with three independent layers that compose together.
Layer 1: Permission modes. Claude Code supports five modes that control how tool calls are approved: default (prompt on first use), acceptEdits (auto-approve file edits and common filesystem commands), plan (read-only exploration), auto (classifier-approved actions), and bypassPermissions (skip prompts - designed for containers and VMs only). Each mode serves a different workflow, and you can switch between them per session.
Layer 2: Permission rules. Claude Code's rule system supports allow, ask, and deny rules with gitignore-style path patterns, Bash command wildcards, WebFetch domain restrictions, MCP server-scoped rules, and Agent subagent rules. Rules are evaluated in order: deny, then ask, then allow. A deny rule for a tool name removes it from the model's context entirely - the model never sees the tool exists. Rules can be scoped to user settings, project settings, or managed settings (organizational, non-overridable).
Layer 3: OS-level sandboxing. The Bash sandbox uses bubblewrap on Linux and Seatbelt on macOS to enforce filesystem and network isolation at the operating system level. Within the sandbox, commands can write only to the working directory and session temp directory by default. Network access is restricted to a configurable allowlist, with a proxy that handles domain resolution and optional TLS termination. This is the only tool in the comparison that enforces boundaries at the OS process level, meaning restrictions hold even if the model is compromised.
Credential protection. Claude Code's sandbox.credentials setting lets you declare credential files and environment variables with two modes: deny (block the sandbox from reading or seeing them) and mask (inject a session-scoped sentinel that the sandbox proxy replaces with the real value only on authenticated requests to approved hosts).
Managed settings for organizations. Administrators can deploy non-overridable policies through managed settings, enforcing sandboxing, restricting permission modes, and locking network access to approved domains. Key controls include allowManagedPermissionRulesOnly, allowManagedDomainsOnly, and allowManagedReadPathsOnly to prevent developers from widening security policy.
The complexity of Claude Code's system is a tradeoff: it offers the most fine-grained control, but configuring it well requires understanding a multi-layered permission model. Teams that invest in setup get production-grade isolation.
Cursor's security model is built around its IDE-native architecture. As a VS Code fork, it inherits the editor's process model and extends it with agent controls.
Permissions. Cursor supports a rule system where you can define project-level rules for what the agent can access. Rules are stored in .cursorrules and can specify allowed directories, file patterns, and commands. However, the rule system is advisory rather than enforced at the OS level - it guides what the model attempts but does not prevent it from attempting restricted operations.
Agent modes. Cursor offers a "plan first" mode where the agent describes its approach before executing changes, similar to Claude Code's plan mode. The full agent mode performs multi-file edits autonomously. In practice, Cursor's security relies heavily on the user reviewing inline diffs before accepting changes - a visual workflow that works well for incremental edits but less well for autonomous multi-step tasks.
Network access. Cursor does not provide built-in network sandboxing or domain restrictions. The agent can make network requests (for fetching dependencies, hitting APIs, or browsing documentation) subject to standard OS network access. There is no proxy or allowlist mechanism.
MCP controls. Cursor supports MCP servers with per-server configuration, but the permission granularity is less developed than Claude Code's per-tool MCP rules. MCP servers in Cursor run with the same access as the editor process.
Cursor's security model is appropriate for developers who work interactively and review every change visually. It is less suited for unattended or CI/CD agent execution where automated enforcement boundaries are needed.
Newsletter
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools, delivered free every week.
From the archive
Jul 28, 2026 • 8 min read
Jul 28, 2026 • 7 min read
Jul 28, 2026 • 8 min read
Jul 28, 2026 • 9 min read
Codex takes the opposite approach from local agents: every task runs in an isolated cloud sandbox. The security model is defined by the sandbox architecture rather than local permission rules.
Execution model. Codex clones your repository into an ephemeral container, executes the task, and delivers results as a PR or diff. The agent cannot access your local filesystem, your running services, or your credentials (beyond what the sandbox is explicitly configured with). This eliminates local execution risk entirely.
Network isolation. Codex sandboxes are network-isolated during execution - the agent cannot fetch live documentation, hit external APIs, or send data to external servers. This is both a security strength and a practical limitation: tasks that require live API access or real-time web research cannot run in Codex's default sandbox.
Credential model. Codex authenticates through GitHub's OAuth integration and does not have access to your local credentials, SSH keys, or environment variables. Codex uses its own scoped tokens for git operations.
CI/CD fit. The cloud sandbox model makes Codex the most natural fit for headless CI/CD integration among the tools compared. There is no local agent process to manage, no permission prompts to bypass, and no desktop dependency.
The tradeoff is that Codex cannot handle tasks requiring local database access, local services, or long-running interactive development. It is designed for delegatable, well-scoped tasks where the sandbox constraints are not limiting.
GitHub Copilot's security model relies on the GitHub platform's existing trust boundaries rather than OS-level isolation.
Permissions. Copilot's agent mode (added in mid-2026) runs in your editor with the same permissions as your IDE process. There is no granular file permission system - Copilot can access any file your editor can open. Session spend limits (AI credits per session) control cost but not access scope.
Data handling. Copilot's key differentiator is IP indemnity at the Business and Enterprise tiers - GitHub assumes legal liability for copyright claims against generated code. This is a legal security model rather than a technical one, and it makes Copilot the default choice for enterprises concerned about code generation liability.
Network and credentials. Copilot does not sandbox network access or credential access. It runs in-process with your editor, inheriting all of its access rights. The model relies on the user's judgment to approve or reject generated code and commands.
Enterprise controls. Enterprise and Business tiers add organization-wide policy management, audit logging, and the option to disable public code matching. These controls manage risk at the organizational policy level rather than the process isolation level.
Copilot's model is appropriate for teams that prioritize legal protection over technical isolation, and for developers who work within GitHub's ecosystem where the platform's trust model is sufficient.
Aider's security model is the simplest in the comparison: there is no sandbox, no permission system, and no network controls. Aider runs commands with your shell's full privileges.
The trust model. Aider assumes you review every proposed change before accepting it. The --yes flag bypasses confirmation prompts for automated use, but this removes the only built-in approval gate. There is no intermediate permission layer between the model's decision and the execution.
Git safety net. Aider's primary safety mechanism is git integration. Every AI-generated change is committed with a descriptive message, and git undo provides a rollback path. This is a recovery mechanism, not a prevention mechanism - it helps after a mistake but does not prevent one.
Model flexibility, your risk. Because Aider is model-agnostic, the security characteristics depend on which model you connect. A local model via Ollama keeps all data on your machine. A cloud API model sends your code to an external provider. Aider itself offers no data handling guarantees.
Best suited for. Budget-conscious developers and privacy-first teams who run local models via Ollama. Aider's simplicity means zero configuration overhead, but it places full responsibility on the user to review every change. For production environments or teams, it requires pairing with external sandboxing (containers, VMs).
Windsurf's Cascade flow system provides a structured execution model that offers some security benefits by design, though granular controls are limited.
Sequential execution. Cascade breaks tasks into sequential steps - read files, edit code, run commands, check results. This step-by-step structure means the user sees what the agent plans before commands execute. The sequential model is inherently more auditable than parallel execution.
Permissions. Windsurf does not provide granular file or command permissions comparable to Claude Code's rule system. The agent runs with the IDE process's full access rights. The free tier of codeium provides session-level controls but not path-level or command-level enforcement.
Network and credentials. Windsurf does not sandbox network access or provide credential protection. Like Cursor and Copilot, it runs in-process with the editor.
Windsurf's security model is appropriate for developers who work interactively with Cascade's step-by-step flow. The structured execution provides auditing benefits, but the lack of granular enforcement makes it less suitable for unattended or high-security deployments.
The right security model depends on your threat profile. Here is how each tool maps to common threat scenarios:
| Threat | Claude Code | Cursor | Codex | Copilot | Aider | Windsurf |
|---|---|---|---|---|---|---|
| Malicious code execution | OS sandbox blocks | User reviews diffs | Cloud isolation prevents | User reviews diffs | User reviews diffs | User reviews diffs |
| Credential exfiltration | Credential masking + deny rules | No protection | Sandbox isolates | No protection | No protection | No protection |
| Prompt injection | Detection + multi-layer permissions | Limited detection | Sandbox limits blast | Unknown | No protection | Unknown |
| Data exfiltration via network | Sandbox proxy + domain allowlist | No network controls | Network isolation blocks | No network controls | No network controls | No network controls |
| Hostile MCP server | Per-tool deny rules, scope control | Server-level control | N/A | N/A | N/A | No controls |
| Unauthorized file writes | Mode + path rules + sandbox | User reviews diffs | Sandbox prevents | User reviews diffs | User reviews | User reviews |
| Insider threat (malicious model) | Sandbox restricts regardless | None beyond review | None beyond sandbox | None beyond review | None | None |
Solo developer, terminal-native workflow. Use Claude Code with default permission mode and enable the Bash sandbox. This gives you granular control over file access and network domains without adding friction to daily work. The sandbox auto-allow mode handles routine commands, and permission rules block the few things you want to protect (SSH keys, .env files).
Team in an IDE-heavy workflow. Use Cursor with plan-first mode and enforce project-level rules through .cursorrules. Pair with the upcoming Cursor session spend limits for cost control. The visual diff workflow is the strongest safety mechanism for teams that iterate rapidly.
Enterprise with compliance requirements. Use Claude Code with managed settings to enforce sandboxing, restrict auto-mode usage, and credential masking. Pair with Codex for async CI/CD tasks that benefit from cloud sandbox isolation. Use Copilot for developers who need IP indemnity and work in JetBrains or Neovim.
Budget-conscious, privacy-first team. Use Aider with local models via Ollama. The data never leaves your machine. Pair with Docker containers for sandboxing. This combination gives you privacy and isolation at the cost of configuration overhead and reduced model capability.
CI/CD and automation pipeline. Use Codex for GitHub-integrated async task execution where sandbox isolation is a benefit, not a limitation. Use Claude Code in auto mode with sandboxing for terminal-based automation scripts and scheduled tasks.
Claude Code has the most comprehensive security architecture with three independent layers: permission modes, granular allow/deny/ask rules, and OS-level sandboxing with filesystem and network isolation via bubblewrap or Seatbelt. It is the only tool that offers credential masking and managed organizational policies. However, "most secure" depends on your threat model - Codex's cloud sandbox model eliminates local execution risk entirely, which may be preferable for some use cases.
No. Cursor does not provide OS-level sandboxing for agent command execution. Its security model relies on user review of inline diffs and project-level rules stored in .cursorrules. The agent runs with the same permissions as the VS Code process.
Yes, with proper configuration. Enable the Bash sandbox, restrict network access to approved domains, use credential masking or deny rules for SSH keys and .env files, and run in auto mode with the classifier reviewing actions. For the most sensitive codebases, use dev containers or VMs in addition to the built-in sandbox. See Anthropic's security documentation for detailed guidance.
Claude Code includes built-in prompt injection detection that analyzes requests for potentially harmful instructions. It also runs sensitive operations through separate context windows and uses a permission system that blocks tool calls regardless of the model's intent. Other tools offer varying levels of detection - most rely primarily on user review of proposed changes as the prompt injection defense.
Claude Code supports managed settings that administrators deploy through MDM or server-managed settings. These policies cannot be overridden by individual developers and can enforce sandboxing, restrict permission modes, lock network domains, and block dangerous commands. Copilot offers organization-level policy management through GitHub's admin console. Other tools in this comparison do not offer managed policy enforcement.
Codex benefits from cloud sandbox isolation - the agent runs in an ephemeral container with no access to your local system. Claude Code with sandboxing enabled and --dangerously-skip-permissions (in a container only) is the terminal-native alternative, though it requires more configuration to match Codex's isolation guarantees.
Aider has no sandbox, no permission system, and no network controls. Its primary safety mechanism is git integration: every AI change is committed with a descriptive message, and you can roll back any edit with git undo. Aider is best used with external sandboxing (Docker, VMs) for production or team environments.
Yes. A common pattern is to use Claude Code with sandboxing for interactive development, Codex for CI/CD tasks where cloud isolation is beneficial, and a tool-specific firewall (like Belay or Snapshield) for monitoring agent behavior across all tools. See the agent firewalls comparison for external monitoring options.
Read next
Belay, Claude Code built-in guards, Codex CLI sandboxing, and MCP proxy patterns compared - how to protect your system from destructive commands, secret leaks, and prompt injection in AI coding agents.
9 min readA builder's guide to picking a code-execution sandbox for AI agents - E2B, Daytona, Modal, Cloudflare Sandbox, and Vercel Sandbox compared on isolation, latency, state, and pricing model.
7 min readA practical comparison of the four authentication platforms developers reach for when connecting AI agents to third-party APIs: Arcade, Composio, Nango, and Stytch. OAuth 2.1, MCP support, integration counts, and which to pick by workload.
8 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Mac app for running parallel Claude Code, Codex, and Cursor agents in isolated workspaces. Watch every agent work at onc...
View ToolOpenAI's open-source terminal coding agent built in Rust. Runs locally, reads your repo, edits files, and executes comma...
View ToolA hosted infinite canvas your headless AI agents drive over MCP. Any MCP-speaking agent - Claude Code, Codex, Cursor, or...
View ToolOpen-source terminal agent runtime with approval modes, rollback snapshots, MCP servers, LSP diagnostics, and a headless...
View ToolEvery coding agent in one window. Stop alt-tabbing between Claude, Codex, and Cursor.
View AppScore every coding agent on your own tasks. Catch regressions in CI.
View AppCompare AI coding agents on reproducible tasks with scored, shareable runs.
View AppDeep comparison of the top AI agent frameworks - LangGraph, CrewAI, Mastra, CopilotKit, AutoGen, and Claude Code.
AI AgentsSet up Codex Chronicle on macOS, manage permissions, and understand privacy, security, and troubleshooting.
Getting StartedA complete, citation-backed Claude Code course with setup, prompting systems, MCP, CI, security, cost controls, and capstone workflows.
ai-development
Check out Zed here! https://zed.dev In this video, we dive into Zed, a robust open source code editor that has recently introduced the Agent Client Protocol. This new open standard allows...

In this episode, we explore the newly released GPT-5 Codex by OpenAI, a specialized version of GPT-5 designed for agentic coding tasks. Codex offers advanced features, including enhanced code...

Exploring Codex: AI Coding in Terminal In this video, I explore Codex, a new lightweight CLI tool for AI coding that runs in the terminal. This tool, possibly a response to Anthropic's CLI,...

Belay, Claude Code built-in guards, Codex CLI sandboxing, and MCP proxy patterns compared - how to protect your system f...

A builder's guide to picking a code-execution sandbox for AI agents - E2B, Daytona, Modal, Cloudflare Sandbox, and Verce...

A practical comparison of the four authentication platforms developers reach for when connecting AI agents to third-part...

Terminal agent, IDE agent, local-plus-cloud agent. Three architectures compared - how to decide which fits your workflow...

Complete pricing breakdown for every major AI coding tool. Claude Code, Cursor, Copilot, Windsurf, Codex, Augment, and m...

Prompt injection, sandbox escapes, and hallucinated dependencies are now documented, patched, CVE-numbered realities. He...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.