The 6 Pre-Launch Security Bugs That Keep Breaking AI-Built SaaS Apps (And How to Catch All 30 Patterns Locally in 30ms)
Building a full-stack SaaS with Next.js, Supabase, Stripe, and OpenAI has never been faster. Unfortunately, shipping a critical vulnerability on day one has never been easier either. While building a deterministic pre-l
Building a full-stack SaaS with Next.js, Supabase, Stripe, and OpenAI has never been faster. Unfortunately, shipping a critical vulnerability on day one has never been easier either.
While building a deterministic pre-launch scanner (ShipGate PRO), I cataloged the 30 highest-impact security failures across modern indie SaaS and AI-assisted codebases β and grouped them into 6 concrete failure modes every developer should verify before hitting Deploy.
1. Supabase Row Level Security (RLS) Traps
Creating a table in supabase/migrations/001_init.sql without ALTER TABLE ... ENABLE ROW LEVEL SECURITY; leaves that table exposed via PostgREST to anyone holding your public anon key.
Just as common: enabling RLS, then adding an overly broad policy to "make it work":
-- Dangerous: any logged-in user can overwrite or delete other customers' rows
CREATE POLICY "profiles_allow_all" ON public.profiles
FOR ALL USING (true) WITH CHECK (true);
Fix: Always pair ENABLE ROW LEVEL SECURITY with explicit owner predicates (auth.uid() = user_id), and check migrations across all SQL files so multi-file migrations don't create false alarms.
2. Server-Side supabase.auth.getSession() & Unprotected "use server" Actions
Two Next.js footguns that slip past code review constantly:
- Using
supabase.auth.getSession()insidemiddleware.tsor API routes instead ofsupabase.auth.getUser().getSession()trusts unverified cookie payloads on the server;getUser()validates the JWT with Supabase Auth. - Forgetting that
"use server"Server Actions compile into public HTTP POST endpoints. If an action callsprisma.workspace.delete(...)without checking the authenticated user and record ownership, anyone can invoke it withcurl.
3. Mass Assignment & IDOR in "Simple" CRUD Routes
// Vulnerable: attacker sends { "role": "admin", "credits": 99999 }
const body = await req.json();
await prisma.user.update({ where: { id: user.id }, data: body });
Always parse incoming JSON with a strict allowlist schema (Zod / Pydantic) and scope every update/delete query by BOTH id AND userId: user.id.
4. Payment Webhooks Without Signature Verification or Idempotency
If your /api/stripe/webhook handler runs const event = await req.json() without stripe.webhooks.constructEvent(rawBody, sig, secret), any attacker can forge checkout.session.completed and grant themselves Pro access.
And even when signatures are verified, skipping event.id deduplication means Stripe's automatic webhook retries can double-credit accounts.
5. Public AI Endpoints (The Overnight API Wallet-Drain Bug)
An exported POST /api/ai/chat calling openai.chat.completions.create(...) without:
- User authentication (
getUser()) - Per-user rate limiting (e.g., Upstash Ratelimit)
- An explicit
max_tokenscap
...is an open proxy to your credit card.
6. Client-Bundled Secrets (NEXT_PUBLIC_*) & Missing Headers
Prefixing a service key with NEXT_PUBLIC_ or VITE_ bakes it directly into browser JavaScript. Similarly, shipping next.config.mjs with ignoreBuildErrors: true and zero CSP / HSTS / X-Frame-Options headers silently degrades production security.
Automating All 30 Checks Locally (With Auto-Fix Packs)
To avoid manually grepping through every repo before launch β and without uploading private client source code to third-party SaaS scanners β I packaged all 30 checks into ShipGate PRO:
- Zero-cloud local Web Studio + CLI (Python + FastAPI, runs in ~30ms)
-
Drag & Drop
.zipsupport (works straight off Lovable / Bolt.new / v0 / Replit / GitHub exports) -
Auto-Fix Pack (
.zip): auto-generatesfix_supabase_rls.sql,security_headers_patch.js, and targeted 1-click AI fix prompts per finding -
White-Label HTML/PDF Client Report + SARIF 2.1.0 for GitHub Actions (
--fail-on high)
Every rule is tested against both vulnerable fixtures and paired hardened negative controls (30/30 coverage, 0 false positives).
Check it out here: https://czechaieu.gumroad.com/l/shipgate-pro
ShipGate PRO β Local Pre-Launch Security & Auto-Fix Studio by Ε tefan Bohumel
Read more about ShipGate PRO β Local Pre-Launch Security & Auto-Fix Studio by Ε tefan Bohumel on Contra.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.