How to secure an app you built in Cursor
Short answer
Secure a Cursor-built app by reviewing the diff before you deploy, not the chat. Reject client-prefixed secrets (NEXT_PUBLIC_, VITE_, EXPO_PUBLIC_), keep authorization in the route or database policy rather than only in middleware or a system prompt, and pin Next.js and React Server Components to a patched release. Cursor is the editor. The production URL is what visitors get, so scan that URL after deploy.
Last updated · Sekrd Research
- Cursor does not host the app. Whatever the agent commits is what your host builds.
- Next.js middleware is not an authorization boundary on self-hosted apps that are still in the CVE-2025-29927 range. Vercel- and Netlify-hosted apps were not affected by that CVE.
- A system prompt is not an access-control layer. OWASP LLM07:2025.
Review the diff like a security change
The useful habit with an agent in Cursor is the same one you already use for a human teammate: read the diff before it ships. The agent optimizes for “the feature works in the browser.” These are the lines that do that and still leak.
- Environment variables.
NEXT_PUBLIC_,VITE_, andEXPO_PUBLIC_are compiled into the client. A name likeNEXT_PUBLIC_OPENAI_API_KEY,NEXT_PUBLIC_STRIPE_SECRET, orVITE_SUPABASE_SERVICE_ROLEis the bug, even before you look at the value. The safe split is in the env-prefix guide..envand.env.localstay out of git. Cursor rules and.cursornotes sometimes get a key pasted into them during a debugging session — those files are in the repo too. - Authorization that lives in only one place.
middleware.tsthat redirects anonymous users is convenient, and on a self-hosted Next.js in the CVE-2025-29927 range it can be skipped. Check the session again in the Server Component, route handler, or Server Action that returns the data. Supabase and Firebase need the same idea in RLS or Security Rules, not only in a Reactif (user)around a button. Database checklists: Supabase RLS and Firestore rules. - The model call.
dangerouslyAllowBrowser: trueon the OpenAI SDK is the agent clearing an error by shipping the key. Move the call to a route handler that checks the session and holds the key in a server-only variable. If a key already shipped, follow the first hour. - Prompts that contain the security policy. “You are an admin” or “ignore RLS” inside
systemPromptin a client component is not a control. Anyone can read it, and the model can be talked out of it. Put the rule in Postgres or in the route. Ordinary product copy in a prompt is fine. - Dependency pins. If the app uses React Server Components, compare
react-server-dom-webpack(and the Parcel and Turbopack packages) to the versions in CVE-2025-55182. Do not trust a homepage banner for the Next.js version; read the lockfile.
A short pre-deploy command
git diff --stat
git grep -n -E "NEXT_PUBLIC_(OPENAI|ANTHROPIC|STRIPE_SECRET|SERVICE_ROLE)|VITE_(OPENAI|SUPABASE_SERVICE)|dangerouslyAllowBrowser|sb_secret_" \
-- ':!node_modules' ':!*.lock'
npm ls react-server-dom-webpack react-server-dom-turbopack next
Then deploy, and run a free scan of the URL you just published. The scan sees the bundle the agent cannot see from inside the editor. A deep scan, on Pre-Launch or Pro, adds the read-only checks for a middleware gate that actually opens, an unauthenticated MCP server, and an env file the host is serving.
MCP servers the agent added
Cursor sessions often gain MCP servers for the filesystem, the database, or GitHub. That is a developer-machine risk and, if you deploy the same server, a production risk. Require auth on any remote server, and do not treat tools/list without credentials as a health check. The longer list is MCP server security in 2026.
Frequently asked questions
How do I secure an app built with Cursor?
Review the diff for client-prefixed secrets, browser-side API keys, and auth that exists only in middleware or a system prompt. Keep secrets in server-only env vars, enforce authorization in the database or route, upgrade vulnerable Next.js and React Server Components versions, and scan the deployed URL.
Does Cursor scan my app for secrets before deploy?
Cursor is the editor. It does not replace a check of the production bundle. Search the diff for NEXT_PUBLIC_ and VITE_ secrets, and scan the live URL after deploy.
Is Next.js middleware enough to protect a Cursor-generated dashboard?
No. Middleware is one layer. Self-hosted Next.js versions affected by CVE-2025-29927 can skip it. Check the session in the handler that returns the data, and keep Row Level Security or Security Rules on the database.
Sources
Don't ship until you're sekrd
Run a free scan to find the vulnerabilities your AI missed.
Scan Your App Free