Understanding the (in)security of vibe-coded applications: Practical Guide
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.

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.
Three root causes drive this:
- Training data bias - LLMs learned from millions of code samples, including insecure Stack Overflow answers, outdated tutorials, and hobby projects that never needed hardening.
- 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.
- Prompt gaps - If you do not ask for security, you do not get security. The model gives you what you described, nothing more.
Common vulnerabilities in AI-generated code
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/123that 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
Step-by-step security audit process
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.
1. Scan for secrets
Run git log --all --diff-filter=A -- '
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)
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
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
Example data based on common findings across vibe-coded Node.js/Next.js projects
| Tool | What It Catches | Cost |
|---|---|---|
| Gitleaks | Hardcoded secrets in git history | Free |
| OWASP ZAP | XSS, injection, misconfig via active scanning | Free |
| npm audit / pip audit | Known CVEs in dependencies | Free |
| Semgrep | Code-level patterns (SQLi, IDOR, auth gaps) | Free tier |
| Snyk | Dependency + container vulnerabilities | Free 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"
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.Vibe-Coded App Security Audit Checklist
Your progress is saved automatically in your browser.
FAQ
Frequently Asked Questions
What was the first security issue you discovered in your own vibe-coded project? Share your experience below.
Additional Resources
- Understanding the (In)Security of Vibe-Coded Applications - In this paper, we conduct a systematic study of the security of vibe-coded applications. We collect a large corpus of real-world applications ...
- Vibe Coding Security: Risks and Vulnerabilities - This guide covers vibe coding security in practical terms. We break down the biggest risks, share a checklist your team can put to work this ...
- Secure Vibe Coding Guide | Become a Citizen Developer - AI-generated code isn't inherently secure. This guide is designed to help you bridge that gap, only innovative but also secure. Understand ...
Ready to Master Vibe Coding?
Learn to build software faster with AI assistance using the Vibe Coding Bible.
Get Started