AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure Cursor Terminal Agent Permissions and Sandboxing for Safe Shell Automation

Carmen Gracia Santos · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

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 ModeAuto-Run ScopeSandboxing EnforcementLLM Classifier Review365Finds 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.
AllowlistExplicitly 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:

  1. Allowlist Bypass: If a command matches an explicit allowlist pattern, it executes immediately.
  2. 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.
  3. 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).
  4. 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-review delivers 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:

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:

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

  1. 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.
  2. Linux Architecture:

    • Powered by Landlock v3 (CONFIG_SECURITY_LANDLOCK=y on 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-apparmor package if user namespace restrictions are enforced.

Workspace vs. System Read Access (Cursor 3.23+)

Under Settings > Agents > Approvals & Execution > Read Access, engineers can toggle read boundaries:

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:

Additional Built-In Guardrails

Cursor integrates built-in safety triggers that enforce human approval even in permissive modes:


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:

Solution: Injected Sandbox Environment Variables

Cursor injects diagnostic and identity variables into every sandboxed child process:

Environment VariableTarget PlatformDescription
CURSOR_SANDBOXmacOS, LinuxSet to "seatbelt" on macOS or "native" on Linux when sandboxed.
CURSOR_ORIG_UIDmacOS, LinuxCaptures the authentic host UID of the engineer prior to namespace remapping.
CURSOR_ORIG_GIDmacOS, LinuxCaptures the authentic host GID of the engineer prior to namespace remapping.
CURSOR_SANDBOX_LANDLOCK_STATUSLinuxReturns "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:

  1. 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.
  2. 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 in deny, and list internal package registries in sandbox.json.
    • Commit these files to version control so new engineers inherit uniform guardrails on checkout.
  3. 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, confirm native or fully_enforced.

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.


References