Vibe Coding Security: How to Ship AI-Built Apps Without Getting Hacked
What the 2026 research says about AI-generated code, the ten security risks that show up in almost every vibe-coded app, how to fix each one, and how to scan your own codebase for free before an attacker does.
If you built an app with Cursor, Lovable, Bolt, v0, Replit, or Claude Code and you are about to put it in front of real users, this guide is for you. It is written for founders and developers who ship fast with AI, not for security teams. Every risk below comes with a plain-language explanation of what the AI got wrong, why it keeps getting it wrong, and the specific fix. The last third of the guide shows you how to check your own codebase in a few minutes using a free, open-source scanner that runs inside the coding tool you already use.
The short version: vibe coding is not inherently unsafe, but the output is unsafe by default. The tools are optimised to make code work, and working code and secure code are different targets. Until you verify, assume the gaps are there.
Is Vibe Coding Safe?
Not out of the box. Every independent study published in 2025 and 2026 that looked at AI-generated applications reached the same conclusion: the code usually works, and it usually has at least one serious security hole. That is true across tools, across models, and across model generations. The functional quality of AI code has improved dramatically. The security quality has barely moved.
The numbers below are from peer-reviewed research, vendor-neutral security labs, and large passive scans of live production apps. Full citations are at the end of the guide.
Two of these deserve a closer look. The Carnegie Mellon team behind the SUSVIBES benchmark gave coding agents 186 real repository tasks where human developers had previously shipped a vulnerability, then checked whether the agent's solution was both correct and secure. The best combination they tested was functionally correct 57% of the time and secure 11.8% of the time. The agents were solving the problem. They were not solving it safely.
Veracode has run the same 80 tasks against every major model since 2023. Over that period the syntax pass rate climbed from roughly 50% to 95%. The security pass rate stayed between 45% and 55% the entire time, regardless of which model or when it was released. Cross-site scripting and log injection, the two flaws that require reasoning about how data flows across several files, passed only 15% and 13% of the time in the Spring 2026 update. Newer models write better code. They do not write safer code.
So the honest answer to “is vibe coding safe?” is: it is exactly as safe as your verification step. Teams that scan and fix before launch ship apps that hold up. Teams that trust the output become the statistics above.
What Is Vibe Coding, and Why Is Security Its Blind Spot?
Vibe coding is the practice of building software primarily through AI coding assistants. Instead of writing every line by hand, you describe what you want in natural language and let tools like Cursor, Lovable, Bolt, v0, and Claude Code generate the implementation. You set the direction; the AI writes the code. Andrej Karpathy coined the term in February 2025, and within about 16 months it had moved from a hobbyist technique to something enterprise security teams were writing governance notes about.
This approach has dramatically lowered the barrier to shipping software. Solo founders launch SaaS products in a weekend. Designers build functional prototypes without backend experience. Teams that used to spend months on an MVP now ship in days. The productivity gains are real and they are not going away.
But speed creates blind spots. When you move from idea to deployed app in hours, entire categories of requirements get skipped, not because you are careless but because AI tools don't surface what they don't build. Security is the most dangerous of these blind spots, because the consequences are invisible until someone exploits them. A missing feature is obvious. A missing authorization check looks identical to a working one until the wrong user requests the wrong record.
Why AI-Generated Code Has Security Gaps
AI coding tools are optimized for a specific outcome: generating code that works. When you ask Cursor to build a login page, it produces a login page that accepts credentials and authenticates users. That is what you asked for, and it delivers. What it does not do, unless you specifically request it, is add rate limiting to prevent brute force attacks, set session expiration policies, implement account lockout after failed attempts, or log authentication events for monitoring.
This is not a flaw in any single tool. It is structural. These models are trained on vast quantities of open-source code, tutorials, and documentation, and most of that source material demonstrates functionality, not hardening. A Stack Overflow answer showing how to handle file uploads rarely includes MIME type validation, size limits, or storage isolation. The AI learns to replicate what it has seen most often, which is code that works in development.
The 2026 study of 9,041 AI-built applications traced the recurring failures back to three kinds of defect. Memory defects: the agent forgets a constraint it established earlier in the session, such as which routes need an admin check. Objective defects: the agent optimises for the stated goal (“make the dashboard load”) at the expense of an unstated one (“only for this user's data”). Knowledge defects: the agent does not know a framework's secure default has to be switched on, or reaches for a package that does not exist. Better prompting reduces all three. It does not eliminate them.
Tenzai's comparison of five coding agents found the same split from a different angle. The agents were good at avoiding flaws with a generic fix, such as SQL injection, where “always use parameterized queries” is the whole answer. They were bad at flaws where safe and dangerous depend on context: whether this particular endpoint should require admin, whether a price can be negative, whether a user-supplied URL should be fetched at all. Those are exactly the decisions your app's security rests on, and they are the ones you have to check.
The Top Vibe Coding Security Risks
These ten categories account for the overwhelming majority of findings in every audit of AI-generated code published to date. They are ordered roughly by how often they appear and how much damage they do.
1. Broken Access Control
This is the single most common vulnerability in vibe-coded apps, and the one AI tools are structurally worst at. The pattern is consistent: the AI checks whether a request comes from a logged-in user, and then trusts whatever ID that user supplies. Change the number at the end of /api/invoices/1042to 1043 and you are reading someone else's invoice. Security researchers call this an insecure direct object reference, or IDOR. The 2026 audit of 200 deployed AI-built apps found broken access control was the leading vulnerability class, and Tenzai found every agent it tested skipped ownership checks somewhere.
The fix is a discipline, not a library: every query that returns or mutates a resource must be scoped to the current user or their organisation, and every admin-only route must verify the admin role on the server, not just hide the button in the UI. Tell your AI tool explicitly, in a rules file, that authentication and authorization are separate checks and both are required.
2. Authentication Vulnerabilities
Authentication is the front door to your application, and AI-generated auth code consistently leaves it unlocked. The most common issue is missing rate limiting: without it, an attacker can attempt thousands of password combinations per second with no friction. AI tools also generate sessions that never expire, meaning a stolen token grants permanent access.
Other frequent gaps include predictable password reset tokens (sequential IDs or short numeric codes that can be brute-forced), missing multi-factor authentication, and session tokens that are not invalidated on password change. If you built auth with an AI tool, these are the first things to check. See the full authentication checklist for a complete audit guide.
3. Exposed API Keys and Secrets
AI coding assistants frequently place API keys directly in source code. When you ask an AI to integrate with Stripe, Resend, or any third-party service, it often hardcodes the key in the file where it is used rather than referencing an environment variable. If that file is client-side JavaScript, the key is visible to anyone who opens browser dev tools. The August 2026 scan of nearly 31,000 live AI-built apps found one in 23 shipping secrets in public bundles or config files. Escape's scan of 5,600 apps found more than 400.
Even when keys land in server-side code, they end up committed to git history where they persist after deletion. Without secret rotation and proper environment variable management, a single exposed key can grant attackers access to your payment processor, email service, or database. Put a secret scanner in CI so this class of mistake cannot reach main. The monitoring checklist covers how to detect and prevent secret exposure.
4. Misconfigured Databases and Missing Row-Level Security
Most vibe-coded apps use a hosted backend such as Supabase or Firebase, where the browser talks to the database directly using a public key and the database itself enforces who can read what. That model is secure only if row-level security policies are enabled and written correctly. AI tools routinely create tables without enabling RLS, or generate a policy of USING (true) to make the feature work, which grants every visitor access to every row.
This was the mechanism behind CVE-2025-48757, where 303 endpoints across 170 Lovable-built projects were readable or writable without logging in. Over a year later the problem has grown, not shrunk: the August 2026 scan found 57% of reachable Supabase-backed apps still permitted unauthenticated table reads, and 16% of all apps scanned allowed anonymous users to modify or delete data. If your app uses a hosted backend, verifying every table's policies is the highest-value hour you can spend.
5. Missing Input Validation: Injection and XSS
When AI generates forms, API endpoints, or database queries, it typically trusts user input implicitly. Form fields accept any value without length limits or format validation. API endpoints pass request bodies directly to database queries. User-submitted content renders in the browser without sanitization.
These patterns enable the most common web vulnerabilities: SQL injection (manipulating database queries through form fields), cross-site scripting or XSS (injecting JavaScript that runs in other users' browsers), and command injection (executing system commands through unsanitized input). Models have largely learned to avoid SQL injection, which Veracode now measures at an 82% to 86% pass rate. XSS is a different story: only 15% of generated code defended against it in the Spring 2026 tests, because doing so requires tracking data across the request handler, the template, and the client. A single unsanitized field can compromise every user who visits your site.
6. Insecure File Uploads
File upload is one of the most exploited attack vectors on the web, and AI-generated upload handlers are almost always missing critical safeguards. A typical implementation accepts any file, stores it in a publicly accessible directory, and uses the original filename, which opens the door to path traversal, executable uploads, and storage abuse.
Secure file upload requires validating both the MIME type and file extension, enforcing size limits, generating random filenames, storing files outside the web root, and scanning for malware. Most AI tools implement none of these by default. Review the file uploads checklist to see what your implementation may be missing.
7. Missing Security Headers and CSRF Protection
Security headers are the cheapest defence on the web. A content security policy blunts XSS. X-Frame-Options stops clickjacking. HSTS prevents protocol downgrade attacks. Every one of them is a few lines in your framework's config, and AI tools almost never add them because no tutorial does. In Tenzai's study, none of the 15 apps built by five different agents set a single security header, and none had CSRF protection.
Cross-site request forgery matters whenever your app uses cookie-based sessions: without a SameSite attribute or an anti-CSRF token, a malicious page can make your logged-in user's browser submit requests they never intended. If your app uses bearer tokens in an Authorization header you are largely covered. If it uses cookies, check.
8. Server-Side Request Forgery
Any feature that fetches a URL the user supplies is an SSRF risk: link previews, webhook registrations, “import from URL”, image proxies, PDF generators. AI tools implement these by passing the URL straight to a fetch call. An attacker supplies an internal address, such as a cloud metadata endpoint or an admin service on localhost, and your server dutifully retrieves it for them.
Tenzai found that every one of the five agents it tested introduced SSRF. It is one of the clearest examples of a context-dependent vulnerability: fetching a URL is fine, fetching an arbitrary user-controlled URL from a privileged server is not, and the model cannot tell the difference without being told. Resolve and validate the destination, block private and link-local ranges, and allowlist where you can.
9. Insecure Payment Handling
Payment integration is where security gaps become directly expensive. AI-generated payment code often processes sensitive operations client-side, where they can be manipulated. Price calculations happen in the browser. Subscription status is checked by reading local state rather than verifying with the payment provider. Webhook endpoints accept payloads without verifying signatures. Tenzai's e-commerce test apps accepted negative quantities and prices.
Without idempotency keys, network retries can charge customers multiple times. Without webhook verification, attackers can forge payment confirmations and access paid features for free. The payments checklist walks through every critical check for AI-generated payment code.
10. Hallucinated and Vulnerable Dependencies
AI tools add packages freely, and not all of them are real. The Cloud Security Alliance analysed 2.23 million AI-generated code samples from 16 models and found 19.7% referenced at least one package that does not exist. Attackers register those names on npm and PyPI and wait, a technique now called slopsquatting. When the next developer's AI suggests the same phantom package, it installs the attacker's code.
Even real packages carry risk. AI tools have no sense of whether a library is maintained, how many downloads it has, or whether it has open CVEs; they reach for whatever appeared most often in training data, which skews old. Audit every dependency the AI added: confirm it exists, check its maintenance status, and run a vulnerability scanner in CI.
How to Secure Vibe-Coded Apps
You do not need to stop using AI tools or start reviewing every line by hand. You need three layers: instructions the AI follows, guardrails the AI cannot bypass, and verification before you ship. Here is what each looks like in practice.
Tell the AI what secure looks like, once
Every major coding tool reads a rules file from your repository: CLAUDE.md for Claude Code, .cursor/rules for Cursor, AGENTS.md for Codex and others. Put your security requirements there so they apply to every session instead of every prompt. The requirements that pay off most: every data access must be scoped to the current user; secrets come from environment variables only; every API route validates its input with a schema; new tables get row-level security enabled before any code uses them; never disable a security feature to make a test pass. This directly addresses the memory and objective defects the research identifies, because the constraint is re-read on every turn.
Validate at the boundary
Define a schema for every request body, query string, and form submission using Zod or an equivalent, and reject anything that does not match before it reaches business logic. This one habit eliminates most injection, type-confusion, and mass-assignment bugs, and it gives the AI a concrete pattern to copy. Pair it with parameterized queries or an ORM for database access and an auto-escaping template layer for output.
Authorize every resource, not just every request
Middleware that confirms a user is logged in is necessary and not sufficient. Each handler must also confirm the user is allowed to touch the specific record they asked for. The cleanest implementation is a data-access layer where every query takes the current user and filters by ownership, so it is impossible to forget. If you use Supabase or Firebase, that layer is your row-level security or security rules, and every table needs a real policy.
Make the secure default the only default
Some protections should not depend on the AI remembering them. Set security headers in your framework config or hosting platform once. Turn on rate limiting at the edge or in middleware for auth routes. Add a secret scanner such as gitleaks to CI so a hardcoded key fails the build. Enable dependency auditing in CI. These guardrails are invisible during day-to-day vibe coding and catch the mistakes that matter most.
Verify before you ship, and again after every big change
Instructions and guardrails reduce the error rate. They do not take it to zero, and AI tools make different decisions in every session. A systematic scan of the whole codebase before launch, and after any feature that touches auth, payments, uploads, or user data, is the step that separates the teams that ship safely from the ones in the statistics. The next section shows how to do it in a few minutes.
How to Check Your Vibe-Coded App for Security Gaps
Spot-checking individual files is not enough. Security gaps in AI-generated code are distributed across the entire codebase: a missing rate limiter here, an unvalidated input there, a hardcoded secret somewhere else. An effective audit requires a systematic scan across every domain: authentication, file handling, payment processing, API security, data storage, and infrastructure configuration.
Vibe Check automates this. It is a free, open-source production readiness scanner that installs as a skill inside the AI coding tool you already use, reads your actual code, and reports specific gaps with plain-language fix instructions you can hand straight back to the AI. It works in nine harnesses: Claude Code, Cursor, Gemini CLI, Codex CLI, VS Code Copilot, Kiro, OpenCode, Antigravity, and Pi.
Step 1: Install
From the root of your project, run one command. It detects which coding tool you use and installs the right skill files.
npx skills add Hypership-Software/vibe-checkStep 2: Run the check
In Claude Code, run the check skill. In Cursor the same skill is invoked as @vibe-check check, and in VS Code Copilot as #vibe-check check. To scan only the security domain, pass it as the focus.
/check
/check securityThe check asks four short context questions (what you are building, who it is for, what data it handles, what is at stake), maps your codebase, then runs a specialised assessor for each production domain in parallel. Domains that do not apply to your project are skipped. The security assessor checks nine items against your real code:
- Secrets management — no hardcoded keys, tokens, or connection strings in code or git history
- Authentication — hashed passwords, expiring sessions, protected routes
- Input validation — schema validation at every API boundary, parameterized queries
- Dependency security — no known CVEs, no unmaintained or hallucinated packages
- HTTPS — enforced on every route with HSTS
- Security headers — CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy
- CORS configuration — explicit origin allowlist, never wildcard with credentials
- CSRF protection — SameSite cookies or anti-CSRF tokens on state-changing routes
- Rate limiting — on login, signup, password reset, and public API endpoints
Step 3: Read the score
You get a score out of 100 and a band: Production Ready (90+), Launch Ready (75 to 89), Needs Work (60 to 74), or Early Stage (below 60). Critical security failures gate the band: an app that scores 92 but has a hardcoded API key is capped at Needs Work until the key is removed, so a good overall score can never hide a dangerous finding. Every finding comes with a priority, an explanation calibrated to your context, and a fix instruction written for your AI tool.
Step 4: Fix and re-check
Run the fix skill to walk through findings one at a time. It proposes the change and applies it only after you approve. When you are done, or a week later after more vibe coding, re-run to see what improved and whether anything regressed.
/fix
/refreshEverything is written to a .vibe-check/ directory in your repo, so the report, the checklist, and the action plan travel with the code and give you a record of what was checked and when. If you would rather start without code access, the web app at vibe-check.cloud walks you through the same domains as guided questions and links to the detailed feature checklists.
Sometimes the question is bigger than a scan. If you handle regulated data, are heading into a funding round or a customer security review, or a partner has asked for validation from someone independent, Hypership, the team behind Vibe Check, runs an independent audit of AI-built software: security and data access, build quality, product experience, and commercial readiness, with findings ranked by business cost and a report in about a week. Run the free scanner first. Call them when the stakes justify it.
Vibe Coding Security Checklist
Print this, or paste it into your coding tool and ask it to audit the codebase against each line. Every item maps to one of the ten risks above.
Vibe Coding Security FAQ
Is vibe coding safe?
Vibe coding is safe only if you verify what the AI produced before real users touch it. In 2026 research, 91% of audited vibe-coded apps contained at least one vulnerability and the best coding agents produced secure code in under 12% of realistic tasks. The tools are not unsafe to use; shipping their output unreviewed is. A systematic security scan before launch closes most of the gap.
Can vibe-coded apps be hacked?
Yes, and they are. Passive scans of live AI-built apps in 2026 found that 57% of Supabase-backed apps allowed anyone to read database tables without logging in, 1 in 23 shipped hardcoded secrets in public bundles, and 16% allowed anonymous users to modify or delete data. None of these required sophisticated attackers, only someone who looked.
What are the biggest vibe coding security risks?
Broken access control (checking that a user is logged in but not that they own the resource), exposed API keys and secrets, misconfigured database access rules, missing input validation leading to injection and XSS, missing security headers and CSRF protection, server-side request forgery, insecure file uploads, and insecure payment handling. Hallucinated or vulnerable dependencies are a growing tenth category.
Which AI coding tool is the most secure?
No tool is meaningfully safer than the others on this dimension. Tenzai ran identical prompts through Claude Code, Cursor, Windsurf, Replit, and Devin and every one of them introduced server-side request forgery and none added CSRF protection or security headers. Veracode found security pass rates flat between 45% and 55% across more than 150 models regardless of release date. Pick the tool you are most productive in and add verification around it.
How do I make my vibe-coded app secure?
Three steps. First, tell the AI what secure looks like with a rules file in your repo that requires authorization checks, schema validation, and environment variables for secrets. Second, enforce guardrails your AI cannot skip: row-level security on the database, a secret scanner in CI, and security headers set in framework config. Third, scan the whole codebase before launch with a tool like Vibe Check, fix the critical findings, and re-scan after every major feature.
Do I need a security expert to ship a vibe-coded app?
Not for a typical SaaS, marketing site, or internal tool. The vulnerabilities AI introduces are overwhelmingly well-understood classes with known fixes, and the fix instructions can be handed straight back to your coding agent. You need an expert when you handle regulated data (health, financial, children), process card data yourself instead of through a provider, or face a customer security review.
How often should I scan a vibe-coded app for security issues?
Before the first real user, after every feature that touches auth, payments, file handling, or user data, and on a schedule of roughly once a month. AI coding tools make different decisions in every session, so a codebase that passed last month can regress after a week of prompting.
Scan Your App for Security Gaps
Find out what your AI coding tool missed before an attacker does. Free, open source, runs inside the tool you already use.
Sources
- Understanding the (In)Security of Vibe-Coded Applications. Deng, Fan, Meng. arXiv, June 2026 (revised September 2026). 9,041 open-source AI-built apps examined, 200 deployed apps audited.
- Is Vibe Coding Safe? Benchmarking Vulnerability of Agent-Generated Code in Real-World Tasks. Zhao et al., Carnegie Mellon University. ICML 2026. The SUSVIBES benchmark: 186 repository-level tasks across 79 CWE categories.
- Bad Vibes: Comparing the Secure Coding Capabilities of Popular Coding Agents. Tenzai Research. Identical prompts through Claude Code, Cursor, Windsurf, Replit, and Devin; 69 vulnerabilities across 15 apps.
- The State of Security of Vibe Coded Apps. Escape. Passive scan of 5,600+ production apps: 2,000+ vulnerabilities, 400+ exposed secrets, 175 PII leaks.
- Spring 2026 GenAI Code Security Update. Veracode, March 2026. 150+ models, 80 tasks, four languages. 45% of tasks produced insecure code; XSS pass rate 15%.
- Vibe Coding Security Report, August 2026. VibeEval. Passive scan of 30,998 live AI-generated web apps, August 12–14, 2026.
- Vibe Coding Security Debt: AI-Generated Vulnerabilities at Scale. Cloud Security Alliance research note, April 2026. 19.7% of 2.23 million AI-generated code samples referenced a package that does not exist.
- CVE-2025-48757: Lovable row-level security bypass. Matt Palmer, May 2025. 303 endpoints across 170 Lovable projects readable or writable without authentication.
Keep Reading
Related Guides
Vibe Coding Governance
Guardrails for startups and small teams — rules files, CI gates, review boundaries, and a launch gate.
Vibe Coding Risks
The complete risk landscape of AI-generated code — tech debt, reliability, scalability, and compliance.
Vibe Coding Failures of 2026
Real AI-generated code failures — what broke and what a production readiness review would have caught.
