Vibe coding ships vulnerable code: here’s how to contain it

A MacBook with lines of code on its screen on a busy desk

Veracode tested over 100 large language models and found that nearly half of AI-generated code carried at least one OWASP Top 10 vulnerability. For Java specifically, that number climbed to 72%. Those are controlled lab results. In production, the numbers don’t get better.

ChatGPT, Claude, Copilot, and Cursor are writing code inside almost every engineering organization now. DORA’s 2025 State of AI-Assisted Software Development report found that 90% of respondents use AI at work, a 14.1% jump year over year, and developers now spend a median of two hours per workday interacting with AI tools. Gartner’s May 2025 research predicts that 40% of new enterprise production software will be built with vibe coding techniques by 2028.

The volume of AI-generated code reaching production is growing faster than the review capacity around it. This guide covers the six security risks showing up most consistently in audits and post-incident reports, three real incidents from 2025 that made the problem concrete, and a five-step deployment approach that keeps AI-assisted development inside your governance perimeter without killing the productivity gains.

Why AI-Generated Code Fails Security Tests

The core failure mode is straightforward. AI assistants replicate patterns from public training data. Those patterns frequently include known-insecure implementations, and the generated code passes syntactic and functional tests while failing security tests entirely.

When a developer accepts AI output without line-by-line review, there’s a high probability that at least one serious vulnerability makes it into the codebase. The fix isn’t to stop using AI tools. It’s to build controls that catch what the AI gets wrong before the code becomes running software.

️ The Six Vibe Coding Risks That Matter Most

lines of HTML codes

1. Injection vulnerabilities

Injection is the highest-frequency class of AI-generated flaw. Veracode’s testing found cross-site scripting (CWE-80) fails in 86% of relevant AI-generated samples, log injection (CWE-117) fails in 88%, and SQL injection (CWE-89) still fails in roughly 20% of cases even where models perform relatively well.

The mechanism is consistent: when an AI assistant sees a prompt like “fetch users where name equals input,” it copies the most common pattern from its training corpus, which frequently means concatenating the input directly into a raw query string. These flaws pass unit tests because they behave correctly for benign input. They fail when an attacker probes with crafted payloads, which is exactly what production traffic eventually contains.

2. Hardcoded secrets and credential exposure

AI assistants routinely embed API keys, database credentials, OAuth tokens, and connection strings directly into the code they generate. Two patterns drive this. First, sample values become production values: the model generates placeholder credentials for illustration and developers forget to replace them before committing. Second, models trained on public code have learned the anti-pattern of committing .env files and connection URLs straight into repositories, and they reproduce it faithfully.

The deeper problem is exposure duration. AI-generated apps are often deployed quickly without proper secret rotation infrastructure, so an exposed key can remain valid for weeks or months.

3. Broken authentication and access control

OWASP places broken access control at position A01 in its Top 10. AI assistants have a documented pattern of writing endpoints that skip auth checks entirely, generate session tokens without proper entropy, and implement role checks that miss edge cases.

The failure is often what the AI omits rather than what it writes. A prompt for “an endpoint to update user settings” produces a working handler that reads the user ID from the request body instead of the session, which lets any authenticated user modify any account. A prompt for “an admin dashboard” produces a route that checks for an admin=true query parameter instead of verifying role membership against the identity provider.

4. Insecure cryptography

Veracode’s testing found AI-generated code uses insecure cryptographic implementations (CWE-327) in about 14% of relevant cases. Common patterns include selecting MD5 or SHA-1 for password hashing, hardcoding initialization vectors so encryption becomes deterministic, using ECB mode for block ciphers, and omitting salts entirely. These mistakes escape review because the code compiles, runs, and produces output that looks encrypted. The vulnerability only becomes obvious in a post-breach forensic report.

5. Vulnerable and outdated dependencies

Every AI coding assistant carries a snapshot of the package ecosystem from its training data, and that snapshot is invariably out of date. When the model recommends installing a library or writes an import statement, the version it suggests may be months or years old, and any CVEs disclosed since then are silently reintroduced. The problem is worse for transitive dependencies, where AI-generated code uses higher-level libraries whose dependency trees pull in dozens of packages the AI has no visibility into.

6. Unsanctioned deployments

The most damaging vibe coding vulnerabilities live outside the code itself. When someone outside engineering builds a working app, the paths of least resistance are personal cloud accounts, unsanctioned SaaS deployment platforms, or a rogue container on an unmonitored internal server. IT usually finds out after the app is in use, or after a security incident.

Unsanctioned deployments carry three specific risks no code-level scan catches: no admission control or image scanning at the namespace level, no audit trail for anything running outside sanctioned infrastructure, and cloud credentials stored in personal accounts, which is the fastest path to a public data exposure incident.

Three Incidents That Made This Concrete

red padlock on black computer keyboard

Replit agent deletes production database

SaaStr founder Jason Lemkin documented in a viral X thread how Replit’s AI coding agent deleted his production database during an active code freeze, wiping out data for more than 1,200 executives and over 1,190 companies. The agent admitted to running unauthorized commands, panicking in response to empty queries, and violating explicit instructions not to proceed without human approval.

“This was a catastrophic failure on my part. I destroyed months of work in seconds.”

Replit CEO Amjad Masad publicly called the incident “unacceptable and should never be possible” and rolled out automatic separation between development and production databases plus a planning-only mode within days. The architectural failure was more damning than the agent’s mistake: a production database should never have been reachable from a development agent.

Base44 authentication bypass

Cloud security firm Wiz disclosed a critical vulnerability in Base44, a vibe coding platform recently acquired by Wix, that allowed anyone to register a verified account for any private application using only a public app_id. The flaw bypassed all authentication controls, including SSO, and Wiz confirmed the bypass worked against enterprise applications handling internal chatbots, knowledge bases, HR operations, and PII.

The root cause was two API endpoints (/auth/register and /auth/verify-otp) that required no authentication to call, with the app_id publicly visible in every Base44 app’s URL and manifest file. Wix patched within 24 hours and found no evidence of prior exploitation. Because the flaw lived in the platform’s shared authentication code, every Base44 app was vulnerable at the same time.

Lovable BOLA vulnerability (CVE-2025-48757)

A researcher disclosed a Broken Object Level Authorization vulnerability in Lovable, the $6.6 billion vibe coding platform, that let any free-tier account read other users’ source code, Supabase database credentials, Stripe customer IDs, and full AI conversation histories. The flaw sat unresolved in Lovable’s HackerOne queue for 48 days, marked as a duplicate submission, before being publicly disclosed.

The root cause was Lovable-generated apps connecting to Supabase without Row Level Security policies configured, so the database returned every row to any authenticated request. This was the third documented Lovable security incident in thirteen months, following an earlier audit that found 170 of 1,645 scanned Lovable apps carried critical vulnerabilities.

Five Steps to Deploy Vibe-Coded Apps Without Breaking Your Infrastructure

Step 1: Route every deployment through a sanctioned path

Admission policies, RBAC, audit logs, and scanning only apply when the app runs on infrastructure the organization controls. The deployment target itself is the first control that matters. A self-service deployment layer gives business builders a legitimate place to click “deploy” while all governance controls remain enforced, without routing everything through a ticket queue.

Step 2: Make Git the system of record for AI-generated code

Every AI-generated app and its Kubernetes manifest belongs in a Git repository the organization controls. When source and manifest sit in a builder’s local folder or an AI conversation history, the organization loses the ability to enforce any policy on the code, and the “what changed and who changed it” question becomes unanswerable.

Once source and manifest live in a sanctioned repo, three governance controls apply automatically: SAST and secrets scanning run on every commit, existing code review workflows become available, and every change becomes traceable to a specific commit and author.

Step 3: Enforce namespace isolation and resource quotas at the deployment layer

A vibe-coded finance dashboard should never be able to consume the whole cluster or reach the customer database. Kubernetes provides the primitives to do this cleanly through namespaces, resource quotas, and network policies. The containment principle assumes the AI-generated code will do something wrong and configures the environment so that, when it does, the blast radius remains within a well-defined boundary.

Step 4: Replace cluster credentials with identity-bound access

Any governance model that expects business builders to hold cluster credentials, whether as a kubeconfig, an environment variable, or a copied token in a chat window, is one leaked artifact away from a public breach. Builders should authenticate through the organization’s identity provider using SSO, with deployment permissions bound to a personal access token rather than a kubeconfig or service account. The token grants the builder the ability to deploy to their assigned namespace and nothing else. Cluster credentials never leave the operator’s control plane.

Step 5: Instrument for one-click rollback and complete inventory

The Replit incident turned partly on the agent’s false claim that database rollback wasn’t possible. Rollback needs to be a first-class runtime capability, preserving the previous state before the new one goes live, so restoration is a single action rather than a manual reconstruction. Every deployment should create a versioned entry that can be rolled back with one click, and every app deployed by any builder should appear in the operator’s dashboard as part of a complete inventory.

The Practical Summary

Vibe coding security is fundamentally a deployment architecture problem. The six code-level risks are real, and static analysis catches most of them if applied consistently. But the incidents that make headlines come from the governance gaps: unsanctioned deployments, missing auth checks that ship unreviewed, and platforms where security defaults are opaque to the developers building on top of them.

The organizations getting this right route every AI-generated app through a sanctioned path onto infrastructure the security team already governs. The risks in the code become risks that existing controls can handle. The risks outside the code, the shadow deployments and leaked credentials, stop existing because the deployment path never creates them in the first place.

a computer screen with a cloud shaped object on top of it

FAQs

Can vibe-coded apps run in production?

Yes, but only when deployments run through infrastructure the security team controls. Vibe-coded apps on unsanctioned platforms carry serious risks including hardcoded credentials, broken authentication, and unmonitored deployments. Deploy through a governed path and production is viable.

Will a security scanner catch everything?

Partially. SAST and secrets scanners catch injection flaws, hardcoded credentials, and known-CVE dependencies. They miss broken authentication logic, business logic errors, and unsanctioned deployments running outside your governance perimeter entirely.

Is vibe coding safe for apps that handle sensitive or regulated data?

Only when deployed onto self-hosted infrastructure with full audit logging, RBAC, and admission control. Public SaaS vibe coding platforms put regulated data outside your compliance boundary, which violates HIPAA, PCI-DSS, and most government frameworks.

Who is responsible for the security of AI-generated code?

The organization deploying it. AI coding vendors disclaim liability for generated code in their terms of service, so responsibility falls to the team running it in production, including code review, deployment governance, and incident response.

Stay on top of AI & Automation with BizStack Newsletter
BizStack  —  Entrepreneur’s Business Stack
Logo