ivinco
Vibe Coding Security: 8 Risks and How to Find Them

Vibe Coding Security: 8 Risks and How to Find Them

Ivinco Team··Updated

Vibe coding security is the gap between what AI coding tools build and what a production app needs to be safe. Apps built with Lovable, Bolt.new, Replit or Cursor work, but they are not secure by default. Escape found 2,038 highly critical vulnerabilities, more than 400 leaked secrets and 175 cases of exposed personal data across about 1,400 vibe-coded applications.

The broader research points the same way. A Cloud Security Alliance research note summarizes Veracode's tests of more than 100 large language models on 80 coding tasks: 45% of the AI-generated code samples introduced OWASP Top 10 vulnerabilities, 86% failed to defend against cross-site scripting, and 88% were vulnerable to log injection.

We call this the Demo-to-Disaster Gap: the distance between a working prototype and a system that survives real users. AI coding tools have collapsed the first half of that journey. The second half hasn't changed.

Andrej Karpathy coined the term "vibe coding" in February 2025: writing software by describing what you want and accepting the AI's output without deep review. Collins English Dictionary named it Word of the Year for 2025. Y Combinator reported that 25% of the startups in its Winter 2025 batch had codebases that were 95% AI-generated. The prototype works. The demo impresses. And then someone points real traffic at it.

The eight problems below are the Demo-to-Disaster Gap in practice. For each one: what it looks like, why it happens, and the commands to find it in your codebase.

Risk 1: Hardcoded Secrets in Your Frontend

The symptom is a Stripe secret key, a Supabase service role key or an OpenAI API token sitting in a JavaScript file that ships to the browser. Sometimes it's in a .env file committed to Git. Sometimes it's inline in the code.

Ask an AI tool to "add Stripe payments" or "connect to the database," and it may put the key wherever the code can reach it fastest, including files that ship to the browser. Escape's scan found more than 400 leaked secrets across the apps it checked.

How to find it:

# Scan for secrets in your codebase
npx @secretlint/quick-start "**/*"

# Check Git history for committed secrets
git log --all -p | grep -iE "(sk_live|sk_test|SUPABASE_SERVICE|OPENAI_API_KEY|password\s*=)"

# Check if .env is in your Git history
git log --all --full-history -- .env .env.local .env.production

If git log returns results for .env, those secrets are in your history permanently, even if the file is now in .gitignore. You need BFG Repo-Cleaner or git filter-repo to purge them, and you need to rotate every exposed credential immediately.

The fix: Move all secrets to environment variables loaded at runtime. Use a secrets manager: AWS Secrets Manager, Doppler or Infisical for startups. Add Secretlint or TruffleHog to your CI pipeline so secrets can't be committed again.

Risk 2: Missing or Broken Authentication

The app has a login page. It might even use Clerk or Supabase Auth. But the API routes behind it? Unprotected.

Vibe-coded apps routinely ship with frontend-only auth: the UI hides buttons from logged-out users, but the API endpoints accept requests from anyone. An HTTP GET to /api/admin/users returns the full user list. No token check. No middleware. The AI built the login screen and the admin dashboard as separate features without connecting the authorization layer between them.

How to find it:

# List all API route handlers, then check each one for a session check
grep -rn "export.*function\|export default" src/app/api/ --include="*.ts" --include="*.tsx"

# Check whether a proxy.ts (formerly middleware.ts) exists as a first gate
ls proxy.ts middleware.ts src/proxy.ts src/middleware.ts 2>/dev/null || echo "No proxy.ts or middleware.ts found"

# Test an authenticated endpoint without credentials
curl -s -o /dev/null -w "%{http_code}" https://your-app.com/api/admin/users
# If this returns 200, your auth is broken

Check every route handler in src/app/api/. If any handler processes the request without calling auth(), getServerSession() or checking a JWT, that endpoint is open to the internet.

The fix: Check the session inside every route handler. In Next.js 16, proxy.ts (formerly middleware.ts) is a first gate, not the only one: Vercel advises against relying on it alone. Use Clerk or Auth.js for the session itself. Don't hand-roll JWT verification unless you understand timing attacks, token rotation and session fixation.

Risk 3: Database Open to the Internet (Supabase RLS Off)

Apps built on Supabase often query the database straight from the browser with a public anon key. That is safe only when row-level security (RLS) policies limit what each user can read and write. Without them, anyone holding the key, which ships in the page, can read or change whole tables.

This has already happened at scale. CVE-2025-48757 describes insufficient RLS policies in apps built with Lovable through April 15, 2025, which let unauthenticated attackers read or write their tables. Matt Palmer, the researcher who reported it, found 303 endpoints across 170 projects without proper RLS. The record is marked disputed: Lovable's position is that each customer is responsible for protecting their own app's data.

How to find it:

-- In the Supabase SQL editor: tables with RLS turned off
select tablename from pg_tables
where schemaname = 'public' and rowsecurity = false;

-- Policies that let everyone through
select tablename, policyname, cmd from pg_policies
where schemaname = 'public' and (qual = 'true' or with_check = 'true');

The fix: Turn on RLS for every table the browser can reach, write policies that tie rows to auth.uid(), and never use the service role key in client code. Test each policy as an anonymous visitor and as a second user, not only as the owner.

Risk 4: No Input Validation

The contact form saves user input directly to the database. The search bar passes the query string into a SQL statement. The file upload endpoint accepts anything.

In Veracode's tests, 86% of AI-generated samples failed to defend against cross-site scripting. The reason: language models generate code that handles the happy path. Input validation is defensive code; it handles the paths the user didn't describe. The AI was never told "also protect against SQL injection," so it didn't.

How to find it:

# Static analysis for injection vulnerabilities (install with: pipx install semgrep)
semgrep scan --config auto src/

# Look for raw SQL queries (ORM bypass)
grep -rn "\.raw\|\.query\|\.exec\|sql\`" src/ --include="*.ts" --include="*.tsx"

# Check for unsanitized HTML rendering
grep -rn "dangerouslySetInnerHTML\|v-html\|innerHTML" src/ --include="*.ts" --include="*.tsx" --include="*.vue"

Semgrep catches the patterns static analysis can find. But some injection vectors depend on runtime behavior: parameterized queries bypassed by a helper function, or a Prisma $queryRawUnsafe call buried in a utility file. Manual review of every database call is the only way to catch everything.

The fix: Use an ORM (Drizzle or Prisma) for all database access, and never concatenate user input into SQL strings. Validate every input with Zod schemas at the API boundary. Set a strict Content Security Policy header to block inline scripts. Add Semgrep to CI so these patterns fail the build.

Risk 5: No Rate Limiting

The login endpoint accepts unlimited password attempts. The API route that calls OpenAI on every request has no throttle. At GPT-4o's list price of $2.50 per million input tokens, a bot sending 50,000 requests with 500-token prompts runs up $62.50 in one go, and that's one endpoint on one day.

The deeper risk is credential stuffing. The OWASP Credential Stuffing Prevention Cheat Sheet covers it as a common automated attack against web applications. It calls multi-factor authentication "by far the best defense"; add rate limits alongside it.

How to find it:

# Check for rate limiting libraries
grep -rn "ratelimit\|rate-limit\|throttle\|upstash.*ratelimit" src/ package.json

# Check for any request counting logic
grep -rn "rateLim\|requestCount\|tooMany\|429" src/ --include="*.ts"

If neither search returns results, you have no rate limiting.

The fix: Upstash Ratelimit works with Vercel Edge and Cloudflare Workers: serverless-compatible, no Redis server to manage. Add it to your authentication endpoints first, then to any endpoint that calls a paid external API. A sliding window is a good default; start strict on login (for example, 10 requests per minute) and looser on general API access, then adjust to your actual usage.

Risk 6: Hallucinated and Vulnerable Dependencies

AI coding tools add packages as freely as they write code, and some of those packages don't exist. A USENIX Security 2025 study of 16 code-generating models found that, on average, at least 5.2% of the packages commercial models suggested were hallucinated, and 21.7% for open-source models, with 205,474 distinct invented names. Attackers register those names and wait for someone to install them, a practice called slopsquatting. Real packages carry the usual risk too: an AI tool may pin an old version with known vulnerabilities.

How to find it:

# Known vulnerabilities in production dependencies
npm audit --omit=dev

# Every direct dependency, to check that each one is the package you meant
npm ls --depth=0

Look up any package you don't recognize on its registry page: owner, release history, downloads and source repository.

The fix: Review every new dependency in pull requests, commit the lockfile, and let Dependabot or Renovate keep versions current. Fail CI when a dependency with a known critical vulnerability appears.

Risk 7: No Security Logging

The app has no structured logging, no error tracking and no alerts. When someone tries a thousand passwords or reads another user's data, nothing records it, so nobody finds out until a customer does. OWASP lists this as A09:2025, Security Logging and Alerting Failures.

AI tools build what you describe. The defensive layer around it, the part that tells you when something goes wrong, doesn't get described, so it doesn't get built.

How to find it:

# Check for any logging library
grep -rn "winston\|pino\|bunyan\|morgan\|console\.log" src/ --include="*.ts" | head -20

# Check for error tracking SDK
grep -rn "Sentry\|BetterStack\|Highlight\|Axiom\|bugsnag\|rollbar" src/ --include="*.ts"

If the only logging is console.log scattered through the code, there is no record of an attack. Console logs don't persist, aren't structured, and can't be queried when something fails at 3 AM.

The fix: Log security events (sign-ins, failed sign-ins, permission errors and admin actions) with the user and request ID, and keep secrets and personal data out of the logs. Alert on spikes of failures. Add Sentry for errors; its free Developer plan includes 5,000 errors, enough for many MVPs. Send structured logs to Axiom or BetterStack, where they persist and can be queried.

Risk 8: No CI/CD Pipeline

Deployment is git push with no intermediate steps. No tests run. No security scan. No type check. No build verification. The code goes from editor to production in one step.

This is the Demo-to-Disaster Gap at its widest. Apiiro's research, summarized in the same CSA research note, found that monthly security findings at the Fortune 50 enterprises it studied rose from about 1,000 to more than 10,000 between December 2024 and June 2025, as AI coding assistants spread. AI-generated code without automated quality gates turns fast prototyping into fast vulnerability creation.

How to find it:

# Check for CI/CD configuration
ls -la .github/workflows/ 2>/dev/null || echo "No GitHub Actions found"
cat .gitlab-ci.yml 2>/dev/null || echo "No GitLab CI found"

# Check for test configuration
ls package.json | xargs grep -l "test\|vitest\|jest\|playwright" 2>/dev/null

# Check if any tests exist
find src/ -name "*.test.*" -o -name "*.spec.*" | head -5

If there are no workflow files and no test files, every commit goes to production unchecked.

The fix: A minimum viable CI pipeline in GitHub Actions is a short file:

# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm ci
      - run: npx tsc --noEmit          # Type check
      - run: npx vitest run             # Unit tests
      - run: pipx run semgrep scan --config auto --error  # Security scan

Add Dependabot for automated dependency updates. Add Semgrep for security pattern matching. These are free, they run on every push, and they catch the classes of bugs that vibe coding introduces most often.

Closing the Demo-to-Disaster Gap

Every one of these problems exists because AI coding tools optimize for the first half of the Demo-to-Disaster Gap (getting from idea to working prototype) and ignore the second half: getting from prototype to production system. The first half is creative. The second is defensive. Language models are trained on code that solves problems, not code that anticipates them.

The gap is structural enough that startups are being funded to close it. Modelence, a Y Combinator startup, raised a $3 million seed round in January 2026 for an all-in-one toolkit that handles authentication, databases and hosting for apps like these.

Running the Full Audit

Here's the condensed version. Run these five commands against any vibe-coded codebase:

# 1. Secrets scan
npx @secretlint/quick-start "**/*"

# 2. Security static analysis (install with: pipx install semgrep)
semgrep scan --config auto src/

# 3. Dependency vulnerabilities
npm audit --omit=dev

# 4. List API route files that never check a session
grep -rL --include="route.ts" -E "auth\(|getSession|getServerSession|currentUser" src/app/api/

# 5. Check for any test coverage
npx vitest run --reporter=verbose 2>&1 | tail -5

If any of these produces concerning output, the app needs hardening before it handles production traffic. Our vibe coding cleanup playbook covers the fixes in order.

These eight risks are the most common ones, but they're not exhaustive. Every vibe-coded app has its own failure profile based on the AI tool used, the prompts given and the complexity of the domain. A fintech MVP has different vulnerabilities than a social app. An app using Supabase Row Level Security has a different auth surface than one using Clerk middleware.

This audit catches the structural problems. Domain-specific security review (payment flow testing, multi-tenancy isolation, compliance requirements) needs a team that understands both the code and the business context.

Have a vibe-coded app? Send us the repository, and on a 30-minute call we will tell you whether it needs fixes or a rebuild. See our MVP development services.


The vulnerabilities are already in the code. The only cost is looking.

Frequently Asked Questions

How secure is vibe coding?

Not secure by default. In Veracode's tests of more than 100 language models, 45% of AI-generated code samples introduced OWASP Top 10 vulnerabilities, and Escape found 2,038 highly critical vulnerabilities across about 1,400 vibe-coded apps. The code works on the happy path, but AI tools routinely skip defenses such as input validation, auth checks, database access rules, rate limiting and secret handling.

Is vibe coding trustworthy?

For prototypes and validation, yes. For production with real users and real data, only after review and hardening: secrets moved out of the code, every API route behind authentication, inputs validated, rate limits on login and paid APIs, and a CI pipeline with security scans. Treat AI output as a draft from a fast junior developer, not as finished code.

How do I secure my vibe-coded app?

Start with secrets: scan the code and Git history, rotate anything exposed and move secrets to a secrets manager. Then check authentication in every API route handler, turn on row-level security if you use Supabase, validate inputs with schemas, add rate limiting, and set up CI with Semgrep and dependency scanning. The five commands in this post show where you stand.

Is vibe coding a trap?

Not if you treat the result as a prototype. It becomes a trap when a fast demo goes to production unreviewed, and security debt, a fragile data model and missing monitoring pile up under real users. Validate the product with vibe coding, then harden it, clean it up or rebuild it before you scale.

What are the most common security vulnerabilities in AI-generated code?

Cross-site scripting (86% of samples failed in Veracode's tests), log injection (88%), hardcoded secrets, missing authentication on API routes, SQL injection through raw queries, and insecure direct object references. These patterns appear because language models generate code for the happy path; validation, authorization and output encoding cover paths the prompt didn't describe.

Can I use Lovable or Bolt.new for a real product?

For validation and prototyping, yes. For production with real users and real data, not without significant engineering work. Escape found 2,038 highly critical vulnerabilities across about 1,400 apps built on vibe coding platforms. The tools are excellent for functional prototypes, but the output needs a production engineering layer (security hardening, observability, CI/CD, infrastructure) before it's ready for real traffic.