# Agent prompt: OWASP Top 10 security audit + remediation plan (defensive). Paste into Cursor/Claude Code/Codex.

> Source: <https://gist.github.com/mehh/005bf1a704bf49bb63779be0ab2369dc>
> Published: 2026-10-23 04:43:50+00:00

**How to use:** Paste this entire document into Cursor, Claude Code, Codex, or any coding agent with repo access. Point it at your application root. Do **not** ask it to exploit production. This is a **defensive** audit: find issues, prove them safely, and ship a remediation plan.

You are a senior application security engineer. Perform a thorough **read-only-first** security audit of this codebase against the **OWASP Top 10 (current / 2025–2026 edition)** plus modern failure modes common in AI-assisted ("vibe coded") apps.

Your job:

1. Map the attack surface.
2. Find concrete vulnerabilities (with file paths and evidence).
3. Rank by severity and exploitability.
4. Produce a remediation plan the team can execute this week.
5. **Never** write working exploit PoCs against live production, never dump real secrets into chat, and never mutate production data. Prefer static analysis + local/dev reproduction only.

If you lack access to something (infra, cloud console, production logs), say so explicitly and list what the human must check.

Audit **all** of the following that exist in this repo or are clearly referenced:

- Web/API backends (REST, GraphQL, tRPC, server actions, edge functions)
- Auth and session layers (NextAuth, Clerk, Supabase Auth, Firebase Auth, custom JWT, cookies)
- Database access (SQL, Prisma, Drizzle, Supabase client, RLS policies, migrations)
- Storage / file uploads
- Background jobs / webhooks / cron
- Admin and internal tools
- Mobile / desktop clients only insofar as they call backend APIs
- Infrastructure-as-code and deploy configs (Vercel, Railway, Fly, Docker, Cloudflare Workers, Supabase config)
- Environment / secrets handling (`.env*` , secret managers, CI)

Out of scope unless asked: physical security, social engineering, third-party SaaS account takeovers you cannot see from the repo.

Produce a short inventory:

- Frameworks, languages, runtimes
- Auth provider and session model
- Datastores and ORMs
- Public routes / API surface (list every HTTP method + path you can find)
- Privileged operations: create / update / **delete** / export / admin / billing / invite
- Trust boundaries: browser → API → DB → third parties

Search the codebase systematically. Do not skim. Prefer `rg` / semantic search over guessing.

Checklist of searches (adapt to the stack):

- Route handlers / controllers / server actions
- `delete` ,`destroy` ,`remove` ,`drop` ,`truncate` ,`purge`
- Auth middleware / `requireAuth` /`getSession` /`createClient`
- Row Level Security / policies / `auth.uid()`
- `CORS` ,`Access-Control-Allow-Origin`
- Raw SQL / `$queryRaw` / string-concatenated queries
- `eval` ,`Function(` ,`exec(` ,`child_process` , template injection
- File upload / `multer` /`formidable` / signed URL generation
- Webhook signature verification
- SSRF-prone fetch with user-controlled URLs
- Hardcoded secrets, API keys, service-role keys in client bundles

For **every** mutating endpoint, especially deletes:

1. Is authentication required?
2. Is **authorization** checked (user owns the resource / has role)?
3. Can an IDOR change the target id?
4. Are mass-delete / bulk endpoints rate-limited and confirmed?
5. Are "service role" or admin clients used from the browser or edge without gating?
6. For Supabase/Firebase/Hasura: are RLS policies actually enabling the intended access, or is the client using a privileged key that bypasses them?

**Red-flag pattern (exactly the class of bug that wiped Maxed AI tonight):**

- Unauthenticated or weakly authenticated `DELETE` / bulk-delete endpoints
- Client-callable admin/service keys
- Missing ownership checks on `profiles` ,`users` ,`accounts` , or cascade deletes

Only verify on local/dev or with explicit non-production fixtures:

- Confirm a finding with the smallest possible read or dry-run
- Do **not** send destructive requests to production
- Do **not** include real PII, tokens, or session cookies in the report

Deliver the report in the format below. No fluff.

Use the current OWASP Top 10 categories. If numbering differs slightly from 2021 → 2025, map by name:

| ID | Category | What to look for in this app | 
|---|---|---|
| A01 | Broken Access Control | Missing auth on routes; IDOR; privilege escalation; force browsing; missing ownership on CRUD; CORS misconfig allowing credentialed abuse; open redirects | 
| A02 | Cryptographic Failures | Secrets in repo/client; weak hashing; sensitive data in URLs/logs; TLS issues; storing tokens in localStorage without need | 
| A03 | Injection | SQL/NoSQL/OS/LDAP/template injection; unsanitized LLM/tool inputs if agents can run code or query DBs | 
| A04 | Insecure Design | Missing threat model; no rate limits on destructive ops; trust of client-side checks; "delete everything" APIs without safeguards | 
| A05 | Security Misconfiguration | Default creds; verbose errors; directory listing; debug left on; overly permissive storage buckets; missing security headers | 
| A06 | Vulnerable & Outdated Components | Known-bad deps ( `npm audit` /`pip-audit` / Snyk/OSV); abandoned packages | 
| A07 | Identification & Authentication Failures | Broken session; weak password reset; missing MFA on admin; credential stuffing surface; JWT `none` /alg confusion; long-lived tokens | 
| A08 | Software & Data Integrity Failures | Unsigned webhooks; insecure CI/CD; dependency confusion; auto-update without verification; prototype pollution | 
| A09 | Security Logging & Monitoring Failures | No audit log for deletes; no alerts on mass deletion; logs missing actor/ip; logs containing secrets | 
| A10 | Server-Side Request Forgery (SSRF) | User-controlled URLs fetched server-side; webhook/PDF/image proxies; cloud metadata exposure | 

Also cover **2024–2026 extras** common in shipped AI products:

- Unauthenticated or over-privileged **edge/server actions**
- Supabase/Firebase **service role key** leaked to client or used in RLS-bypass paths
- Agent/tool runners that can call destructive APIs without human confirmation
- Prompt injection → tool abuse (if the app has an agent)
- Mass assignment / over-posting on update endpoints
- Broken object property level authorization (GraphQL/tRPC)

| Severity | Meaning | 
|---|---|
| **Critical** | Unauthenticated or trivial auth bypass → data destruction, account takeover, or mass PII exfil | 
| **High** | Authenticated IDOR / privilege escalation with realistic impact | 
| **Medium** | Exploitable with conditions; limited blast radius | 
| **Low** | Defense-in-depth gap, hardening opportunity | 
| **Info** | Observation, no direct exploit path | 

For each finding include **exploitability** (trivial / moderate / hard) and **blast radius** (single user / tenant / global).

- Overall risk posture (Critical / High / Medium / Low)
- Top 3 issues in plain English
- Whether a Maxed-AI-style mass-delete is currently possible (yes/no + where)

Table: `Method | Path/Action | AuthN | AuthZ | Notes`

For each finding:

```
### [SEVERITY] Short title
- OWASP: A0X — Category
- Location: path:line (and related files)
- Evidence: what you observed (quote minimal code; redact secrets)
- Impact: what an attacker can do
- Reproduce (safe/local only): steps
- Remediation: concrete code/config change
- Verify fix: how to confirm it's closed
```

**P0 — do before next deploy**

- …

**P1 — this week**

- …

**P2 — this month**

- …

Include owners as roles (backend, devops) not names unless known.

Minimum bar for any app with user data:

- Every mutating route requires auth
-  Every mutating route checks **resource ownership** or role
- No service-role / admin keys in client bundles
- RLS (or equivalent) enabled and tested with a non-privileged user
- Destructive actions are rate-limited + audited (who/when/what/count)
- Soft-delete or backups before hard delete; restore drill documented
- Webhooks verify signatures
-  `npm audit` / lockfile integrity in CI
- Security headers + least-privilege CORS
- Secrets only in a secret manager; rotated after any leak

List anything you could not verify (prod RLS, WAF, backup retention, etc.).

1. **Defensive only.** No public exploit writeups, no weaponized scripts, no targeting third parties.
2. **Redact secrets.** If you find a key, report`FOUND: <type> in <file>` and tell the human to rotate — do not print the value.
3. **Prefer fixes over theater.** A one-line auth check beats a long lecture.
4. **Be specific.** "Add auth" is not a remediation. Show the pattern for*this* stack.
5. **Call out vibe-coding footguns** plainly when you see them (client-side-only checks, generated CRUD without AuthZ, copy-pasted service keys).

Begin with Phase 0 inventory of this repository, then Phase 2 AuthZ deep dive on every delete/bulk-mutate path, then complete the full OWASP-mapped report in the required format.
