Cursor app security checklist: what to check before you ship
· PlugLeak
A checklist before you ship a Cursor-built app: secrets in AI context and the browser bundle, server-side auth, Supabase RLS, Stripe webhooks, and the live site.
Shipping from Cursor means shipping the app in the repo, usually Next.js or Vite, often with Supabase or Stripe. Walk this list before that deploy. A passive scan of the live URL covers files a visitor can already download. Session checks, Row Level Security, and webhook verification are manual. This page is those checks. The free scan itself is at plugleak.com/#scan, and the Cursor landing page is /scan/cursor.
1. Keep secrets out of AI context and git
Cursor reads the project to power Agent and Tab. It respects .gitignore, and files that git ignores are excluded from AI context (Ignore files). On top of that, a default ignore list already includes .env*, so .env and .env.local are ignored, along with .git/ and lockfiles (Ignore file). A ! line in .cursorignore can un-ignore a default pattern. Do not add !.env.
Add a .cursorignore in the project root for anything else, using gitignore syntax. It blocks those paths from Agent, Tab, and @ mentions. The global ignore list in user settings is empty until you fill it, and it applies to every project. The patterns the Cursor docs suggest:
**/.env
**/.env.*
**/credentials.json
**/secrets.json
**/*.key
**/*.pem
**/id_rsaThat block is not a guarantee. The reference says the terminal and MCP tools used by Agent cannot block access to code governed by .cursorignore, and that while Cursor blocks ignored files, complete protection is not guaranteed, because the model is unpredictable. The help page says the same thing another way: terminal commands and MCP tools run outside Cursor's file access controls, so they may still read ignored files.
Review what the agent is allowed to run. Reading files and searching code do not require approval. .cursorignore is what blocks those reads. By default, terminal commands need your approval. Run Modes can let trusted calls skip the prompt, from an allowlist up to the Auto-review classifier, and Cursor describes those as best-effort guardrails rather than a hard security boundary (Agent security). MCP connections need approval, and each MCP tool call needs approval again unless you put that tool on an allowlist. An allowlist is a choice to stop reviewing that call.
Keep the secret out of git as well. The Next.js env docs say the default create-next-app template gitignores .env files, and that you almost never want to commit them (Environment variables). Vite tells you to gitignore *.local, because .env.*.local is where local secrets belong (Env variables and modes). If a secret was committed, deleting the line in a new commit leaves it in history. GitHub's first step for a committed secret is to revoke or rotate it. Rewriting history is a separate, coordinated process, and it does not erase clones that already have the old commits (Removing sensitive data from a repository).
2. Keep secrets out of the browser bundle
A variable the bundler inlines is visible to anyone who loads the site. Next.js inlines every NEXT_PUBLIC_ value into the JavaScript bundle at build time. Variables without that prefix stay on the server (Environment variables). The data security guide states the default directly: environment variables are only available on the server, and Next.js exposes a variable to the client when the name starts with NEXT_PUBLIC_ (Data security).
Vite exposes names that start with VITE_ on import.meta.env and bundles those values at build time. The docs say VITE_* variables should not contain sensitive information such as API keys. In their example, import.meta.env.VITE_SOME_KEY is the string from the env file, and import.meta.env.DB_PASSWORD is undefined (Env variables and modes). Confirm which bundler you have: a next.config file means Next.js, a vite.config file means Vite. The full table of what may sit in either prefix is the NEXT_PUBLIC_ and VITE_ guide.
Check the deployed site, not the source tree. Open the live URL, then in DevTools use Sources and search across the loaded files, or open a script in Network and search the response. Search for sk_live_, sk-, sb_secret_, service_role, AKIA, ghp_, and -----BEGIN. A Stripe publishable key (pk_) or a Supabase publishable or anon key can be there on purpose. A secret key or a service_role JWT cannot. If you find one of those, use the service_role guide for the Supabase case, and the same rotate-and-move-server-side order for any other secret.
Removing the line from the current source does not pull the value out of a bundle that is already live, and it does not pull a committed value out of git history. Rotate anything that shipped or was committed, put the replacement in a name with no public prefix, rebuild, and redeploy. Then search the live JavaScript again.
3. Server-side auth and authorization
A Route Handler (route.ts) is a URL anyone can request. A Server Action is a POST endpoint. Next.js says that when a Server Action is created and exported, it is reachable by a direct POST, not only through the UI. Actions the build can prove are unused are removed. Treat every action that ships as reachable, and verify authentication and authorization inside it. A check that runs on the page does not extend to the action defined on that page (Data security). The same guide tells you to audit route.ts with extra care, because those handlers have a lot of power. Check the session on the server in each one.
Authentication is "who is this". Authorization is "may this user touch this row". The docs' example loads the record and compares authorId to the session user. User B must not get user A's invoice by changing the id in the request. This is that check, adapted to a read:
"use server";
import { auth } from "@/lib/auth";
import { db } from "@/lib/db";
export async function getInvoice(id: string) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");
const invoice = await db.invoice.findUnique({ where: { id } });
if (!invoice || invoice.userId !== session.user.id) {
throw new Error("Forbidden");
}
return { id: invoice.id, total: invoice.total };
}A Route Handler does the same work before it returns data. auth here is your session helper, the same shape the Next.js examples import from @/lib/auth. It is not a global.
export async function GET(request: Request) {
const session = await auth();
if (!session?.user) return new Response("Unauthorized", { status: 401 });
const id = new URL(request.url).searchParams.get("id");
if (!id) return new Response("Bad request", { status: 400 });
const invoice = await db.invoice.findUnique({ where: { id } });
if (!invoice || invoice.userId !== session.user.id) {
return new Response("Forbidden", { status: 403 });
}
return Response.json({ id: invoice.id, total: invoice.total });
}Ignore a role, plan, or credit count the client sends. Next.js says to validate client input because it can be modified, and shows the failure mode as trusting searchParams.isAdmin. Read the plan and the balance from your database for the session user. The body of the request is not that database.
A redirect in front of the app is not this check. Starting with Next.js 16, middleware.ts is renamed to proxy.ts, and the old file convention is deprecated (Renaming Middleware to Proxy). The authentication guide says Proxy can do an optimistic redirect from the session cookie, and that it should not be your only line of defense. Do the session and ownership checks next to the data, in the action, the Route Handler, or a data-access function both of them call (Authentication). On a Next.js 15 app the file may still be named middleware.ts. The limit is the same: the redirect is not the authorization check.
4. Database, if you use Supabase
Supabase's warning: a table in an exposed schema without Row Level Security is readable and writable by any role with a grant on it. Enable RLS on every table in an exposed schema. On existing projects, a new table in public starts with privileges already granted to anon, authenticated, and service_role. Adding a policy does not take those grants back. Revoke the client roles, then grant only the operations the app uses (Row Level Security).
A private table needs an owner policy, not using (true). Supabase's pattern is (select auth.uid()) = user_id, with one policy per operation. A missing grant fails with 42501 before any policy runs. That error is the 42501 guide. The grants, the four policies, and the signed-out curl test are the Supabase RLS checklist.
PlugLeak does not test Row Level Security or grants, and it does not query the database. A clean scan of the live URL does not tell you that these policies hold. Run the checklist.
5. Payments and webhooks
Stripe signs each webhook and sends the signature in the Stripe-Signature header. Verify it with the official library before you fulfill anything. Pass three things: the raw body string Stripe sent, the header, and that endpoint's secret (whsec_). constructEvent() is the call for snapshot events. Thin events use parseEventNotification() with the same three inputs. If verification fails, return an error and do not act on the body (Receive Stripe events, signature verification).
Stripe requires the raw body. Parsing JSON and stringifying it again changes the bytes, and verification fails. In an App Router Route Handler, request.text() is that string. The test secret and the live secret are different, including when they share an endpoint URL.
export async function POST(request: Request) {
const payload = await request.text();
const signature = request.headers.get("stripe-signature");
const secret = process.env.STRIPE_WEBHOOK_SECRET;
if (!signature || !secret) return new Response("Bad request", { status: 400 });
try {
const event = stripe.webhooks.constructEvent(payload, signature, secret);
// Fulfill from event only after constructEvent returns.
return new Response("ok", { status: 200 });
} catch {
return new Response("Invalid signature", { status: 400 });
}
}Decide the price on the server. Stripe's guidance for updating a payment amount is to recalculate on the server and not trust a price or total the client sends (Dynamically update payment amounts). When you create a Checkout Session, build it from a Price id or amount you look up, and do not forward arbitrary session fields from the browser (Accept a payment). The webhook secret and the secret API key stay in unprefixed env vars. The scan does not check webhook signatures or prices. This section is that check.
6. Deployed site hygiene
Request https://your-domain/.env and https://your-domain/.git/config on the origin you shipped. The body should not be the env file or a git config. Then open the document request in DevTools and read the response headers. OWASP's header cheat sheet is the reference for the three below (HTTP Headers Cheat Sheet).
- Strict-Transport-Security. HSTS tells the browser to use HTTPS for later visits. Send it on HTTPS responses. OWASP warns that a long
max-age, especially with preload, can lock people out if the certificate later breaks. Read that warning before you set a multi-year value. - X-Content-Type-Options: nosniff. Stops the browser from sniffing a file into a different type.
- Content-Security-Policy
frame-ancestors. OWASP recommends this directive and says it obsoletesX-Frame-Optionsin browsers that support it. Use it to say who may embed the page. Their recommendation for the older header isDENY.
Load the site over HTTPS and confirm the browser trusts the certificate. Send HSTS on that HTTPS response.
Decide whether production source maps are public. Next.js leaves browser source maps off in production so the original source is not sent to the client, unless you set productionBrowserSourceMaps: true. When that flag is on, Next.js writes the maps next to the JavaScript and serves them when requested (productionBrowserSourceMaps). Vite's build.sourcemap defaults to false. true writes a separate map file. 'inline' appends the map to the bundle (build.sourcemap). Leave them off on a public production build unless you have a reason to ship the original source.
7. Optional: security rules for Cursor
A project rule is an .mdc file in .cursor/rules. A plain .md file in that folder is ignored, because it has no frontmatter. AGENTS.md in the project root is the plain-markdown alternative. With alwaysApply: true, the rule is included in every Agent chat. Rules are instructions placed at the start of the model context. They guide the model. Cursor says AI guidance should not be your only security control (Rules).
---
alwaysApply: true
---
- Read secrets only on the server. Never put a secret in NEXT_PUBLIC_ or VITE_.
- In every Route Handler and Server Action, check the session, then check that the caller owns the row.
- Ignore a role, plan, or credit count sent by the client. Read those from the database.
- Do not turn off RLS, and do not add a policy of using (true), to make a query succeed.Scan the live URL
The free scan is at https://plugleak.com/#scan. For a Cursor-built app, the same check is also on /scan/cursor. Every request is a GET. It fetches the public page you submit and same-site JavaScript, and it does not start another batch of scripts once 25 files or 12 MB of JavaScript have been fetched. It requests /.env and /.git/config, and it checks security headers and TLS. In the page and those scripts it looks for Stripe, OpenAI, Anthropic, and AWS keys, GitHub tokens, PEM private keys, Supabase sb_secret_ keys, and service_role JWTs.
It does not test Row Level Security or grants, query the database, log in, or crawl. It does not check that a route verifies a session, that one user cannot read another user's row, or that a webhook signature is verified. Those are the manual checks above. How the free scan works lists every request. The broader pass across a vibe-coded app is the 10-minute self-check.
Quick checklist
.gitignorecovers env files. Cursor already ignores.env*. Add.cursorignoreor global patterns for**/.env,**/.env.*,**/*.pem, and**/credentials.json. Review terminal and MCP approvals. Those tools are outside.cursorignore.- No secret keys in
NEXT_PUBLIC_orVITE_. Search the deployed JavaScript. Rotate anything that shipped or was committed. - Every Route Handler and Server Action checks the session, then the row's owner. Ignore a role, plan, or credit count from the client. A middleware or proxy redirect is not that check.
- Supabase: RLS on every exposed table, owner policies, grants trimmed to what the app does. Use the RLS checklist. A
42501is a missing grant. - Stripe: verify the webhook signature on the raw body. Set the price on the server.
- Live site:
/.envand/.git/configare not served. HSTS,nosniff, and CSPframe-ancestorsare present. The site is HTTPS. Production source maps are a decision you made on purpose. - Optional: an always-on rule in
.cursor/rules. It guides the agent. It is not a control. - Run the free scan for the public page. Then do the auth, RLS, and webhook checks by hand.
FAQ
Is my Cursor app secure?
Cursor being the editor does not answer that. Walk the checks on this page: secrets out of AI context and git, no secret keys in NEXT_PUBLIC_ or VITE_ variables, a session and ownership check in every Route Handler and Server Action, Supabase Row Level Security and grants if you use Supabase, Stripe webhook signatures and server-side prices if you take payments, and the live site's files, headers, and TLS. The free scan covers the public page, its same-site JavaScript, /.env, /.git/config, security headers, and TLS. Auth, Row Level Security, and webhooks are manual.
Does .cursorignore keep secrets away from the agent?
It blocks ignored files from Agent, Tab, and @ mentions. Cursor also respects .gitignore and ignores .env files by default. The ignore-file docs say terminal and MCP tools used by Agent are not blocked by .cursorignore, and that complete protection is not guaranteed. Review terminal approvals. By default those commands need your approval, and Run Modes that skip the prompt are best-effort guardrails, not a hard boundary.
Is a middleware redirect enough to protect an API route?
No. Next.js 16 renamed middleware.ts to proxy.ts. The authentication guide says Proxy is useful for an initial redirect and should not be your only line of defense. Server Actions are reachable by a direct POST, and a check on the page does not cover the action. Check the session and the row's owner inside the action and inside each Route Handler.
Does the free scan check RLS, logins, or Stripe webhooks?
No. The scan is a passive GET of the public page and same-site JavaScript (it stops starting new script batches at 25 files or 12 MB), plus /.env, /.git/config, security headers, and TLS. It looks for Stripe, OpenAI, Anthropic, and AWS keys, GitHub tokens, PEM private keys, Supabase sb_secret_ keys, and service_role JWTs. It does not test Row Level Security or grants, query the database, log in, or crawl, and it does not check auth or webhook signatures. Those checks are the sections above.
Sources
- Cursor: Ignore file
- Cursor: Ignore files
- Cursor: Agent security
- Cursor: Rules
- Next.js: Environment variables
- Next.js: Data security
- Next.js: Authentication
- Next.js: Renaming Middleware to Proxy
- Next.js: productionBrowserSourceMaps
- Vite: Env variables and modes
- Vite: build.sourcemap
- Supabase: Row Level Security
- Stripe: Receive Stripe events
- Stripe: Resolve signature verification errors
- Stripe: Dynamically update payment amounts
- Stripe: Accept a payment
- OWASP: HTTP Headers Cheat Sheet
- GitHub: Removing sensitive data from a repository
Check your app now — free, passive, about 20 seconds.
Same scanner as the homepage scan. Paste the live URL. It reads what a visitor already downloads. It does not log in or query your database.
Related guides
- GitHub token in the frontend
- Stripe secret key in the frontend
- CheckVibe alternatives
- OpenAI API key in the frontend
- Claude Code settings.local.json keys
- Bolt environment variables vs Secrets
- v0 app security checklist
- NEXT_PUBLIC_ and VITE_ API keys
- Lovable app data exposure check
- Supabase 42501 permission denied
- Supabase RLS checklist
- Bolt Supabase API key visible
- Supabase service_role key exposed
- Lovable app security check
- Is my vibe-coded app secure?
Scan by builder