Skill Details
Runtime
Any model
Example user message
[userMessage]: Security-check this Cursor change before I merge it. This is a multi-tenant Next.js SaaS app. Audit security only and do not edit the code. ```ts export async function POST(req: Request) { const session = await getSession(); if (!session) return Response.json({ error: "login required" }, { status: 401 }); const { teamId, email, role } = await req.json(); try { const member = await db.member.create({ data: { teamId, email, role } }); return Response.json(member); } catch (error) { return Response.json({ error: error.message }, { status: 500 }); } } ``` The current tests cover only a team owner inviting a normal member.
Example agent response
CURSOR AI CODE SECURITY GATE
#### Scope
- Reviewed: The supplied team-invitation route and described happy-path test.
- Excluded: Session implementation, database schema, middleware, deployment,
dependency manifest, and runtime traffic.
- Evidence gaps: The session shape and any database-level tenant policy were not
provided.
#### Verdict: BLOCK RELEASE
Reason: The route accepts tenant identity and privilege level from the request
without a supported server-side authorization decision.
#### Trust-boundary map
Request body -> authenticated session -> no team-owner or admin decision ->
membership creation with caller-selected role -> full member record returned.
#### Findings
F1 — CRITICAL — CONFIRMED — Caller controls tenant and role
Evidence: `POST()` reads `teamId` and `role` from `req.json()` and passes both
directly into `db.member.create()`; the visible route checks login only.
Impact: Any authenticated caller reaching this route can attempt to create a
membership in another team or assign a privileged role.
Fix: Derive the acting user from the server session, verify that user can invite
members to the selected team, and map the requested role through an explicit
server-side allowlist before the write.
Regression test: Call the route as a non-admin user with another team's id and
an admin role; require a 403 response and verify that no membership is created.
F2 — MEDIUM — CONFIRMED — Raw internal error returned
Evidence: The catch block returns `error.message` in the HTTP response.
Impact: Database or internal implementation details can be exposed to callers.
Fix: Log a redacted internal error server-side and return a stable generic error
code to the client.
Regression test: Force a database failure; require a generic 500 response with
no table, query, stack, or connection details.
F3 — MEDIUM — CONFIRMED — Negative authorization tests missing
Evidence: The supplied test description covers only an authorized owner invite.
Impact: Cross-tenant and privilege-escalation regressions can merge undetected.
Fix: Add non-admin, cross-tenant, invalid-role, and unauthenticated cases.
Regression test: Run all four negative cases and require refusal with no write.
#### Eight-check ledger
- C1 Authentication and identity — CLEAN WITH LIMIT: A session is required, but
session validation internals were not supplied.
- C2 Authorization and tenant ownership — FINDING: F1.
- C3 Input and execution boundary — FINDING: `teamId` and `role` reach the write
without visible validation.
- C4 Secret and configuration exposure — NOT APPLICABLE to the supplied code.
- C5 Client/server enforcement parity — UNVERIFIED: No client code was supplied.
- C6 Security control connectivity — UNVERIFIED: No middleware or policy helper
was supplied.
- C7 Dependency and supply-chain change — UNVERIFIED: No manifest or lockfile.
- C8 Tests and failure behavior — FINDING: F2 and F3.
#### Fix order
1. Add server-side team authorization and role allowlisting.
2. Add cross-tenant and privilege-escalation tests.
3. Replace raw error responses with a bounded client error.
#### Limits
This verdict covers only the supplied route and test description. It does not
establish the security of the whole SaaS application.
---
By purchasing this skill, you agree to our terms of service
Audit the current Cursor workspace, working-tree diff, or staged changes for authorization gaps, unsafe input flow, exposed secrets, client-only enforcement, unwired security controls, dependency uncertainty, and missing negative tests. Produces an evidence-bounded release verdict without modifying code or claiming the whole application is secure.
...more
Added 1 week ago
