Vibe coding cleanup

Guide

Security issues in AI-generated code, and how to fix them

Updated November 27, 20262 min read

AI coding tools write code that works on the happy path. Security is about the other paths: the user who is not logged in, the request that was not meant to be made, the key that should never have reached the browser. Those paths are exactly what a prompt rarely mentions, so they are where AI-built apps most often have holes.

This guide lists the issues that show up most in apps built with Lovable, Bolt, Cursor or v0, how to check for each, and what fixing them involves. It is written by THWorks, which does vibe coding cleanup on these apps.

The issues that show up most

Database rules that let anyone read everything

Apps on Supabase or Firebase rely on row-level security or security rules to decide who can read and write each row. If those rules are missing or too broad, any visitor with the public key can read other users’ data. Check: sign in as one test user and try to fetch another user’s records directly.

Secret keys in the front end

Payment, email or AI provider keys pasted into client code ship to every visitor’s browser. Check: search the built JavaScript for key prefixes. Fix: move the call behind a server function and rotate the exposed key.

Checks that only happen in the browser

Hiding an admin button is not the same as protecting the admin action. If the server endpoint does not check who is calling, anyone can call it. Check every endpoint that changes data for a server-side permission check.

No limits on inputs, uploads or AI calls

Unvalidated input opens the door to injection, unlimited uploads to storage bills, and unlimited AI calls to a provider bill someone else can run up. Add validation, size limits and rate limits on the server.

Dependencies nobody chose

Generated code pulls in packages, sometimes outdated ones. Run your package manager’s audit and update what it flags.

Why prompting rarely fixes it

Asking the tool to "make it secure" tends to patch the file you point at and miss the rule, endpoint or key elsewhere. Security problems sit between files: in how the database, the server and the browser trust each other. That is also why fixing one bug often breaks another in these apps.

Do it yourself or get help

If you are comfortable reading your database rules and server code, the checks above will find most problems. If you are not, or the app already holds real users’ data, have someone review it before more users arrive. THWorks prices the job rather than the hours. After a scoping call you get a fixed price for the agreed scope, settled before the work starts. If a new feature or integration comes up midway, it is priced and agreed with you before it is built, so the total never moves without your say.

Questions

What people ask next.

  • The platform can be secure; the app built on it is only as secure as its database rules, keys and server checks. Review those before real users and real data arrive.

  • Often, yes, if you can read your database rules and server code. The common issues are well known and the checks in this guide find most of them. Get help when the app already holds user data or payments.

Next step

Tell us what is breaking, and what it costs you.

A scoping call is 30 minutes and gets you a fixed estimate. If we are the wrong people for it, we will say so.

See the work
  • Reply within one business day
  • Fixed price, fixed scope
  • You own the code