You described the app in a few prompts, the agent built it, and it works. Sign-up works, payments go through, and the dashboard loads. What you probably haven't checked is whether a logged-in user can change one number in a URL and read somebody else's data, or whether your API key is sitting in the JavaScript bundle for anyone to copy.
That's the gap vibe coding security covers. This guide is for people shipping with Cursor, Claude Code, Lovable, Replit, or Copilot. It covers the risks that keep showing up in AI-built apps, a pre-launch checklist, and how to test the running app with the same agent that wrote it.
What Is Vibe Coding Security?
Vibe coding security is the practice of finding and fixing the vulnerabilities AI coding tools introduce when you build software from natural language prompts. It covers the code the model writes, the dependencies it pulls in, the config it sets up, and how the finished app behaves once it's running.
Vibe coding itself is the workflow where you describe what you want in plain language and a large language model generates the code. Secure vibe coding adds checks for what the model misses. It matters now because the people shipping vibe-coded apps often aren't security engineers, and the AI is optimizing for "it works," not "it's safe."
Why Vibe-Coded Apps Ship Vulnerabilities
The Vibe Security Radar project traces published vulnerabilities back through code history to identify who introduced them. In its April 2026 findings, the Georgia Tech team confirmed 74 vulnerabilities written by AI coding tools after scanning more than 43,000 security advisories. Fourteen were critical, and 25 were high severity, including cases of command injection, authentication bypass, and server-side request forgery.
The count only includes cases with an identifiable AI signature, such as a co-author tag. It therefore shows confirmed examples, rather than the full scale of vulnerable AI-generated code.
The pattern holds up when AI-generated code is tested under controlled conditions too. The BaxBench benchmark asked models to generate backend applications, then attacked the ones that worked. On average, the researchers could execute security exploits against around half of the functionally correct programs each model produced.
Several development habits contribute:
- The model optimizes for working code. Your prompt says "add a page that shows invoices." It doesn't say "only show invoices that belong to the logged-in user," so the model may not add the check.
- If a validation rule or permission check only exists in the frontend, an attacker skips it with a single
curlrequest. - Skipping line-by-line review is the point of vibe coding, which is fine for a prototype and risky for anything holding real user data.
None of this means AI-generated code is uniquely bad. The risks AI coding assistants introduce center on volume and understanding: more code ships, and fewer people know exactly what it does.
The Most Common Vibe Coding Security Risks
Check for these vulnerability types before releasing a vibe-coded app.
Exposed Secrets and API Keys in the Client Bundle
You ask the agent to call a paid API; it needs a key, and the quickest way to make the error go away is to read the key from a public environment variable. In Next.js, any variable prefixed with NEXT_PUBLIC_ gets inlined into the JavaScript sent to the browser, while unprefixed variables stay on the server. Vite does the same with VITE_, so keep API keys out of those client-exposed variables.
// Illustrative client excerpt: this value ships to visitors
const key = process.env.NEXT_PUBLIC_PAYMENTS_SECRET_KEY
// app/api/charge/route.js: runs only on the server
export async function POST(request) {
const key = process.env.PAYMENTS_SECRET_KEY
// call the payments API here and return only what the browser needs
}
If a secret ever lived in client code or a public repo, moving it isn't enough. Rotate it.
Broken Access Control and IDOR
Broken access control holds the #1 spot in the OWASP Top 10 2025, and it's easy for an AI tool to get wrong because the bug never shows up in a demo. The classic version is an insecure direct object reference (IDOR): your route loads /api/invoices/1024 for the logged-in user, and nothing stops them from requesting /api/invoices/1025.
// Deliberately vulnerable example; assumes an existing db client.
// app/api/invoices/[id]/route.js
export async function GET(request, { params }) {
const { id } = await params
const invoice = await db.invoices.findById(id)
return Response.json(invoice) // never checks invoice.userId against the session
}
It returns the right data every time you test it, because you only ever test with your own account. We go deeper on detection and fixes in our guide to broken access control.
Missing or Weak Authentication on API Routes
Agents build the login page and forget that the API behind it is a separate door, so a route the UI only calls after login is still open to anyone who finds it in the network tab. Every route that reads user data or acts on a user's behalf needs its own auth check on the server, not just a redirect in the frontend. Routes like login and signup are public on purpose, so give them input validation and rate limits instead.
Injection (SQL Injection and XSS)
When generated code builds SQL by concatenating strings, user input becomes part of the query, and the fix is prepared statements with bound parameters to keep user-supplied values separate from SQL instructions. Watch the edge case models miss: table and column names can't be bound as parameters, so a dynamic ORDER BY built from a query string still needs an allowlist.
Cross-site scripting follows the same logic on the output side: user input rendered into HTML without encoding.
Insecure, Outdated, or Hallucinated Dependencies
Models suggest packages that don't exist. A USENIX Security 2025 study found hallucinated package rates of at least 5.2% for commercial models and 21.7% for open-source models, with 205,474 unique made-up package names across its tests. Attackers exploit this with slopsquatting: they pre-register a name the model tends to invent on npm or PyPI, then wait for someone's agent to install it. Real packages bring the usual software supply chain problem too: a version the model suggests from memory may have picked up known vulnerabilities since.
Misconfigured Database Rules
Backend-as-a-service platforms like Supabase let the browser talk to the database directly, which is only safe if the database enforces who can see what. Enable row-level security on every table in an exposed schema so access policies apply at the database. Its publishable key is designed to be public, but its secret key bypasses row-level security and should never be in a browser or a shipped app. A leaked secret key gives an attacker privileged access to all your project's data. An agent that "fixes" a permissions error by swapping in the secret key has just put every row of sensitive data you store within reach.
Prompt Injection in Apps That Call an LLM
If your app sends user content to a model, that content can rewrite the model's instructions. OWASP ranks prompt injection as LLM01:2025, and an indirect injection arrives through a web page or file your app processes, rather than the chat box. Treat the model like any other untrusted user and validate what it returns before it reaches your backend, and keep its privileges to the minimum the feature needs.
No Rate Limiting on Login, Signup, or Paid APIs
An API without limits on requests or resource use can turn abuse into service disruption or a bill. Endpoints that send emails or SMS are a particular concern because each request can incur a cost. For a vibe-coded app, that means unlimited login attempts, signup spam, and an LLM endpoint someone can loop until your bill arrives.
Vibe Coding Security Checklist Before You Launch
Run through this before real users and real data touch the app.
- Move every secret server-side and rotate any that touched client code or git. Search the built bundle for key prefixes, not just the source.
- Check ownership on every route that takes an ID. Log in as user A, copy a resource URL, and request it as user B.
- Require auth on the server for every route that isn't meant to be public. Call each protected route with no session and confirm you get a 401 or 403, and keep a short list of the routes that are public on purpose.
- Turn on row-level security (or your platform's equivalent) for every table, and confirm the secret key isn't used anywhere in the frontend.
- Use parameterized queries everywhere, and allowlist any dynamic table, column, or sort value.
- Validate input on the server. Client-side checks help the UX, but an attacker can skip them entirely.
- Lock down CORS. Credentialed requests can't use a * wildcard origin anyway, so name the origins you actually serve.
- Set session cookies
HttpOnlyandSecure, so scripts can't read them, and they only travel over HTTPS. - Scan your dependencies with
npm auditor your ecosystem's equivalent, and confirm every package the agent added actually exists and is the one you meant. - Add security headers such as
Content-Security-PolicyandStrict-Transport-Security; the OWASP Secure Headers Project lists what each one does. - Rate limit login, signup, password reset, and any endpoint that costs money, and set spending caps on paid APIs.
- Run a runtime security test against the app itself before launch, not just a review of the code.
Items 2, 3, and 12 require tests against the running app.
How to Test a Vibe-Coded App Before It Ships
Why "Ask the AI If It's Secure" Isn't a Test
It's tempting to finish a session with "now review this for security issues." You'll get a confident list, but the model is reviewing its own assumptions: if it didn't know invoices should be scoped to a user when it wrote the route, it may miss the same check on a re-read. Review AI-generated changes for input-handling and authentication flaws. A self-review is a nudge, not evidence.
Static Checks vs. Runtime Testing (What Each Catches)
Static analysis reads AI-generated code before it runs. Dynamic application security testing (DAST) tests the running app from the outside, by sending real requests and checking what comes back. You want both, because they catch different things:
| Check | What it's good at | What it misses |
|---|---|---|
| SAST / code scanning | Injection patterns, hardcoded secrets, unsafe functions, before the app runs | Behavior that depends on config, auth, and data at runtime; custom authorization logic |
| Dependency scanning (SCA) | Known vulnerabilities in third-party and open-source packages | Bugs and logic flaws in your own code |
| Runtime testing (DAST) | Broken auth, access control failures, injection that actually executes, and leaky responses and headers | Code paths the scanner can't reach; needs a running app and auth configured |
| Platform scanners | Varies by platform and scan level: database rules and dependencies, and on some platforms a review of your app code or a test of the live preview | Rules it can't infer from your code, and anything outside that platform |
Access control is where the difference shows. Static tools struggle with custom authorization schemes. A scan that runs as one user has no second identity to try, so it can't tell whether user B can read user A's data. A runtime test set up with two test accounts, each owning its own data, can try user A's IDs as user B and check that directly.
Put Runtime Testing Inside the Coding Agent (Find, Fix, Verify)
The old problem with DAST was timing: it needs a running app, so it usually ran late in the process, long after the developer had moved on. Vibe coding changes that, because the agent that wrote the feature can also boot the app, test it, and fix what it finds while it still has all the context.
That's how we approach security testing inside the agent loop. With our agent skills installed, your coding agent runs the loop itself:
- Configure: generate a
stackhawk.ymlfor your app type, host, and auth pattern. - Scan: run HawkScan against the app running locally.
- Parse: read structured findings with the vulnerability type, severity, path, and method.
- Fix: change the code at the source, with the context the agent already has.
- Verify: rescan to confirm the fix held.

It works in Claude Code, Cursor, Codex, Antigravity, and GitHub Copilot, and the agent runs the loop on its own when you finish a feature. In Claude Code, setup is two commands: /plugin marketplace add stackhawk/agent-skills-marketplace and /plugin install wingman@stackhawk, plus installing and authenticating the hawk CLI.
For routes behind a login, tell the agent your auth pattern (for example, JWT bearer tokens) so it can configure an authenticated scan.
Cross-user checks like the invoice example take more setup: an OpenAPI spec, at least two test accounts with seeded data, and a local or staging environment, never production. Configure those profiles and test data for multi-profile business logic testing. You can see the whole flow in our Claude Code security best practices walkthrough, or the equivalent guide to securing code written in Cursor.
Runtime testing only covers what it can reach, so a route behind an unconfigured login won't get tested, and it doesn't replace a dependency scan. What it does give you is evidence about how the running app behaves on the paths and scenarios the scan exercises. Here's the product view of runtime testing for vibe-coded apps.
Vibe Coding Security Tools: What to Look For
Evaluate tools against your workflow:
- It works inside the agent you already use. Check whether scanning requires switching to a separate dashboard.
- It tests the running app. Access control and auth flaws show up in behavior, and reading the source alone can miss them.
- Findings are specific enough to act on, with a path and method the agent can reproduce and few false positives.
- Your coding agent fixes and re-verifies, instead of opening a ticket.
- A non-security builder can run it without tuning policies.
- It leaves a record. If security teams ever ask what was tested, you can show them.
Static scanners, dependency checkers, and platform-built-in checks each cover part of this list, and they're worth running as security controls in their own right. We built StackHawk for the runtime piece; if you're comparing options, here's how we work as a vibe coding security vendor.
Conclusion
Code that works isn't the same as code that's safe. Run the checklist, fix the obvious issues, and then test the running app before your users test it for you.
If you want that test to run inside the agent you're already building with, our Wingman plan is $10 per user per month and covers unlimited apps with 50 scans per user each month. Start the 14-day free trial, no credit card required, install the skills, and let your agent find, fix, and verify before the next deploy.
Vibe Coding Security FAQ
Not by default. BaxBench found exploitable bugs in some functionally correct generated programs. Reduce the risk with checks for what the model misses: secrets on the server, ownership checks, server-side auth, and a runtime test before launch.
Work through the checklist above, starting with secrets, ownership checks, and server-side auth. Then run a runtime security test from your coding agent so it can fix what it finds and rescan.
You can, and it'll catch some things, but it can share the blind spots that caused the bug. Treat it as a first pass and back it with a runtime test.
Yes. Built-in scanning varies a lot by platform and scan level. Some only check database rules and dependencies, others review your app code or test the live preview, and Lovable explicitly treats its scans as a complement to a thorough security review. Use it, then test the running app with test accounts that own different data, like the customer who owns invoice 1025.


