Skip to content
mentoor

Topic 4 of 5 · 6 min read

What breaks in vibe-coded apps

Goal: Spot the security or data flaw in a vibe-coded app's code or configuration.

Vibe-coded apps usually fail in the parts that work silently when everything is fine: secrets, access checks and data handling. The screens look right. The flaws sit behind them, where nobody looks because nothing is visibly broken.

Check yourself · 1 of 3

A vibe-coded app shows the admin button only to admins, but its server accepts admin requests from anyone. What is the flaw?

Choose one answer

Why it matters

An AI tool is asked to make a feature work. It does that. It was not asked to keep a stranger out, so it often does not. Access control failures (a user reaching data they should not see) are listed by OWASP among the top web app risks, and they are very common in generated apps. The user sees a working app. The attacker sees open doors.

The usual failures

  1. Exposed keys. The AI puts an API key or database password straight in the code, including code that runs in the browser. Anyone can open the page source and copy it. Pushing it to a public repository does the same. Deleting it later does not help, because the key is already out; it must be revoked and replaced.
  2. Missing login checks. A page hides the admin button, but the server endpoint behind it accepts any request. Hiding a button is not security.
  3. No database access rules. With services such as Supabase, the browser talks to the database directly. If row level security is off, any visitor can read or change every row. The app works perfectly, so nobody notices.
  4. Trusting the client. The price, the user id or the role comes from the browser, and the server believes it.
  5. Lost or silently wrong data. No backups, errors swallowed, or a migration that drops a column.
  6. Code nobody can maintain. Duplicate logic, changes layered on changes, and no tests. The next prompt breaks something else, and nobody knows why.

Before and after

Weak (code that runs in the browser):

const stripe = new Stripe("sk_live_...redacted");
const rows = await db.from("orders").select("*");

The secret key is visible to every visitor, and the query returns all customers' orders.

Better:

// server only; key comes from the environment
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
const rows = await db.from("orders").select("*").eq("user_id", session.userId);

The key never reaches the browser, and the query returns only the signed-in user's rows. The database should enforce the same rule, not only the code.

What goes wrong when you check

  • Testing only as yourself. Open the app signed out, and as a second user, and try to reach the first user's data.
  • Believing the AI's security summary. It may say "secure" without having changed anything.
  • Fixing the symptom. Moving a key into a file in the repository still publishes it.

Look for these flaws on purpose. They do not announce themselves.

Examples

A key in browser code

// runs in the browser
const client = createClient("https://app.example.co", "service_role_key_...redacted");

A service role key skips all database rules. In the browser, any visitor can copy it and read or delete everything. Browser code may hold only the public, low-privilege key, and the database rules must limit what that key can do.

A missing ownership check

app.get("/api/invoices/:id", async (req, res) => {
  const invoice = await db.invoices.find(req.params.id);
  res.json(invoice);
});

The route returns any invoice to anyone who guesses an id. Add a check that invoice.userId equals the signed-in user, and return an error otherwise.

Key points

  • The most common vibe-coding flaws are exposed secrets, missing server-side login checks and missing database access rules.
  • Hiding a button or page in the interface is not access control; the server and database must enforce it.
  • A leaked key must be revoked and replaced, since deleting it from the code does not remove copies.
  • Never take price, role or user id from the browser without checking it on the server.
  • Test as a signed-out visitor and as a second user to find data that should not be reachable.

Common mistakes

  • Assuming a feature is safe because the interface hides it.
  • Deleting a leaked key from the code but leaving it active.
  • Testing only as the owner account, never as a stranger.
  • Asking the AI "is this secure?" and accepting the answer without checking.

Check yourself · 2 of 3

An AI-written page has a secret payment key in its browser code. What must you do?

Choose one answer

Check yourself · 3 of 3

Why can an app with row level security turned off still seem to work perfectly?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic