Dev.to Security 🔐 Cybersecurity 👁 0 📖 7 min read

Your Cursor Allowlist Says git. It Also Approves git push --force

Cursor's agent doesn't ask before it edits files in your workspace. The Agent Security docs say it plainly: agents can modify workspace files without approval (configuration files are the exception), changes save to disk

Cursor's agent doesn't ask before it edits files in your workspace. The Agent Security docs say it plainly: agents can modify workspace files without approval (configuration files are the exception), changes save to disk immediately, and you should use version control so you can revert. Terminal commands are different. By default they need your approval.

Most people want that prompt gone after a day. What replaces it is a run mode and three small files: .cursor/permissions.json, .cursor/sandbox.json and .cursorignore. The detail most often missed: a terminal allowlist entry of git doesn't mean "safe git commands". It means every command that starts with git.

An earlier article covered which jobs to give Cursor. This one covers what its local agent may do without asking. Everything below is from the official Cursor docs, fetched on 21 Nov 2026.

The short version

  1. Commit before you start an agent task. Edits land on disk right away.
  2. Pick a run mode on purpose. Auto-review is Cursor's recommended default; Run Everything has no checks at all.
  3. Keep allowlist entries narrow: git status, not git.
  4. Put secrets in .cursorignore, but don't treat it as a wall.
  5. Leave the sandbox network on deny-by-default and add only the domains you need.
  6. Review the diff before you merge: /agent-review or Source Control.

1. Pick the run mode on purpose

Run modes live in Settings > Agents > Approvals & Execution (Run Modes docs). There are three:

  • Auto-review. Allowlisted calls run immediately. Other shell commands run in the sandbox when possible. Calls that can't use the sandbox go to a classifier that decides whether they run or come back to you. Cursor made this the recommended default in version 3.6 (29 May 2026).
  • Allowlist. Only what's on your allowlist runs without approval. With sandboxing on, supported shell commands can run in the sandbox. An empty allowlist gives you the old "ask every time" behaviour, which was deprecated in 3.5.
  • Run Everything. Every tool call runs automatically. No sandbox, no classifier.

Keep two lines from the docs in mind: run modes are "best-effort guardrails rather than a hard security boundary", and the classifier "can make mistakes" in both directions. Run modes also apply to local agents only. Cloud Agents run on their own dedicated machine and never ask you to approve an action.

2. Your allowlist is prefix matching

The terminal allowlist can live in the settings UI or in permissions.json, either ~/.cursor/permissions.json (all projects) or <repo>/.cursor/permissions.json (one project). The permissions.json reference defines the matching: entries are command prefixes, case-sensitive. git matches git status, but it also matches git push --force and git reset --hard. npm matches npm publish.

In Auto-review that matters more than it looks: per the docs, allowlisted calls run immediately and outside the sandbox, so they skip the sandbox and the classifier. Separate protections can still force a prompt, such as File-Deletion Protection (it covers rm) and External-File Protection (files outside the workspace), but neither one covers git push.

A narrower list looks like this:

{
  "terminalAllowlist": ["git status", "git diff", "git log", "npm test", "ls"],
  "mcpAllowlist": ["github:get_issue", "linear:list_issues"],
  "autoRun": {
    "allow_instructions": [],
    "block_instructions": [
      "Any git push, git reset or git rebase should go through approval first.",
      "Any command that publishes a package should go through approval first."
    ]
  }
}

Three details from the reference:

  • MCP entries are server:tool. github:* approves every tool on that server and *:* approves every tool on every server. Name the tools you've actually read.
  • autoRun instructions are plain English for the Auto-review classifier. The docs call them steering, not enforcement, and they do nothing in Allowlist or Run Everything mode.
  • The file wins over the UI, and both files add up. A file-defined allowlist makes the in-app editor read-only, and arrays from your user file and the repo file are concatenated.

That last point has a consequence the docs don't spell out: a repo you clone can bring its own .cursor/permissions.json, and its entries join yours. Read that file before you run the agent in someone else's repo, the same way you'd read a stray AGENTS.md.

3. .cursorignore hides files from the agent, not from the shell

Per the ignore file docs, files in .cursorignore are blocked from the Agent, Tab and @ mentions. The same page says the agent's terminal and MCP tools can't block access to them, and that protection "isn't guaranteed due to LLM unpredictability".

Covered by default: your .gitignore plus a built-in list that includes .env*. Not covered: .pem, .key and credentials.json, and the global ignore list in user settings starts empty. The docs suggest **/.env, **/.env.*, **/credentials.json, **/secrets.json, **/*.key, **/*.pem and **/id_rsa. The syntax is the same as .gitignore, and the docs suggest testing patterns with git check-ignore -v.

For a boundary outside the project, Cursor 3.23 added Read Access. Set it to Workspace and the agent has to ask before reading files outside the workspace, unless they're on your Read Allowlist. The default is System, which reads without asking.

4. The sandbox: leave the network on deny

The sandbox runs supported terminal commands with read and write access inside the workspace and network access blocked by default, then opened by your network mode and sandbox.json (sandbox.json reference). The default network mode adds Cursor's built-in list of package-manager and tool domains to yours.

  • "networkPolicy": {"default": "deny", "allow": [...]} limits sandboxed commands to the listed domains. Deny rules always beat allow rules.
  • Private addresses such as 10.x, 192.168.x, 127.x and the cloud metadata endpoint are blocked by default.
  • .cursor/*.json and .cursorignore are write-protected inside the sandbox, so a sandboxed command can't loosen them.
  • On Linux the sandbox needs kernel 6.2+ with Landlock. Without it, Cursor falls back to asking before running commands.

A small check you can run on a repo

To check these in one go, I wrote cursor_guard_check.py (about 100 lines, Python standard library plus git). It reads a repo's .cursor/permissions.json, .cursor/sandbox.json and ignore files, then flags bare command prefixes, server:* MCP entries, an open network policy, and files that look like secrets but aren't ignored. It reads files only: it can't see your Cursor Settings, team policies or ~/.cursor, and the list of risky prefixes is my choice, not Cursor's.

I ran it on 21 Nov 2026 against a demo repo I made up for this, with a loose config "copied from a blog post" ("git", "npm", "github:*", network allow) and fake key files. Real output:

WARN  terminalAllowlist "git" is a bare prefix; it also matches: git push --force, git reset --hard
WARN  terminalAllowlist "npm" is a bare prefix; it also matches: npm publish, npm install <anything>
WARN  mcpAllowlist "github:*" auto-approves every tool from github
INFO  no autoRun.block_instructions (only matters in Auto-review mode)
INFO  this repo ships its own permissions.json; its entries are added to yours
WARN  sandbox.json networkPolicy.default is "allow" (any host)
INFO  readBoundary is "system": the agent can read outside the workspace without asking
WARN  config/credentials.json looks like a secret and is not in .cursorignore
WARN  config/deploy.pem looks like a secret and is not in .cursorignore
INFO  .cursorignore does not stop terminal commands or MCP tools from reading files
Result: 6 warning(s), 4 note(s)

After switching to the permissions.json above, a deny-by-default sandbox.json with readBoundary: "workspace", and a three-line .cursorignore, the same run printed Result: 0 warning(s), 2 note(s). The two remaining notes are the ones no config file fixes.

5. After the session: review the diff, not the summary

The summary says what the agent meant to do; the diff shows what it did. Agent Review runs a code review on your local changes: type /agent-review in the agent input, or run it from the Source Control tab to compare all local changes against your main branch. It has a Quick depth (fast, low cost) and a Deep one (slow, higher cost) for security-sensitive code or big refactors. You can also set it to run automatically; from Cursor 3.11 that setting is under Git & PRs > Pull Requests.

Checklist

  • Commit, or start a branch, before every agent task.
  • Choose Auto-review or Allowlist in Approvals & Execution; skip Run Everything on code you care about.
  • Replace bare prefixes (git, npm, curl, bash) with exact commands.
  • Name MCP tools; avoid server:* and *:*.
  • Read .cursor/permissions.json in any repo you didn't write.
  • Add key and credential patterns to .cursorignore or the global ignore list.
  • Set Read Access to Workspace unless the agent needs files outside the project.
  • Keep the sandbox network on deny and list the domains you need.
  • Run /agent-review before you merge.

Where to go next

If you're new to Cursor, the free Cursor AI Quick-Start Cheat Sheet puts the AI surfaces, the essential keyboard shortcuts, the @ symbols for context and a 60-second starter workflow on 5 pages you can keep beside your editor.

When you want to go further, Cursor AI Mastery: The Complete Guide is a 41-page guide covering Agent Mode, Background (now Cloud) Agent workflows, model selection, MCP and Skills, rules, 12 common pitfalls with fixes, 20 power-user tips and a 30-day mastery plan.

This article was written with the assistance of AI and reviewed by the author. Cursor behaviour is from the official Cursor docs (Agent Security, Run Modes, permissions.json, sandbox.json, ignore file and Agent Review pages), fetched on 21 Nov 2026. The script output is a real run on 21 Nov 2026 against an invented demo repo; Cursor itself was not run for this article. PromptMaster guides are independent and not affiliated with or endorsed by Cursor.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.