Autonomous coding agents deliver unprecedented development velocity, but granting an AI agent terminal access presents a critical operational paradox for engineering leadership. If every trivial shell command (git status, npm run build, ls) triggers an interactive confirmation popup, developers quickly suffer from approval fatigue—inevitably training them to click "Approve" blindly without inspecting arguments. Conversely, flipping the agent into unrestricted execution ("YOLO Mode" or "Run Everything") exposes host machines, production credentials, and repositories to catastrophic blast radiuses: accidental directory purges (rm -rf), corrupted local environments, unvetted package execution, or prompt-injected data exfiltration.
At 365Finds, our institutional position is unequivocal: engineering organizations should never permit unrestricted "Run Everything" terminal access on developer workstations, nor should they subject engineers to friction-heavy manual prompt loops. The optimal enterprise posture is Hardened Auto-review backed by OS-level Sandboxing and Git-versioned permission policies.
This guide details the internal mechanics of Cursor's multi-layered terminal security architecture and provides production-ready configuration blueprints for engineering leaders and DevOps architects.
The Threat Model: Why Approval Fatigue Breeds Catastrophe
When Cursor Agent executes terminal tasks—such as resolving compilation errors, running test suites, or scaffolding microservices—it generates and executes raw shell commands against the developer's underlying environment.
Two critical failure modes emerge when organizations rely solely on default human-in-the-loop controls:
[ Traditional Approvals ] --> [ Hundreds of Daily Popups ] --> [ Approval Fatigue ] --> [ Blind Clicks ] --> [ Destructive Execution ]
[ YOLO / Run Everything ] --> [ Zero Human Verification ] --> [ AI Hallucination / Injection ] --> [ Immediate Environment Wipe ]
- The Approval Fatigue Dilemma: A typical multi-file refactoring task may generate 30 to 80 terminal invocations. When 95% of these commands are benign (
cat,pwd,cargo test), engineers develop muscle memory to approve prompts instantly. When an unexpectedrm -rf /or a misdirectedgit reset --hardslips through, the human checkpoint fails completely. - Autonomous Blast Radius: Modern development environments contain high-value targets outside the repository root:
~/.ssh/id_rsa,~/.aws/credentials, system daemons, Docker sockets, and.envfiles with production API keys. Without strict kernel-level sandboxing, a hallucinated command or an indirect prompt injection embedded in third-party library documentation can execute arbitrary scripts, alter parent directories, or establish reverse TCP shells.
To eliminate this vulnerability without crippling developer velocity, Cursor separates terminal execution into three distinct defensive tiers: OS-Level Kernel Sandboxing, Declarative Allowlists/Denylists, and Sub-Agent Semantic Review Classifiers.
Architecture: Cursor's Multi-Tier Terminal Defense
Cursor constructs a defense-in-depth model that enforces boundaries before, during, and after command generation.
| Defensive Layer | Mechanism | Configuration File | Primary Enforcement Goal |
|---|---|---|---|
| Tier 1: OS Kernel Sandbox | OS-level isolation (macOS Seatbelt, Linux Landlock) | sandbox.json | Restricts filesystem write access to workspace root; blocks lateral movement and unauthorized network egress. |
| Tier 2: Declarative Policies | Strict token and command allowlists/denylists | permissions.json / cli-config.json | Pre-approves trusted non-destructive tools; outright forbids blacklisted binaries (e.g., rm, dd). |
| Tier 3: Semantic Auto-Review | Lightweight LLM Classifier Sub-Agent | permissions.json (autoRun) | Parses context and natural language intent to detect masked destructive actions before terminal execution. |
| Tier 4: Enterprise Governance | Centralized administrative override | Team Admin Dashboard | Enforces security baselines across the organization; prevents local overrides. |
[ Incoming Agent Shell Request ]
|
v
+----------------------------+
| Team Admin Policy Check | ---> [ Violates Policy: BLOCKED ]
+----------------------------+
| Passed
v
+----------------------------+
| Tier 2: permissions.json |
| (Allowlist / Denylist) |
+----------------------------+
/ \
In Denylist / Untrusted Explicitly Allowed
/ \
v v
+--------------------------+ +--------------------------+
| Tier 3: Auto-Review | | Tier 1: OS Kernel |
| Sub-Agent Classifier | | Sandbox Execution |
+--------------------------+ +--------------------------+
/ \ |
Safe / Passed Flagged / Risky v
/ \ [ Filesystem & Network ]
v v [ Confined to Repo ]
+-------------------+ +-------------------+
| Sandboxed Exec | | Human Approval |
| (Workspace Only) | | Prompt Triggered |
+-------------------+ +-------------------+
Tier 1: Configuring OS-Level Sandboxing via sandbox.json
Cursor utilizes native operating system isolation primitives—specifically macOS Seatbelt (sandbox-exec) and Linux Landlock LSM—to create an unprivileged sandbox container for agent commands. When sandboxing is active, the agent cannot write outside designated workspace paths even if it hallucinates a malicious bash script.
Configuration Scope and Hierarchy
Cursor resolves sandbox policies across two scopes:
- User Global Scope:
~/.cursor/sandbox.json(applied across all local repositories on the engineer's machine). - Project / Repository Scope:
<workspace>/.cursor/sandbox.json(takes precedence over global settings).
Production-Hardened sandbox.json Blueprint
For engineering teams, the default configuration should be committed directly to version control in .cursor/sandbox.json:
{
"type": "workspace_readwrite",
"readBoundary": "workspace",
"disableTmpWrite": false,
"enableSharedBuildCache": true,
"additionalReadwritePaths": [
"/tmp/cursor-build-artifacts"
],
"additionalReadonlyPaths": [],
"networkPolicy": {
"default": "deny",
"allow": [
"github.com",
"api.github.com",
"registry.npmjs.org",
"registry.yarnpkg.com",
"pypi.org",
"files.pythonhosted.org",
"crates.io",
"static.crates.io"
],
"deny": [
"169.254.169.254",
"*.internal.corp",
"10.0.0.0/8",
"192.168.0.0/16"
]
}
}
Deep Dive: Key Sandbox Parameters
type: Must be set to"workspace_readwrite". This confines read/write operations strictly to the open project folder. Setting this to"workspace_readonly"turns the terminal into a non-mutating inspection tool, while"insecure_none"disables sandboxing entirely (which 365Finds strongly discourages).readBoundary: Setting this to"workspace"(supported in Cursor 3.23+) prevents sandboxed shell processes from traversing parent directories to inspect host configurations (such as reading/etc/passwdor~/.ssh/).networkPolicy.default: "deny": This is the single most critical egress defense. When untrusted agent scripts run (e.g., executing an obscure test runner or third-party build script), outbound traffic is blocked by default.- Explicit Network Whitelisting: Only vetted package registries (npm, PyPI, crates.io) and public version control endpoints are permitted.
- Explicit Metadata Denylist: Explicitly blocking cloud metadata endpoints (
169.254.169.254) prevents the agent from harvesting AWS/GCP instance credentials via SSRF or piped terminal commands.
Tier 2: Declarative Control via permissions.json and CLI Config
While sandbox.json establishes kernel boundaries, permissions.json controls autonomy—defining which commands execute automatically without prompting the engineer.
File Hierarchy and Placement
- Global:
~/.cursor/permissions.json(macOS/Linux) or$env:USERPROFILE\.cursor\permissions.json(Windows). - Repository:
<workspace>/.cursor/permissions.json. - When both exist, arrays are concatenated. When defined in configuration files, corresponding UI toggles in Cursor Settings become read-only, preventing engineers from accidentally weakening policies.
Enterprise permissions.json Configuration
{
"terminalAllowlist": [
"git status",
"git diff",
"git log",
"npm test",
"npm run build",
"npm run lint",
"cargo check",
"cargo test",
"pytest",
"go test ./..."
],
"mcpAllowlist": [
"github:get_*",
"github:list_*"
],
"autoRun": {
"allow_instructions": [
"Standard test suite executions (pytest, cargo test, npm test) within the workspace are permitted automatically.",
"Read-only build artifact inspections under dist/ or target/ are approved.",
"Code formatting commands (prettier, rustfmt, black) may run unattended."
],
"block_instructions": [
"Never execute file deletion commands like rm, rmdir, or unlink unattended.",
"Do not execute git push, git commit, git reset --hard, or git checkout -f without explicit user prompt.",
"Block any command attempting to read, modify, or export .env files or cloud credential directories.",
"Block any database migration, drop table, or schema-altering commands (e.g., prisma migrate, alembic upgrade, flyway).",
"Reject any command invoking package publication (npm publish, cargo publish, twine upload)."
]
}
}
Headless & CLI Execution: cli-config.json
For teams running automated tasks or using the Cursor CLI, permissions are enforced via permissions.allow and permissions.deny tokens:
{
"version": 1,
"permissions": {
"allow": [
"Shell(git status)",
"Shell(cargo test:*)",
"Shell(npm run test:*)",
"Read(src/**)",
"Read(tests/**)",
"Write(src/**)",
"WebFetch(docs.rs)"
],
"deny": [
"Shell(rm:*)",
"Shell(git push:*)",
"Shell(git reset:*)",
"Read(.env*)",
"Write(.env*)",
"Write(.cursor/**)",
"WebFetch(*.internal)"
]
}
}
Tier 3: The Semantic Classifier Sub-Agent (autoRun)
Static command allowlists fail when agents execute composite commands, bash subshells, or pipes. For instance, an allowlist permitting npm might accidentally allow npm run build && rm -rf /.
To solve this, Cursor integrates an Auto-review Classifier Sub-Agent. When a shell command is not strictly matched against a static allowlist, Cursor passes the proposed command and surrounding conversation context to a lightweight classification model.
[ Agent Generates Command ]
|
v
Command: `find . -name "*.tmp" | xargs rm`
|
v
+-------------------------------------------------------+
| Classifier Sub-Agent evaluates against: |
| - permissions.json `autoRun.block_instructions` |
| - Current conversation context & target directory |
+-------------------------------------------------------+
|
+---> Semantic Match: "File deletion command detected"
|
v
[ Classifier Intercepts Command -> Triggers User Confirmation Prompt ]
Crafting Effective Classifier Instructions
The autoRun block accepts natural-language directives. Effective enterprise prompts must be restrictive, unambiguous, and scenario-specific:
- Explicit Destruction Triggers: Clearly name destructive commands (
rm,shred,find ... -delete). - Contextual Credential Protection: Explicitly state that environment variables (
export,printenv) and dot-files (.env,.npmrc,.netrc) require manual approval. - State-Altering VCS Operations: Require approval for any command that mutates remote version control state (
git push) or destroys local uncommitted working tree modifications (git clean -fd,git restore .).
Production Edge Cases & Operational Gotchas
Deploying sandboxing across heterogeneous development teams introduces several real-world operational challenges:
1. Build Cache Locking & Performance Degradation
Strict sandboxing creates ephemeral isolated file environments. If package managers (npm, cargo, pip) redownload dependencies on every sandboxed agent run, execution speeds plummet.
- Remedy: Always set
"enableSharedBuildCache": trueinsandbox.json. This securely mounts shared build caches from the host while preserving filesystem boundaries.
2. Shell Prompt Hangs & ANSI Truncation
Certain custom terminal themes (such as Powerlevel10k or Oh My Zsh) inject complex ANSI escape sequences and subshells to render prompt banners. This can cause the Cursor Agent terminal parser to hang or truncate output.
- Remedy: Configure shell startup profiles (
~/.zshrcor~/.bashrc) to detect Cursor Agent sessions and suppress heavy themes:if [[ -n "$CURSOR_AGENT" ]]; then # Disable heavy theme hooks for Cursor Agent subshells PROMPT='%m %~ %# ' else [[ -r ~/.p10k.zsh ]] && source ~/.p10k.zsh fi
3. Docker-in-Sandbox Restrictions
If an engineering team relies on Docker for testing (e.g., Testcontainers), sandboxed commands will fail when attempting to connect to /var/run/docker.sock.
- Remedy: Add the socket path to
additionalReadwritePathsinsandbox.json:"additionalReadwritePaths": [ "/var/run/docker.sock" ]
365Finds Institutional Evaluation & Recommendations
| Operating Posture | Velocity Score | Security Score | Friction Rating | 365Finds Verdict |
|---|---|---|---|---|
| Run Everything (YOLO Mode) | 10 / 10 | 1 / 10 | 0 / 10 | Unacceptable for enterprise use. High risk of irreversible data loss, key leakage, or compromised host integrity. |
| Manual Prompt Everything | 3 / 10 | 4 / 10 | 10 / 10 | Counterproductive. Approval fatigue inevitably leads to blind approvals, creating a false illusion of security. |
| Hardened Auto-review + OS Sandbox | 9 / 10 | 9.5 / 10 | 2 / 10 | Recommended Standard. Routine commands execute silently inside OS kernel cages; destructive commands are caught deterministically. |
Enterprise Implementation Checklist
- Mandate Repository Baselines: Check in
.cursor/sandbox.jsonand.cursor/permissions.jsonto the root of all central repositories. Standardize allowlists across frontend, backend, and platform repositories. - Lock Team Admin Controls: In the Cursor Team Admin Dashboard, enforce that sandbox settings cannot be overridden by user-level
insecure_nonedeclarations. - Enforce Egress Boundaries: Maintain
networkPolicy.default: "deny"and only whitelist approved corporate artifact registries and documentation mirrors. - Iterate Classifier Guidance: Periodically review intercepted terminal commands and refine
autoRun.block_instructionsto account for new CLI tools introduced into the engineering stack.
By combining OS-level isolation primitives with intelligent sub-agent classification, engineering organizations can unlock the full autonomous potential of Cursor Agent without exposing developer environments to catastrophic operational risks.