Vibe coding security is the problem of shipping software that an AI wrote and no human read. The common failures are predictable: API keys in frontend code, endpoints without authorization, databases open to the public, and unvetted packages. Vibe-coded apps can be made safe, but only by adding automated checks and a human review before real users arrive.
What vibe coding is and why it changes the security picture
Vibe coding means building software by describing what you want to an AI and accepting what it produces without reading the code closely. Andrej Karpathy popularized the term in early 2025 to describe giving in to the model's output and judging the result only by whether it runs.
That works for a weekend prototype. It breaks when the prototype gets users, payments or customer data, because security flaws do not show up when you click through the app. A login page that works says nothing about whether the API behind it checks who is calling.
Vibe coding shows up in two places at startups:
- Founders and non-engineers building internal tools or MVPs with app builders and agents.
- Engineers moving fast with Claude Code or Cursor and approving large diffs on a skim.
The second case is less obvious and more common. Both produce code nobody read.
The most common vibe coding security risks
The same five flaws appear again and again in vibe-coded apps, because models optimize for "it works" and the person prompting never asked for "it is safe".
1. Secrets in the wrong place
Models put API keys where the code needs them, which is often the frontend. A Stripe secret key or an OpenAI key in client-side JavaScript is visible to anyone who opens the browser's developer tools. Keys also end up committed in .env files that were never added to .gitignore.
2. Missing authorization
AI builds the feature you described. If you described "a page that shows the user's invoices", you get a page that shows invoices, often fetched by an ID in the URL that anyone can change. Broken access control sits at the top of the OWASP Top 10 for web applications, and vibe-coded apps are prone to it because the prompt rarely mentions permissions.
3. Databases open to the internet
Backend-as-a-service platforms let the frontend talk to the database directly, which is safe only when access rules are on. Supabase, for example, relies on row level security policies to stop one user reading another user's rows. Generated code often creates tables without those policies, and the app still works, so nobody notices.
4. Risky or invented dependencies
Models add packages to solve errors. Some are abandoned, some carry known CVEs, and some do not exist at all. Research on package hallucinations found that invented package names recur across prompts, which lets attackers register them and wait.
5. Unsafe handling of input and AI output
Vibe-coded apps that call an LLM often pass user input straight into prompts and model output straight into HTML, SQL or shell commands. That opens the app to prompt injection and classic injection at the same time.
Why "it works" is the wrong test
Functional testing does not catch security flaws, and functional testing is all vibe coding does. You click the button, the invoice appears, you move on. The attacker does something different: changes the invoice ID, calls the API without a token, or reads the database with the public key from your frontend.
The Stanford study Do Users Write More Insecure Code with AI Assistants? found that people using an AI assistant wrote less secure code and felt more confident in it. Vibe coding removes the remaining check, the person reading the code, so that confidence goes unchallenged.
A vibe coding security checklist before you ship
Run this checklist before a vibe-coded app touches real users or real data. Most items take minutes.
- Search the frontend bundle for secret keys. Anything starting with
sk_or labelled secret belongs on the server only. - Confirm
.envis in.gitignore, and turn on secret scanning with push protection in your repo. - Rotate any key that was ever committed, even if you deleted the file afterwards. Git history keeps it.
- Turn on row level security, or the equivalent access rules, for every table, and test that one user cannot read another's data.
- For every API route, check that it verifies who the caller is and that they own the resource.
- Try the app logged out. Call the API directly with no token and see what comes back.
- List every dependency the AI added and remove anything you do not recognize or cannot find a maintainer for.
- Escape model output before it reaches HTML, SQL or a shell.
- Add rate limits to login, signup and any endpoint that calls a paid API.
- Get one experienced engineer to review authentication, payments and data access before launch.
Moving from vibe coding to reviewed code
The fix for vibe coding security is not to stop using AI. It is to add the review step back, mostly through automation, so speed and safety stop trading off.
Three changes make the move:
- Put the code in a repo with branch protection, so every change arrives as a pull request.
- Give your coding agent written security rules in a project file such as AGENTS.md: server-side secrets only, authorization on every route, access rules on every table.
- Run automated security checks on every pull request and block the merge when they fail.
The third step is where most small teams stop, because they have no security engineer to set it up. The Motiontic Security Layer (MSL) is built for startups at this stage, with affordable pricing. It runs on every pull request in the team's own CI, scores risk against the ARI-42 risk index, and leaves a PR comment naming each risk and its fix, so the person who prompted the code can fix it without reading a security textbook. Setup takes a 15-minute call, and the first report arrives within 48 hours.
When vibe-coded apps meet enterprise buyers
Vibe-coded apps hit a wall at the first enterprise security review. Buyers send questionnaires asking how code is reviewed, how secrets are managed and how access is controlled, and "the AI wrote it" does not answer any of them.
If an MVP is turning into a product, plan the move to reviewed code before the first big deal, not during it. Motiontic's compliance work covers the evidence buyers ask for, and its AI product services cover rebuilding prototypes for production.
FAQ
Is vibe coding safe for production apps?
Not on its own. Vibe-coded apps commonly ship with exposed keys, missing authorization and open databases. With a pre-launch checklist, automated checks on every pull request and a human review of auth and payments, a vibe-coded app can reach production safely.
What is the most common security flaw in vibe-coded apps?
Missing access control is the most frequent serious flaw: API routes and database tables that do not check who is asking. Exposed secret keys in frontend code come a close second because they are easy to find.
Can AI fix the security issues it created?
Partly. A coding agent can fix a specific issue once you point at it, such as adding row level security or moving a key server-side. It rarely finds those issues unprompted, which is why automated checks that name each risk matter.
Do I need a security engineer for a vibe-coded MVP?
Not full-time. A checklist, CI security checks and a one-off review of auth and payments by an experienced engineer cover most of the risk at MVP stage. Add dedicated security help once you handle sensitive data or sell to enterprises.
Check your vibe-coded app
Motiontic helps startups turn AI-built prototypes into code that passes security review. Book a 20-minute call to get an ARI-42 report on your repo.



