Vibe Coding Playbook: AppSec-First AI Development.
Hospitality and quality control teach you one lesson fast: the gap between "works in rehearsal" and "works at 2 a.m. when nobody is watching" comes down to whether you modeled failure before opening the doors. AI code generation is fast and syntactically confident. Its failure modes cluster at auth boundaries, multi-tenant queries, and unvalidated inputs.
Model failure modes before you prompt.
"Confident output and correct output are independent variables. At security boundaries they often move in opposite directions."
Implicit permission assumptions: Models treat "authenticated" as "authorized." Row-level ownership, tenant isolation, and role checks never appear unless explicitly required.
Context window drift: Early turn assumptions bleed silently into turn-fourteen data queries. Verify against your written schema, never chat memory.
Unvalidated arguments: Generated handlers assume clean inputs. Control-character stripping, Zod bounds, and enum locks have to be enforced at the boundary.
In a live project audit, invite_codes and api_keys passed every functional test with Row-Level Security disabled. Any signed-in user could query every row across tenants.
On 01/31/2026, Moltbook exposed 1.5 million API tokens and 35,000 email addresses from the exact same gap: Supabase RLS left off while happy-path tests stayed green.
Architecture-first is non-negotiable.
Write system boundaries, data flows, state transitions, auth lifecycles, dependency failure behavior, and abuse vectors before prompting for code. Enforce progression with an explicit SCOPE_MODE gate:
Full boundary specification, entity RLS rules, server-function Zod contracts, and ordered file plan before any component code runs.
HTTP Production Audit Proof: An end-to-end domain audit on an unmodeled build caught four silent architectural omissions: missing HSTS header, absent Content Security Policy, unthrottled auth endpoints, and accepted null-byte path inputs.
Security prompting is a discipline, not a checkbox.
Run this exact 7-question pass on every auth handler, server function, database query, and input parser before merging:
Adversarial security review. For the code above, answer each question: 1. UNTRUSTED INPUT: Which function parameters could carry user-controlled data? Is each one validated before use? 2. SQL / QUERY CONSTRUCTION: Is any query assembled via string concatenation? If so, where and with what input? 3. CONCURRENCY: Are there race conditions possible under concurrent requests? Identify any shared mutable state. 4. DATA EXPOSURE: What data does this return or log? Is any of it sensitive? Is it scoped to the requesting user or tenant? 5. FAIL BEHAVIOR: Does this fail open or fail closed? What is the default behavior on error? 6. IMPLICIT PERMISSIONS: Does this code assume that authentication implies authorization? Where? 7. MISSING VALIDATION: What inputs, states, or edge cases are not covered by explicit validation?
Calibrate review depth to blast radius.
Pair CI smoke checks, CODEOWNERS on sensitive paths, separate RLS migration checklists, unit/E2E gates (529+ tests on flagship builds), and staged canary verification with the trust matrix below:
| Output Type | Trust Level | Required Gate |
|---|---|---|
| Auth handlers / session logic | Never trust | Full adversarial review + CODEOWNERS sign-off |
| Data access / RLS-adjacent queries | Low trust | RLS policy review + tenant scope verification |
| API endpoints / input handling | Low trust | Zod input validation + 7-question adversarial pass |
| Business logic / state machines | Medium trust | Unit test coverage + edge-case verification |
| UI components / presentational markup | Higher trust | Standard code review and accessibility check |
Abstrekkt publishes this AppSec specification openly. Organizations under 200 people needing a guided Shadow AI audit, 14-template governance rollout, and internal champion training engage through Loxihart.