A vibe coded app rarely leaks because the model wrote bad code. It leaks because the model wrote the plumbing, and plumbing is the part nobody reads. The feature you asked for lives in a file you kept opening. The rule that decides who may read that file lives in a dashboard you never opened.
I shipped a small AI product this way and logged every detour at $50 an hour. Nineteen rows. Two of them were security-shaped, and both stayed invisible for weeks, because neither one breaks the demo.
The gap between a working page and a safe one
A demo exercises the happy path. You log in as yourself, click the button, see the right number. Every one of the four failures below leaves that sequence intact.
That is the trap. Nothing errors. Nothing slows down. The app behaves exactly as designed for the person who built it, and differently for everyone else.
Secrets that end up in the browser
Language models pick the shortest route to a working preview. The shortest route to a working preview runs from the client, which means the key ships to the client.
Two variants produce the same outcome. A private server key gets pasted into frontend code after a request failed on the server side. A public key gets used against a table with no policy, which is a different mistake with an identical effect.
The bundle is a public document. Anyone can open devtools, search for a prefix, and read what you shipped at three in the morning.
Check: Build the site, then grep the output directory for the prefixes your providers use. Rotate anything that appears before touching the code.
Rotation order matters more than people expect. A key that sat in a public bundle for a week was compromised at the deploy. Fix the file afterwards.
Storage that answers strangers
Supabase, Firebase and S3 all ship defaults that feel safe and are not, in precisely the configuration a model generates. Row level security in Supabase stays off until somebody writes a policy. The table exists, the API answers, the rows come back, and the rule about who may see them was never written.
Check: Take the public anon key with no session attached and request another user's row. Real data in the response means the policy is missing, whatever the dashboard implies.
The same test works for files. Open the URL of an uploaded document in a private window. If it renders without a token, the bucket is open, and the filenames are easier to guess than the random suffixes suggest.
This failure is quiet in the logs too. A request with an anon key looks like a request from your own app, because it is one.
Routes that never ask who is calling
Every project has routes that look important enough to protect and routes that look harmless because they return very little. Generated code protects the first group and forgets the second.
The tell is a handler that reads the user id from the request body. A server that trusts what the client says about identity will trust anything the client says.
Check: Call each route with no cookie and a body naming somebody else's user id. Any answer containing real rows is an open route.
Export endpoints and admin variants fail this test, because they get added last, after the main route's pattern has already been copied once without its checks.
Webhooks that believe every POST
Payment providers sign their payloads for a reason. A generated handler frequently skips the signature check, because the sample payload used during development had no signature and the handler worked anyway.
For a seller the outcome is worse than a data breach. Anyone who discovers the URL can mark an unpaid order as paid.
Check: Post an unsigned body to the webhook with an order id you own. If the order flips to paid, the endpoint is trusting strangers.
Signature verification needs the raw request body. Most frameworks parse JSON before your handler runs, and a re-serialised body no longer matches the signature. That single detail breaks a surprising number of implementations that look correct in review.
Why all four show up in the same week
They share a location. Each one lives in the glue around the feature, the first and last ten percent of a project, where the model writes confidently because the pattern appears a thousand times in its training data.
The middle, where your actual logic sits, gets more attention because you keep opening it to change things. The glue gets written once and never revisited.
The published numbers agree with this shape. Veracode's 2025 review of generated code found a large share of samples failing security tests, with failures clustering on input handling and trust boundaries rather than syntax errors. Stack Overflow's 2025 survey describes the same thing from the developer side: the most common complaint about AI output is that it is almost right.
Almost right describes a missing policy perfectly. The page loads. The data returns. Only the rule about who may see it was never part of the request.
The glue is also the part that gets generated in a single sitting and never opened again, because it works. Nothing in the file looks provisional. There is no TODO, no placeholder, no comment asking for a second pass. That is what makes it easy to ship and hard to notice.
What to grep for, and what a hit looks like
A key is rarely labelled as a key. It is a string in a config file, interpolated into a fetch call, then minified into a variable called t. The reliable method is to search for the prefixes that providers reserve for secrets.
- sk_live_ and sk_test_ for Stripe, plus whsec_ for signing secrets.
- sk- for OpenAI and most compatible providers.
- service_role in anything Supabase ships to a browser.
- AKIA followed by sixteen characters for long-lived AWS access keys.
A hit inside the built output directory is a leak, even when the variable looks unused. Minifiers keep string literals, and a dead code path still ships.
The reverse test helps too. Search the source for the string the frontend is allowed to use, and confirm that the frontend imports nothing else from the same module. A single barrel export is how service keys travel into pages that never needed them.
What the demo never shows
Walk the sequence a stranger would use, from a browser you have never signed into. Most builders test with their own session, which already owns every row they are about to fetch.
Sign out, take the anon key, and request the same URL the app requests. When the response contains data belonging to the account you just signed out of, the app is rendering whatever the API returns. Ownership was never checked.
Do this on the smallest table in the project. Small tables get created last, and the policy is the thing that gets skipped last.
The tests I run before a launch
- Grep the built bundle for provider key prefixes, then rotate whatever appears.
- Read one row as another user with the public key, and write the policy if it succeeds.
- Call every mutating route with no session, and add the check where one answers.
- Post an unsigned webhook body, and verify signatures on the raw body if the order changes.
- Open an uploaded file in a private window, and close the bucket if it loads.
Keep the results as a file in the repository. Five lines, run before every launch, each one recording the date it last passed. When a new route or table appears, the list gets a new line, and the person who added it owns that line. Documentation that lives beside the tests gets updated; documentation that lives in a wiki does not.
Five tests, about forty minutes, and not one of them requires reading the generated code. They test the deployed app instead, which is the thing anybody else would use.
What a leak costs after you fix it
The data is the cheap part. The expensive part is the week that follows. Rotate every key. Work out which rows were reachable. Tell the users who were affected. Refund the ones who ask. Spend a month wondering whether anybody noticed and said nothing.
One cost never reaches the incident notes. After a leak you change how you work. Every table gets a policy review, every route gets a test, and you stop trusting the green checkmark that used to be enough. That habit is healthy, it takes a month to build, and it slows you down for the rest of the project.
Practical people underestimate how much of that month goes to trust rather than engineering. A leak costs you the confidence of the people who already paid, and that is the resource you cannot regenerate with a migration.
The reason to run the five tests is not compliance. Each test converts a silent failure into a loud one, and loud failures before launch cost an afternoon.