Vibe Code Guardian
← All posts

Someone Is Hammering Your AI-Built App: Rate Limits, Retry Loops and the Bill That Follows

An AI-built app often ships with no limit on how often anyone can call it. One user, a script or a retry loop can run your bill up in an afternoon. What goes wrong, why the AI never added limits, and what to put in place before launch.

Aaron Allen·

Most AI-built apps have no brakes. That sentence sounds dramatic until you look at what the AI actually generated. Your Lovable or Cursor app will happily let one person hit your database, call your AI features or run your expensive searches as many times per second as their browser can manage, because nobody asked it to stop them.

For a while that costs you nothing. Then something changes: a link gets shared, a competitor gets curious, a script starts scraping, or a stuck client starts retrying a failing request in a loop. By the time you notice, the damage is usually on an invoice rather than in an error log.

What a hammering actually looks like

It is rarely a movie-style attack. In practice it looks like one of these:

A stuck retry loop. Your app calls a paid API, the call times out, the frontend retries automatically, and the retry also times out. Modern browsers and HTTP libraries retry by default in several situations, so a single unlucky user on a train can burn through hundreds of paid calls without touching a button.

A scraper. Somebody likes your data: your prices, your listings, your search results. They write a small script that asks for a page every half a second. Nothing breaks. Your database just does ten thousand times more work than it was built for, and your invoice at the end of the month quietly reflects that.

A viral link. This is the good problem, but it is still a problem. A post does well, a few thousand people arrive in a day, and your free-tier database or your pay-per-call AI feature falls over or runs up a bill you never budgeted for.

One user with a big job. Somebody imports two thousand rows, or runs a search that fans out into fifty AI calls, and your happy path becomes your worst case. No malice required.

Why the AI never added limits

Because you never asked, and because limits make demos worse. When you prompted for "let users search their documents", the AI built the shortest path between a search box and an answer. Rate limits, quotas and cost caps are invisible in a demo and annoying to build, so they exist in almost no vibe-coded first draft.

There is a second reason that catches people out: some of your costs live in places the AI never wrote code for. If your app calls OpenAI or Anthropic through a server function, the per-call cost is real, but the AI had no reason to think about it. It wired up the call and moved on. The bill is your problem, not its acceptance test.

The limits worth having, in order

You do not need a full API platform on day one. You need three things, roughly in this order.

First, a per-user cap on the expensive paths. Anywhere your app spends money per call, such as AI features, PDF generation, email sends or heavy searches, decide what a normal user does in a day and enforce roughly that. Ten AI summaries per day per user might be generous; whatever the number is, make the app refuse call number eleven rather than just charging you for it.

Second, a cap for people who are not logged in. Contact forms, signups, password resets and public search should not be callable by a script at full speed. A simple limit per IP address, such as five per minute, stops the cheapest and most common abuse. Most platforms you are already on can do this: Vercel, Netlify, Cloudflare and Supabase all have a way to rate limit at the edge, and it usually takes minutes rather than days.

Third, a hard ceiling on the money. This is the one people forget. Set spend limits on your AI and email providers, turn on billing alerts, and use a prepaid or capped arrangement for anything with metered pricing while the app is young. If a script finds a hole at 3am, a spend cap turns a potential four-figure surprise into a stopped service you fix over breakfast. Check this now: log into your OpenAI, Anthropic, Resend or Stripe dashboards and see whether any limit is actually set. Most people find the answer is no.

The retry problem nobody warns you about

Here is a pattern we see that has nothing to do with attackers. Your app calls an API. The call fails. The frontend (or a background job) retries. The API is slow because of load, so the retry also fails, so something retries again. If each retry is a paid call, a single outage becomes a billing event.

The fixes are small. Retry with a delay that grows each time (one second, then four, then sixteen), cap the number of retries, and never retry an expensive call from the client while the user is watching a spinner. If a request timed out, do not assume it failed: it may have succeeded after you gave up waiting, so retrying can charge the customer twice as well as paying the API twice. That double-charge risk is worth checking in any AI-built app that takes payments, because AI-generated code almost never handles it.

What to do this week

  1. Find your expensive paths. List every place a single user action can trigger a paid or heavy call: AI features, emails, PDFs, exports, big searches.

  2. Put a number on each. How many per user per day is normal? Double it for headroom, and enforce it.

  3. Rate limit the public endpoints. Five requests per minute per IP on forms and public search stops most scripts.

  4. Set spend caps and alerts on every provider that bills per call.

  5. Check your retries. Growth-cap the delay, cap the count, and make sure a timeout cannot double-charge anyone.

None of this needs a rewrite. Each item is a small change to an existing function, and together they are the difference between a link doing well and a link costing you a month's profit.

If you would rather have someone else find these gaps, that is part of what we do. Our launch-readiness audit covers speed and running costs alongside the security checks, and every finding comes with the fix written in plain English. You can also start with the free surface check, which takes a few minutes and costs nothing.

Want a developer to look at your app?

Built your app with AI tools? Run the free surface check yourself in a few minutes. Nothing to buy, and we never look at your app unless you run it.