The Vibe Coding Security Checklist: 10 Critical Flaws in AI-Generated Software
The Vibe Coding Security Checklist: 10 Critical Flaws in AI-Generated Software
AI coding tools like Cursor, Claude Code, Lovable, v0, and ChatGPT are trained to solve one specific objective: generate code that fulfills the user's prompt as quickly as possible.
They are not incentivized to ensure defense-in-depth, least privilege, or cryptographic hygiene.
When teams move fast and ship "vibe-coded" prototypes directly to production, they frequently introduce severe vulnerabilities that automated security scanners and ethical hackers exploit in minutes.
Here is the 10-Point Security Audit Checklist we use at Silver Stack Software when auditing and hardening AI-generated software.
1. Exposed Client-Side Secrets & API Keys
The Vulnerability: AI assistants often place private API keys (Stripe secret keys, AWS credentials, database passwords) into client-side environment variables (NEXT_PUBLIC_* or REACT_APP_*) so frontend components can fetch data directly.
The Fix: Audit all .env files. Ensure secrets are never prefixed with public flags, and route all third-party API calls through server-side API routes or Server Actions.
2. Insecure Direct Object References (IDOR)
The Vulnerability: AI frequently writes endpoints like GET /api/invoices/:id that fetch and return records using the requested ID without verifying that the authenticated user actually owns that invoice.
// ❌ VULNERABLE: Any logged-in user can view any invoice by guessing ID
export async function GET(req: Request, { params }: { params: { id: string } }) {
const invoice = await db.invoice.findUnique({ where: { id: params.id } });
return Response.json(invoice);
}
The Fix: Scope every database query by tenant and user identity:
// ✅ SECURE: Query scoped strictly to authenticated session
const invoice = await db.invoice.findFirst({
where: { id: params.id, organizationId: session.user.orgId }
});
if (!invoice) return new Response('Not Found', { status: 404 });
3. Missing Server-Side Role-Based Access Control (RBAC)
The Vulnerability: AI models often hide admin buttons on the UI ({user.isAdmin && <AdminPanel />}), but forget to check user roles inside the underlying backend API endpoint. Malicious users can send raw POST requests directly to /api/admin/delete-user.
The Fix: Enforce authorization middleware on every backend route, independent of frontend UI state.
4. Raw Unescaped SQL Queries & Injection Risks
The Vulnerability: When asked to implement complex filtering, AI models occasionally concatenate raw strings into SQL queries rather than using parameterized inputs.
// ❌ VULNERABLE: SQL Injection via string interpolation
const query = `SELECT * FROM users WHERE email = '${userEmail}'`;
The Fix: Always enforce parameterized queries or strictly typed ORM builders (Prisma, Drizzle, EF Core).
5. Unrestricted File Upload Endpoints
The Vulnerability: AI-generated file upload routes often trust client-provided file names and MIME types, allowing attackers to upload malicious .php, .sh, or executable files directly into public storage.
The Fix: Generate random UUID file names on the server, validate file magic bytes (not just extensions), and store uploaded assets in isolated cloud buckets with public execution permissions disabled.
6. Weak Password Hashing & Insecure JWTs
The Vulnerability: AI models frequently implement authentication using outdated MD5 or SHA-256 hashing, or sign JSON Web Tokens with hardcoded fallback secrets like "secret123".
The Fix: Use modern adaptive hashing algorithms (Argon2id or bcrypt with cost factor >= 12), and enforce cryptographically random 256-bit signing secrets.
7. Missing Rate Limiting & DoS Vulnerabilities
The Vulnerability: AI assistants write authentication and search endpoints without request throttling. Attackers can flood the endpoint with millions of requests, causing CPU exhaustion or massive third-party API bills. The Fix: Deploy edge rate-limiting middleware (via Redis / Upstash) restricting requests by IP and session.
8. Cross-Site Scripting (XSS) via dangerouslySetInnerHTML
The Vulnerability: When asked to render rich text or markdown, AI tools frequently reach for dangerouslySetInnerHTML without sanitizing input.
The Fix: Use strict HTML sanitization libraries (DOMPurify) to strip executable JavaScript tags before rendering.
9. Dependency Supply Chain Hallucinations
The Vulnerability: Large Language Models sometimes hallucinate package names that do not exist in npm. Attackers register these hallucinated package names with malicious payloads.
The Fix: Run npm audit and verify every package in package.json against official registries and download counts.
10. Missing Audit Logs & Unchecked Error Messages
The Vulnerability: AI code often logs full stack traces and internal database schemas directly into HTTP 500 error responses delivered to the client.
The Fix: Catch all unhandled exceptions, log detailed traces to private server telemetry, and return generic, sanitized error messages to the browser.
The Verdict
Vibe coding accelerates prototype development from months to days. But before you launch to real customers, a rigorous security audit is non-negotiable.
Need an independent security and architecture audit of your AI-built software? Contact Silver Stack Software to schedule a comprehensive code review.
READY TO IMPLEMENT THIS?
We specialize in turning these high-impact engineering concepts into production-grade systems.