Software engineers who rely on Cursor Agent face a sharp operational dilemma: manual confirmation prompts for every terminal command shatter developer focus during iterative test-and-build loops, yet granting unconstrained shell access risks destructive commands like rm -rf, accidental cloud infrastructure alterations, or sensitive token exfiltration.
At 365Finds, our research judgment is unambiguous: never rely on pure manual confirmation ("Ask Every Time"), and never run autonomous terminal agents unconstrained ("Run Everything"). The only commercially viable, production-grade configuration is combining Cursor's native Auto-review run mode with repo-level, version-controlled .cursor/cli.json, permissions.json, and sandbox.json policy manifests. This defense-in-depth model eliminates prompt fatigue while confining shell execution to strict OS kernel boundaries.
This guide provides software engineering teams and DevOps architects with an exhaustive, step-by-step blueprint for configuring Cursor's execution permissions, allowlist/denylist rules, and kernel-level sandboxing.
1. Cursor Terminal Run Modes: The Three Autonomy Tiers
Cursor controls agent execution permissions within the desktop application under Settings > Agents > Approvals & Execution (or Settings > Cursor Settings > Agents > Approvals & Execution).
Cursor provides three operational Run Modes governing shell commands, Model Context Protocol (MCP) tools, and Fetch requests:
| Run Mode | Auto-Run Scope | Sandboxing Enforcement | LLM Classifier Review | 365Finds Evaluation |
|---|---|---|---|---|
| Auto-review (Recommended) | Allowlisted calls run immediately; supported shell commands run inside the sandbox. | Enforced automatically for compatible shell commands. | Yes; uncontained or escalated calls route to a backend classifier. | Top Institutional Choice. Delivers frictionless autonomous loops while catching high-risk actions. |
| Allowlist | Explicitly pre-approved commands execute without prompts. | Optional for shell commands. | No; unlisted commands require human approval. | Best for Rigid Pipelines. High deterministic safety; legacy "Ask Every Time" is replicated using an empty allowlist. |
| Run Everything (YOLO) | Every single tool and shell command executes automatically. | Disabled. | None. | Unacceptable Risk. Avoid in commercial environments, shared codebases, or machines with live credentials. |
How Auto-Review Operates
Auto-review operates as a multi-stage execution funnel:
- Allowlist Bypass: If a command matches an explicit allowlist pattern, it executes immediately.
- Sandbox Containment: If the command is not on the allowlist but conforms to sandbox filesystem and network constraints (e.g., standard compilation, local linting, running unit tests), Cursor isolates it inside an OS-level sandbox.
- Classifier Subagent Evaluation: Commands that cannot run within the sandbox—such as commands demanding outbound external network access outside defaults or writes outside the project workspace—are routed to a fast Cursor backend classifier model (primarily Gemini 3.5 Flash Lite, falling back to Claude 4.5 Haiku).
- Autonomous Alternative or Human Gate: If the classifier approves the intent, it executes outside the sandbox; if the classifier flags risk, the agent either seeks an alternative non-destructive path or presents an explicit visual approval card to the developer.
365Finds Take: In Cursor v3.5, the legacy "Ask Every Time" toggle was deprecated. If your organization requires absolute zero-trust manual prompting for every terminal interaction, select Allowlist mode with an empty allowlist array. However, for 95% of engineering workflows,
Auto-reviewdelivers the optimal speed-to-safety ratio.
2. Granular Allow and Deny Rules: cli.json & permissions.json
Fine-grained command permissions can be declared deterministically using JSON manifests.
Configuration Scopes and Locations
Cursor inspects configuration files across two tiers:
- Global / User Scope:
~/.cursor/cli-config.json(macOS/Linux) or%USERPROFILE%\.cursor\cli-config.json(Windows). Governs default machine-wide behaviors. - Repository / Workspace Scope:
<project-dir>/.cursor/cli.jsonor<project-dir>/.cursor/permissions.json. Versioned inside Git to enforce unified security baselines across development teams.
When both exist, project configurations merge with user configurations, while enterprise organization policies set via the Cursor admin dashboard take absolute precedence.
The Permission Token Grammar
Within <project-dir>/.cursor/cli.json, define permissions using explicit capability tokens:
Shell(commandBase): Matches the root binary of a shell invocation (e.g.,Shell(git),Shell(npm),Shell(cargo)). Supports glob arguments such asShell(git:*)orShell(pytest).Read(pathOrGlob): Governs file and directory read permissions (e.g.,Read(src/**)).Write(pathOrGlob): Controls file creation and modification boundaries (e.g.,Write(src/**),Write(dist/**)).WebFetch(domainPattern): Governs permitted outbound HTTP/HTTPS domains for web query tools.
Production Rule Manifest: <project-dir>/.cursor/cli.json
The deny array always takes precedence over allow. To protect your repository against destructive actions, commit the following template:
{
"version": 1,
"permissions": {
"allow": [
"Shell(git status)",
"Shell(git diff)",
"Shell(git branch)",
"Shell(git log)",
"Shell(npm test)",
"Shell(npm run lint)",
"Shell(npm run build)",
"Shell(pnpm test)",
"Shell(cargo check)",
"Shell(cargo test)",
"Shell(pytest)",
"Read(src/**)",
"Read(tests/**)",
"Write(src/**)",
"Write(tests/**)"
],
"deny": [
"Shell(rm)",
"Shell(rmdir)",
"Shell(sudo)",
"Shell(dd)",
"Shell(mkfs)",
"Shell(chmod)",
"Shell(chown)",
"Shell(curl)",
"Shell(wget)",
"Shell(kubectl)",
"Shell(terraform)",
"Read(.env*)",
"Read(~/.ssh/**)",
"Read(~/.aws/**)",
"Write(.env*)",
"Write(.git/**)",
"Write(~/.ssh/**)"
]
}
}
Natural Language Classifier Guidance: <project-dir>/.cursor/permissions.json
When using Auto-review, you can steer the backend classifier subagent by providing explicit natural language policies in .cursor/permissions.json:
{
"autoRun": {
"allow_instructions": [
"Allow routine test suites, type checking, and local development builds within the repository.",
"Allow reading non-sensitive source files and project documentation."
],
"block_instructions": [
"Every AWS CLI, gcloud, or Azure CLI command must pause for human approval.",
"Every command modifying Kubernetes clusters or Docker daemon configurations must pause for approval.",
"Any file deletion command (such as rm or git reset --hard) must prompt for approval.",
"Any command modifying files outside the workspace directory must pause for approval."
]
}
}
3. Kernel-Level Isolation: How Cursor Sandboxing Works
Sandboxing is Cursor's physical security barrier. Even if an agent constructs an unintended command, the sandbox isolates the subprocess tree directly at the operating system kernel level.
Platform Isolation Mechanisms
-
macOS Architecture:
- Powered by Apple's kernel Seatbelt sandbox framework through
sandbox-exec. - Cursor dynamically compiles a sandbox profile that restricts file access, process forks, and network capabilities across the entire child process hierarchy.
- Available natively in Cursor v2.0+ without supplementary dependencies.
- Powered by Apple's kernel Seatbelt sandbox framework through
-
Linux Architecture:
- Powered by Landlock v3 (
CONFIG_SECURITY_LANDLOCK=yon Linux Kernel 6.2+) for filesystem sandboxing, combined with seccomp for blocking privileged or dangerous system calls. - Requires unprivileged user namespaces enabled.
- Falls back to Bubblewrap if native Landlock kernel features are unavailable.
- In containerized, remote SSH, or headless CLI environments on Ubuntu/Debian, install the
cursor-sandbox-apparmorpackage if user namespace restrictions are enforced.
- Powered by Landlock v3 (
Workspace vs. System Read Access (Cursor 3.23+)
Under Settings > Agents > Approvals & Execution > Read Access, engineers can toggle read boundaries:
- System (Default): The agent reads files outside the workspace without approval.
- Workspace (365Finds Recommended): Constrains agent file reads, grep searches, and sandboxed commands strictly to the workspace directory,
~/.cursor/projects, and/tmp. Reading external directories requires explicit developer confirmation unless declared on the Read Allowlist.
Configuring Network and Filesystem in .cursor/sandbox.json
To customize sandbox containment per repository, create <project-dir>/.cursor/sandbox.json:
{
"readBoundary": "workspace",
"additionalReadonlyPaths": [
"/opt/shared-design-tokens",
"~/company-shared-docs"
],
"additionalReadwritePaths": [
"/tmp/project-build-cache"
],
"disableTmpWrite": false,
"networkPolicy": {
"mode": "sandbox.json + Defaults",
"allow": [
"internal-npm-registry.company.net",
"artifacts.internal.net"
]
}
}
Network Access Modes in Sandbox:
sandbox.json Only: Terminal commands inside the sandbox can only contact domains explicitly listed insandbox.json.sandbox.json + Defaults(Default): Permits user-defined domains plus Cursor's built-in allowlist of trusted package registries (includingregistry.npmjs.org,pypi.org,crates.io,rubygems.org,maven.org,github.com, anddocker.io).Allow All: Disables network filtering within the sandbox. (Not recommended).
Additional Built-In Guardrails
Cursor integrates built-in safety triggers that enforce human approval even in permissive modes:
- File-Deletion Protection: Automatically blocks shell commands invoking file removals (such as
rm). - External-File Protection: Intercepts attempts to write, create, or alter files located outside the active workspace.
- Browser Protection: Prompts before allowing automated web-agent interactions.
4. The Linux UID Remapping Pitfall and Container Automation
A critical engineering gotcha occurs on Linux systems: Cursor's sandbox creates a private user namespace and remaps the subprocess to UID 0 (root) inside that namespace.
As a result:
- Running
id -uor evaluating$UIDinside a sandboxed command returns0rather than the host developer's actual UID. - If an agent command invokes Docker (e.g.,
docker run -v $PWD:/work ...), files generated inside the container may be written as hostroot, corrupting repository file permissions.
Solution: Injected Sandbox Environment Variables
Cursor injects diagnostic and identity variables into every sandboxed child process:
| Environment Variable | Target Platform | Description |
|---|---|---|
CURSOR_SANDBOX | macOS, Linux | Set to "seatbelt" on macOS or "native" on Linux when sandboxed. |
CURSOR_ORIG_UID | macOS, Linux | Captures the authentic host UID of the engineer prior to namespace remapping. |
CURSOR_ORIG_GID | macOS, Linux | Captures the authentic host GID of the engineer prior to namespace remapping. |
CURSOR_SANDBOX_LANDLOCK_STATUS | Linux | Returns "fully_enforced" (Landlock) or "bubblewrap". |
Battle-Tested Docker Invocation Pattern
When writing automation scripts or instructing the agent to run containerized builds, employ the fallback syntax to support both sandboxed and host environments:
docker run --rm \
--user "${CURSOR_ORIG_UID:-$(id -u)}:${CURSOR_ORIG_GID:-$(id -g)}" \
-v "$PWD:/work" -w /work \
builder-image:latest npm run build
This ensures containerized toolchains create files matching the engineer's real workstation ownership regardless of whether sandboxing is engaged.
5. Implementation Roadmap: Deploying Defense-in-Depth
To implement this architecture across your development team:
-
Configure Desktop Baseline:
- Navigate to
Settings > Agents > Approvals & Execution. - Set Run Mode to Auto-review.
- Set Read Access to Workspace.
- Ensure File-Deletion Protection and External-File Protection remain enabled.
- Navigate to
-
Commit Project Policy Files:
- In the root of your git repository, establish
.cursor/cli.json,.cursor/permissions.json, and.cursor/sandbox.json. - Explicitly define your build commands in
allow, ban root destructive utilities indeny, and list internal package registries insandbox.json. - Commit these files to version control so new engineers inherit uniform guardrails on checkout.
- In the root of your git repository, establish
-
Verify Active Sandboxing:
- Prompt the Cursor Agent in terminal mode to run:
echo "Sandbox Status: $CURSOR_SANDBOX, Effective UID: $(id -u), Original UID: $CURSOR_ORIG_UID" - On macOS, confirm output contains
CURSOR_SANDBOX: seatbelt. On Linux, confirmnativeorfully_enforced.
- Prompt the Cursor Agent in terminal mode to run:
By marrying Cursor's Auto-review classifier with strict OS kernel sandboxing and version-controlled repository rules, software engineers achieve continuous autonomous execution speed without exposing local systems or production assets to accidental destruction.