Is Cursor safe? A security guide for Cursor and the apps it builds

Cursor is an AI agent with access to your files and terminal, and it writes code faster than anyone reviews it. That makes two things worth securing: Cursor itself, and the app it builds for you. This guide covers both, starting with the question most people search for.

Is Cursor safe to use?

Mostly, if you configure it. Cursor's security page lists a SOC 2 Type II attestation and says Privacy Mode means it will not train on your data. Terminal commands and MCP connections need approval by default. Most of the risk comes from what you allow: auto-run, untrusted MCP servers, repositories you did not write and generated code you ship without review.

Cursor security best practices: how to secure Cursor itself

Treat Cursor's settings like permissions on any tool that can run code on your machine. These are the ones that matter most.

  • Turn on Privacy Mode. Cursor says that with it enabled it will not train on your data. It is available on free and Pro plans, and team admins can enforce it.
  • Keep terminal approval on. Commands need approval by default. Run Modes (allowlists and auto-review) let trusted calls skip the prompt, but Cursor calls them best-effort guardrails, not a hard security boundary. Allowlist narrowly, and never auto-run commands that delete data, push code or reach the network.
  • Approve MCP servers deliberately. Every MCP connection needs approval, and each tool call asks again unless you pre-approve it. Connect only servers you wrote or trust, and pre-approve specific tools rather than whole servers.
  • Enable Workspace Trust for repositories you did not write. It is off by default: set "security.workspace.trust.enabled": true in your user settings.json. Restricted mode disables AI features, and for untrusted repos Cursor suggests a basic text editor instead.
  • Hide secrets from the agent with .cursorignore. Files listed there are blocked from agent access, so keep .env files, keys and customer data in it.
  • Review edits and commit often. Agents can edit workspace files without approval (configuration files need it), and with auto-reload on, changes can run before you read them. Version control is how you undo.
  • Assume prompt injection is possible. Text in a README, an issue, a web page or an MCP response can try to steer the agent, and Cursor itself warns that agents can behave unexpectedly because of it.

Cursor hooks security: enforce rules in code

Hooks are scripts Cursor runs at set points in the agent loop. They are configured in .cursor/hooks.json for a project or ~/.cursor/hooks.json for you, and a hook for beforeShellExecution or beforeMCPExecution can answer allow, deny or ask. beforeReadFile can deny reads of sensitive files before their contents reach the model.

A hook that crashes fails open by default, so set "failClosed": true on anything security-critical. Exit code 2 blocks the action. The example below stops the agent from running network commands.

.cursor/hooks.json
{
  "version": 1,
  "hooks": {
    "beforeShellExecution": [
      {
        "command": ".cursor/hooks/block-network.sh",
        "matcher": "curl|wget|nc",
        "failClosed": true
      }
    ]
  }
}

Secure Cursor deployment: before you ship what it built

Reviewing the repo is not enough, because secrets that reach the bundle, missing headers and open endpoints only show up on the live URL.

  • Scan the deployed site, not just the code, and fix what a visitor can see.
  • Rotate any key that was ever pasted into a prompt, committed to Git or bundled into the front end.
  • Use separate databases, keys and accounts for development and production, so an agent holding dev credentials cannot touch real data.
  • Set security headers and session cookie flags before real users arrive.

Common security risks in Cursor apps

  1. 1. Secrets committed or bundled

    API keys pasted into code during a quick fix tend to stay there, end up in Git history and sometimes in the front-end bundle.

  2. 2. Weak session cookies

    Session cookies without Secure, HttpOnly and SameSite are easier to steal or misuse. Generated auth code often leaves these at defaults.

  3. 3. Missing or permissive Content-Security-Policy

    A CSP with unsafe-inline, unsafe-eval or wildcard script sources does little to stop injected scripts.

  4. 4. Endpoints without authentication or rate limits

    Routes added while prototyping often stay public. Without rate limits, anything that calls a paid API can be abused.

  5. 5. Debug and internal details in production

    Stack traces, debug headers, internal hostnames and HTML comments reveal more about your stack than you want.

What a FixPrompt scan checks

Passive checks on your public site, the same way a visitor's browser loads it. No attacks, no logins, no data queried.

  • Secret key patterns for 30+ providers in JavaScript bundles and HTML
  • Session cookie flags and lifetime
  • Content-Security-Policy strength, HSTS, clickjacking and Permissions-Policy
  • Common API paths that answer anonymous requests, plus rate-limit headers
  • Debug headers, server banners, error pages, internal hostnames and HTML comments
  • Public .git, .env, source maps and backup files

Copy-paste fix prompt

Paste this into Claude Code, Cursor, Codex or any coding agent with access to your repository. A scan gives you a prompt tailored to the issues found on your live site.

Fix prompt

Act as a security reviewer for this codebase and fix issues in priority order:

1. Search the code and git history for hard-coded secrets. Move them to environment variables that only server code reads, and list the keys I must rotate.
2. Set session cookies with Secure, HttpOnly, SameSite=Lax (or Strict) and a reasonable lifetime.
3. Add a strict Content-Security-Policy (no unsafe-inline or unsafe-eval for scripts; use nonces if needed), plus HSTS, frame-ancestors, X-Content-Type-Options and Referrer-Policy.
4. Require authentication on every route that returns private data and add rate limiting to routes that call paid APIs.
5. Remove debug headers, verbose error pages and source maps from production.

Make small, reviewable commits and tell me how to verify each fix.

Want rules your agent follows on every task? Get security rules for Cursor, CLAUDE.md and AGENTS.md.

FAQ

Is Cursor safe to use for work code?
It depends on your settings and your employer's policy. Turn on Privacy Mode (Cursor says it will not train on your data then), keep approvals on, vet MCP servers and use `.cursorignore` for secrets. Team admins can enforce Privacy Mode. Check your company's rules before using any AI tool on proprietary code.
What are the main Cursor security risks?
Auto-running terminal commands, untrusted MCP servers, prompt injection from repositories or web content, opening untrusted repos with Workspace Trust off, secrets pasted into prompts or code, and shipping generated code without review.
How do I secure Cursor?
Enable Privacy Mode, keep terminal approvals on and allowlist narrowly, approve MCP servers and tools one by one, turn on Workspace Trust for repos you did not write, list secrets in `.cursorignore`, and add hooks for rules that must never be skipped.
What are Cursor hooks, and do they improve security?
Hooks are scripts that run at points in the agent loop, such as before a shell command or MCP call. They can allow, deny or ask, so they turn a rule like 'never run curl' into something enforced in code. Set failClosed to true so a crashing hook blocks the action.
Can Cursor fix security issues by itself?
Yes, when it knows what to fix. The FixPrompt report gives it a prioritized prompt with the evidence from your live site, so it can make targeted changes.
Does this work with Claude Code, Codex or Copilot too?
Yes. The fix prompt is plain text for any coding agent with access to your repository.
Do I need to give FixPrompt access to my code?
No. The scan only looks at the public, deployed site. Your coding agent applies the fixes in your repository.

Check your Cursor app in minutes

Paste your URL and get a plain-English report with prioritized risks and a fix prompt for your AI. Your first scan is free.

Scan my app free