AppSec Architecture··6 min read

Why vibe-coded apps fail authorization audits and how to verify routes first

Fast AI-generated handlers often pass syntax and type checks while trusting client-supplied tenant IDs or skipping server-side role assertions.

Key takeaway

Track every route and mutation in coverage-ledger.json first, then run a paired User A vs User B check before any deploy.

Where AI-generated CRUD routes break silently

When you scaffold an app at high speed in Cursor, Claude Code, or Antigravity, the happy path works on day one. A logged-in test user clicks a button, sends an order ID or document ID, and the handler updates Postgres.

The hidden bug appears when that handler filters strictly by primary key without binding the query to session.userId or session.orgId. Authentication exists on the route, so basic smoke tests return 200 OK, yet any authenticated user can cancel or read a stranger's record.

Vulnerable vs scoped mutation handler
// Vulnerable: looks up by id alone after checking session exists
const order = await db.orders.update({ where: { id: req.params.id }, data: { status: "cancelled" } });

// Verified fix: ownership bound inside the database predicate
const updated = await db.orders.updateMany({
  where: { id: req.params.id, userId: session.user.id },
  data: { status: "cancelled" },
});

Stop running one-line audit prompts

Asking a model to audit an entire repo in one turn pushes the context toward generic noise. It frequently labels missing HTTP headers as High severity while overlooking Next.js server actions or secondary REST handlers.

AegisSec breaks the audit into deterministic reconnaissance, scoped hunting waves, and an independent verification pass that tries to disprove every claim.