Skip to content
RM
Article

9 security mistakes vibe coders make (and how to fix each one)

AI-written apps often ship with exposed keys, open databases and missing checks. Nine common vibe coding security mistakes and the fix for each.

By 3 min read

AI coding tools make it easy to ship an app in a weekend. They also make it easy to ship that app with its database open to the internet. The AI writes what you ask for. If you never ask about security, you usually don't get it.

These are the nine mistakes I see most often in vibe-coded projects, with a fix for each.

1. API keys in the frontend

The AI puts your OpenAI, Stripe or database key straight into a React component so the feature "just works". Anything in frontend code is public: anyone can open the browser's developer tools and copy it.

Fix: keep secret keys on the server only, in environment variables. The frontend calls your own API route, and that route calls the paid service.

2. Secrets committed to Git

Even if the key is on the server, it may be sitting in a .env file that got committed. Once it is in Git history, deleting the file doesn't remove it.

Fix: add .env* to .gitignore before the first commit. If a key was ever pushed, rotate it (create a new one and revoke the old one). Don't just delete it.

3. Database rules left open

Hosted databases often start in a "test mode" where anyone can read and write. AI-generated setup guides rarely mention switching it off.

Fix: turn on row-level security or access rules, and test them: try to read another user's data while logged in as someone else.

4. Trusting the user ID from the browser

A common AI pattern: the frontend sends userId with each request and the server believes it. Anyone can change that number and act as another user.

Fix: the server works out who the user is from the session or token, never from a value the browser sends.

5. No input validation

AI code often passes form input straight into a database query, an email or a file path.

Fix: validate every input on the server (type, length, allowed values) with a schema library, and use parameterised queries, never string-built SQL.

6. Admin routes with no check

The AI builds a /admin page and hides the link. Hiding a link is not security.

Fix: every admin route and API checks the user's role on the server, on every request.

7. No rate limits on paid APIs

If your AI feature calls a paid model with no limit, one script can run up a bill overnight.

Fix: rate-limit by user and by IP, set spending caps with your AI provider, and alert yourself on unusual usage.

8. Installing whatever the AI suggests

AI tools sometimes suggest packages that are outdated, abandoned or don't exist at all, and attackers publish fake packages under names AI models tend to invent.

Fix: check a package's real page, downloads and last update before installing. Keep dependencies few, and run your package manager's audit command regularly.

9. Error messages that leak details

Default error pages and console.log calls can expose stack traces, file paths and database errors to users.

Fix: show users a plain message, log details on the server only, and remove debug logs before you ship.

A 2-minute prompt that catches most of this

Before every release, paste this into your AI coding tool:

Review this project for security problems. Check for: secret keys in frontend code
or in Git, open database rules, trusting user IDs sent from the browser, missing
input validation, admin routes without server-side role checks, paid API calls
without rate limits, unused or suspicious dependencies, and error messages that
leak internal details. List each problem with the file and line, and the fix.

Then read the answers yourself. The AI can find problems. You decide what ships.

TODO: add one real example (without private details) of a security issue you found in a vibe-coded app, yours or a student's.

Rahul Mirji teaches vibe coding like an engineer on Instagram and YouTube. More about Rahul.

Rahul Mirji, Tech and AI Creator based in Bengaluru, India (square portrait)

About the author

Rahul Mirji is a Tech and AI Creator based in Bengaluru, India. He builds AI products and creates practical content on artificial intelligence, vibe coding, developer tools and software development.

All articles