You built an app with AI in a weekend. It works, it looks great, and you are ready to show it to the world. But somewhere between the first prompt and the deploy button, security got skipped entirely. This guide walks through the specific vulnerabilities that vibe-coded applications carry, why they happen, and exactly how to find and fix them before your users pay the price.

Photo by Noe Garde from Pexels

TL;DR:
  • AI code generators produce functional code that frequently contains exploitable security flaws, from SQL injection to hardcoded secrets.
  • Roughly 40% of AI-generated programs in academic testing contained vulnerabilities mapped to the CWE Top 25.
  • A structured audit workflow, free scanning tools, and a security-first prompting habit can close most of these gaps before you ship.

Why vibe-coded security gaps exist

AI coding assistants optimize for one thing: making the code work. When you prompt Cursor, Claude, or Copilot to "build a login page with email and password," the model generates code that compiles, runs, and handles the happy path. What it does not do is think about what happens when someone sends a malformed request, injects SQL into the email field, or intercepts the session token.

This is not a theoretical risk. The pattern repeats across thousands of vibe-coded projects every week: working software with open doors.

0%
AI-generated programs with exploitable vulnerabilities

Three root causes drive this:

  1. Training data bias - LLMs learned from millions of code samples, including insecure Stack Overflow answers, outdated tutorials, and hobby projects that never needed hardening.
  2. Context window limits - Security requires understanding the full system. An AI generating one file at a time cannot reason about cross-cutting concerns like authentication flows or data validation boundaries.
  3. Prompt gaps - If you do not ask for security, you do not get security. The model gives you what you described, nothing more.
Vibe-coded apps lacking input validation at launch
0%

Common vulnerabilities in AI-generated code

software developer coding laptop
Photo by olia danilevich from Pexels

Knowing the specific flaws helps you look in the right places. Here are the ones that show up most often in vibe-coded projects:

  • SQL Injection - AI frequently builds raw SQL queries with string concatenation instead of parameterized statements. One malicious input and your database is exposed.
  • Hardcoded secrets - API keys, database passwords, and JWT secrets end up directly in source files. The model puts them there because you mentioned them in the prompt.
  • Missing authentication checks - Routes that should require login get generated without middleware. The AI built the endpoint, not the guard.
  • Cross-Site Scripting (XSS) - User input rendered directly into HTML without sanitization. Common in AI-generated React, Next.js, and Express apps.
  • Insecure direct object references (IDOR) - Endpoints like /api/users/123 that let any authenticated user access any other user's data by changing the ID.
  • Overly permissive CORS - Access-Control-Allow-Origin: appears in nearly every AI-generated backend because it eliminates errors during development.
"Academic researchers who tested 1,689 AI-generated programs found that roughly 40% contained exploitable vulnerabilities, many mapping to the CWE Top 25."
>,
Vibe Coding Security: Risks and Tools
Warning: If your app handles user data, payments, or personal information, every item on this list is a potential compliance violation under GDPR, PCI-DSS, or SOC 2.

Step-by-step security audit process

startup team programming
Photo by cottonbro studio from Pexels

You do not need a security degree to audit a vibe-coded app. You need a repeatable process. Here is one that works, broken into five concrete steps.

Understanding the (in)security of vibe-coded applications: Practical Guide process
Figure 1: Understanding the (in)security of vibe-coded applications: Practical Guide at a glance.

1. Scan for secrets

Run git log --all --diff-filter=A -- '.env' '.key' and use a tool like Gitleaks or TruffleHog against your repository. Every hardcoded API key, database URL, or token needs to move into environment variables immediately. Rotate any secret that was ever committed, even if you deleted the file later. Git history remembers.

2. Map every route and check auth

List every API endpoint and page route in your application. For each one, answer: does this require authentication? Does it check authorization (is this user allowed to access this specific resource*)? AI-generated backends commonly have five or six routes where the auth middleware is missing. A simple spreadsheet with columns for route, method, auth required, and auth present catches these fast.

3. Test inputs with malicious data

For every form field, URL parameter, and API body field, try:
  • SQL injection payloads (' OR 1=1 --)
  • XSS payloads ()
  • Oversized strings (10,000+ characters)
  • Unexpected types (send a string where a number is expected)
Tools like OWASP ZAP automate this. Run ZAP's active scan against your local dev server before any deployment.

4. Review dependency security

Run npm audit (Node.js), pip audit (Python), or the equivalent for your stack. AI assistants often pin outdated package versions or pull in libraries with known CVEs. Update or replace anything flagged as high or critical severity.

5. Lock down deployment config

Check your CORS settings, ensure HTTPS is enforced, verify that debug mode is off, and confirm that error messages do not leak stack traces or database details to the client. AI-generated deployment configs almost always need tightening.

Tools and workflows that help

programmer working screen
Photo by Zayed Hossain from Pexels

You do not need expensive enterprise tools. These free and open-source options cover the critical bases:

The following dashboard shows a realistic example of what a security scan might reveal for a typical vibe-coded project before any hardening:

🔒 Pre-Audit Scan: Typical Vibe-Coded App

Hardcoded Secrets Found4
Unprotected API Routes7 / 12
SQL Injection Points3
XSS-Vulnerable Fields5
Outdated Dependencies (High/Critical)9
CORS Properly ConfiguredNo → Yes after fix

Example data based on common findings across vibe-coded Node.js/Next.js projects

ToolWhat It CatchesCost
GitleaksHardcoded secrets in git historyFree
OWASP ZAPXSS, injection, misconfig via active scanningFree
npm audit / pip auditKnown CVEs in dependenciesFree
SemgrepCode-level patterns (SQLi, IDOR, auth gaps)Free tier
SnykDependency + container vulnerabilitiesFree tier

Build security into your prompts

The cheapest fix is prevention. When prompting your AI assistant, add explicit security requirements:

  • "Use parameterized queries for all database access"
  • "Add authentication middleware to every route except /health and /login"
  • "Store all secrets in environment variables, never in source code"
  • "Sanitize all user input before rendering in HTML"
  • "Set CORS to allow only https://myapp.com"
This does not guarantee perfect output, but it shifts the baseline dramatically. The Vibe Coding Bible at vibecodingbible.org covers prompt engineering for secure code generation in depth, with templates you can copy directly into your workflow.
Pro tip: Create a SECURITY_RULES.md file in your project root listing your security requirements. Reference it in every AI prompt session. This acts as persistent context that the model can follow.
Key takeaway: AI code generators produce working software, not secure software. A 30-minute audit using free tools catches the majority of critical vulnerabilities before they reach production.
|

Vibe-Coded App Security Audit Checklist

Your progress is saved automatically in your browser.

FAQ

Frequently Asked Questions

This guide is for anyone shipping applications built with AI coding tools like Cursor, Claude, Copilot, Lovable, or v0. You do not need a security background. If you can follow a terminal command and read your app's code, you can complete every step here. It is especially relevant if you are a founder, indie hacker, or builder without a traditional computer science background who is putting AI-generated code into production.
For a typical vibe-coded application with 10-20 API routes and a single database, expect 2-4 hours for the first pass. Secret scanning takes minutes. Route mapping takes 30-60 minutes depending on your app size. Input testing with OWASP ZAP runs in 15-30 minutes. Dependency auditing is nearly instant. The biggest time investment is fixing what you find, not finding it.
Start with secret scanning. Hardcoded API keys and database passwords are the highest-impact, lowest-effort vulnerability to fix. Run Gitleaks, move secrets to environment variables, and rotate anything that was exposed. This single step eliminates the most dangerous class of vulnerability in under 30 minutes.
Partially. You can prompt your AI assistant to refactor specific files with security requirements, and it will often produce correct fixes for straightforward issues like parameterized queries or input sanitization. But you still need to verify the output. Do not trust the AI to catch its own blind spots. Use the scanning tools listed above as your verification layer.
No. This guide covers the baseline hygiene that catches the most common and most exploitable flaws. If your application handles sensitive data, financial transactions, or operates in a regulated industry, a professional pentest is still worth the investment. But running this audit first means the pentest finds edge cases instead of embarrassing basics.

What was the first security issue you discovered in your own vibe-coded project? Share your experience below.

Additional Resources