Cursor security best practices: seven steps to lock down the agent on a Mac
Seven steps cover most of the risk. Three are worth changing today: turn on Privacy Mode, pick a run mode that keeps approvals on, such as Auto-review, and list your secrets in .cursorignore. Two more should simply stay on: the sandbox, a fence the system puts around terminal commands, and the file protections. The last two are for specific moments: approve each MCP server, the helper programs that give the agent extra tools, one by one, and open unknown folders in restricted mode. Add a hook and commit to git often as your way back.
These Cursor security best practices are for a Mac owner who runs the agent daily and wants to know how to secure Cursor without reading ten docs pages. Cursor is an editor with an agent inside it. The agent reads your code, edits files, runs terminal commands and calls helper programs. Each step below closes one way that can go wrong, and says where the protection ends. Together they show how to set up security guardrails for Cursor on your own machine. For how the run modes and the sandbox work in detail, see Cursor security. For a verdict first, read Is Cursor safe?.
01Cursor security best practices at a glance
The table lists each step, what to do and where the protection ends. Steps 1 to 3 are the ones to change today.
| Step | What to do | Where it stops |
|---|---|---|
| 1 | Turn on Privacy Mode | Covers training, not the sending of prompts |
| 2 | Run Auto-review or Allowlist | Best-effort guardrails, not a hard boundary |
| 3 | List secrets in .cursorignore | Terminal commands and MCP tools can still read them |
| 4 | Keep the sandbox and file protections on | Some commands need full access and bypass the sandbox |
| 5 | Approve MCP servers, review plugins and extensions | A plugin can bundle servers, skills, rules and hooks |
| 6 | Use workspace trust for unknown folders | Restricted mode limits AI features, so it is not for daily repos |
| 7 | Add a hook and commit often | A hook that crashes lets the action through unless you set failClosed |
02Step 1: turn on Privacy Mode
Privacy Mode ensures your code is never used for training by Cursor or other AI model providers. Open Cursor Settings with Cmd + Shift + J, click General in the sidebar and toggle Privacy Mode on. For teams it is on by default, and admins can enforce it from the dashboard so members cannot turn it off.
Be clear about what this does. When you use AI features, Cursor sends prompts and code context to model providers such as OpenAI, Anthropic and Google. Privacy Mode changes what they may do with that data, not whether it is sent. If you bring your own API keys, zero data retention does not apply, and your provider's privacy policy governs the data.
03Step 2: pick a run mode that keeps you in the loop
A run mode decides which agent actions need your approval. By default, terminal commands need it. Run Modes let trusted calls run without prompting. Auto-review is the safest useful setup for most people. Its classifier, a small AI model that judges each action, can allow a call you would have blocked, or block one you would have allowed.
Allowlist is the other option: a list of commands that may run without asking. It matches commands by prefix and is case-sensitive, so git matches git status but not gitk. Keep entries short and specific. Auto-review and allowlists are best-effort guardrails, so they work best next to the deterministic controls in step 7. Organizations should set the run mode policy to Auto-review, not Run Everything, and enable sandboxing. The reasons to avoid Run Everything are in Cursor YOLO mode.
Two things stay outside any run mode. Agents can modify workspace files without approval, except configuration files, and changes save to disk immediately. Reading files and searching code need no approval either.
04Step 3: keep secrets out of the agent's reach
Create a .cursorignore file in your project root. Add patterns for the files and folders you want excluded. Cursor already ignores .env files, .git/ and lock files by default. It also respects your .gitignore, so files git ignores are excluded from AI context too. Add entries for secrets and regulated paths on top of that.
The limit matters. Terminal commands and MCP tools run outside Cursor's file access controls, so they may still read ignored files. That is why .cursorignore works together with approvals and file permissions. Treat the file as a way to keep secrets out of the agent's context, not as a lock.
05Step 4: keep the sandbox and the protections on
Of the Cursor security best practices, step 4 is the one you may never need to touch, because Cursor's defaults are meant to stay on.
A sandbox is a fence the operating system puts around a command. Cursor's lets terminal commands run without full machine access, and on macOS it uses Seatbelt, Apple's built-in sandbox. With default settings the agent cannot make arbitrary network requests, and Cursor's own tools only reach GitHub, direct link retrieval and web search providers.
Leave the network mode alone unless you have a reason. The default allows package managers and language tools, and Allow All lets the sandbox reach everything. Read access defaults to System, so the agent can read files outside the workspace without approval. If that worries you, keep secrets out of folders outside the project. Some commands need full access and run outside the sandbox, and Cursor asks for approval when that happens.
Keep Browser, File-Deletion, External-File and .cursor directory protection enabled. File-Deletion Protection is meant to stop the agent deleting files automatically, including rm. A user has reported a delete command that got past it, so it is a guard, not a guarantee. More on the sandbox is on the Cursor sandbox page.
06Step 5: approve MCP servers, review plugins and extensions
An MCP server is a helper program that gives the agent extra tools, such as access to GitHub. All MCP connections need your approval, and after that each tool call still needs approval. In Auto-review mode, allowlisted MCP tools run immediately and everything else goes through the classifier. Approve servers with the allowlist, restrict the tools per server and review each server before enabling it. For the risks of the servers themselves, see MCP security.
Plugins
Plugins are third-party software, and installing one is at your own risk. All plugins are open source, so read a plugin's source before installing. Cursor reviews every plugin update by hand and does not update plugins automatically from source. A plugin can bundle MCP servers, skills, subagents, rules and hooks, so check what it installs.
Extensions
Extensions come from Open VSX, a public extension registry, through a Cursor proxy that automatically checks them for malware and for tampering with the code they depend on. One trap: the same publisher.extension name can point to a different publisher or different code on Open VSX than on the Microsoft Marketplace. Check the publisher, not only the name. A tampered extension has already tried to install a persistent SSH backdoor. Administrators can also delay extension installs until a version has been public for a set number of hours, which blunts short-lived malicious uploads.
07Step 6: treat unknown folders as untrusted
Workspace trust makes Cursor ask, for each new folder, whether to open it in normal or restricted mode. It is disabled by default. Restricted mode limits AI features, so switch it on if you often open folders you did not write, and leave it off if you mostly work in your own repositories. To switch it on, add this setting:
"security.workspace.trust.enabled": trueOrganizations can enforce it through MDM, the tool companies use to manage employee laptops. For a repository you do not trust at all, Cursor says to use a basic text editor instead.
08Step 7: add a hook and keep a way back
Best-effort guardrails are Auto-review, allowlists and .cursorignore. Deterministic ones, which give the same answer every time, are approvals, hooks and sandboxing. Cursor advises layering both rather than relying on a single layer.
A hook is your own script that Cursor runs at a set point. beforeShellExecution controls shell commands, and exit code 2 blocks the action. Any other exit code means the hook failed, and the action goes ahead, which is called fail-open. Setting failClosed: true on the hook definition makes a crash, a timeout, a non-zero exit or no output block the action too.
Then plan for the day a guardrail misses. Agent changes save at once, so always use version control. Cursor also snapshots the codebase during an agent session, and you can restore from the chat timeline. Those checkpoints are local and separate from git, so use git for anything permanent. The steps are in restore a Cursor checkpoint.
09When the settings are not enough
Cursor itself has had flaws. In versions below 1.3.9, an indirect prompt injection, meaning hidden instructions in text the agent reads, could write .cursor/mcp.json and run code on your Mac without your approval. A sandbox escape through git hooks written by a prompt-injected agent was fixed in 2.5. Update Cursor when advisories appear.
Settings tell Cursor what it may do. They do not show what ran on your Mac afterwards. If you want to know which programs the agent started, that needs the optional collector of Artificial Immunity's free, open-source core, installed as administrator; without it the core cannot see program starts.
10The whole list in five lines
The Cursor security best practices, in short. Turn on Privacy Mode and run Auto-review or Allowlist. Put secrets in .cursorignore and keep the sandbox on. Approve every MCP server, open unknown folders in restricted mode and commit often. For a wider view of the same problem across tools, read AI agent security and the Claude Code hooks guide.
FAQ
How do I secure Cursor?
Follow the seven steps on this page, starting with Privacy Mode and a run mode that keeps approvals on. They cover your data, terminal commands, files, MCP servers, plugins and unknown folders.
Is Cursor a security risk?
It carries the risks of any coding agent that can run commands and edit files. By default terminal commands need your approval, but agents can change workspace files without approval. Cursor recommends keeping its built-in protections enabled.
What are the best practices for working with Cursor?
Turn on Privacy Mode, pick Auto-review or Allowlist as your run mode, list secrets in .cursorignore, keep the sandbox and file protections on, approve MCP servers one by one, and commit to git often.
Does Cursor leak your code?
Cursor sends prompts and code context to model providers like OpenAI, Anthropic and Google. With Privacy Mode on, your code is not used for training by Cursor or the providers. With your own API keys, zero data retention does not apply and your provider's policy governs.
Does Cursor spy on you?
Cursor does send prompts and code context to model providers to do its job. Privacy Mode limits what happens to that data, since it is not used for training, but it does not stop the sending.
How do I secure Cursor on a team?
Admins can enforce Privacy Mode organization-wide, set the org run mode policy to Auto-review instead of Run Everything, and enable sandboxing. Workspace trust, a setting that opens unknown folders in a restricted mode, can be enforced through MDM, the tool companies use to manage employee laptops.
Does .cursorignore protect my secrets?
Only from the agent's file access. Terminal commands and MCP tools run outside those controls and may still read ignored files. Pair it with approvals and file permissions.
Which Cursor settings should I never turn off?
Browser, File-Deletion, External-File and .cursor directory protection. Cursor recommends keeping its defaults enabled.