vibe-audit.lab

guides · 2026-11-14

Why AI-Generated Login and API Endpoints Ship Without Rate Limits

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

The short answer

Rate limits are invisible in a demo, so generated code omits them — and an unthrottled login endpoint lets an attacker test thousands of passwords per account per hour. Add per-account and per-IP throttling on login, signup, password reset and one-time-code endpoints first, return 429s with backoff, and remember that GraphQL batching can multiply one request into a hundred login attempts.

Check your own app free: paste your code or enter your site URL on the Vibe-Code Audit homepage — the free scan checks for exposed secrets, injection flaws, XSS patterns, missing headers and exposed .env/.git paths, with a copy-paste fix for every finding. No credit card.

The demo-shaped hole

Ask an AI for a login endpoint and you get correctness without friction: verify credentials, return a token. Rate limiting is friction by design, so it never appears — there is no line in the happy path that asks for it. The result is an endpoint that answers guessing attempts as fast as your database can check a hash. Credential stuffing lists contain billions of real email/password pairs from other breaches; against an unthrottled endpoint, trying the top hundred passwords against each of your accounts is an afternoon's script, and your users who reused passwords fall in batches.

The same hole appears at signup (mass fake accounts), password reset (email flooding and token guessing), OTP verification (a 6-digit code has a million combinations — at unlimited speed, that is minutes), and any paid-API-backed feature where each call costs you money, like AI generation endpoints.

GraphQL's multiplier and other amplifiers

Vibe-Code Audit's GraphQL checks flag batching enabled for exactly this reason: a batched request can carry dozens of login mutations in one HTTP call, and naive per-request counters count it as one attempt. Aliasing does the same inside a single operation. Any throttling design must count operations, not envelopes. Similar amplifiers: password-reset endpoints that accept arrays, 'check this code' endpoints without attempt counters per code (a fresh code should also void the old one's remaining attempts), and login forms that accept both email and username, doubling the guessing surface per account.

Numbers that work as a starting point

For a small app: login — 5 failed attempts per account per 15 minutes, then a growing delay or a lockout with an email unlock path; per-IP ceiling around 100 attempts per hour across accounts to blunt spraying. Password reset — 3 emails per account per hour, and reset tokens that expire in 30–60 minutes and die on first use. OTP — 5 attempts per code, then the code is void. Signup — per-IP caps plus disposable-email screening (VibeAudit ships a disposable-domain list for its own auth for this reason). Tune from your logs: legitimate users mistype, they do not mistype forty times.

Return HTTP 429 with a Retry-After, and log every throttle event with account and IP. The log is the detection system: the first sign of a stuffing campaign is a wall of 429s, and you want to meet it in a dashboard, not in user complaints.

Where to implement it so it survives edits

Put limits at the edge or in shared middleware — a reverse-proxy rule, an API-gateway policy, or one auth middleware every sensitive route passes through — never as hand-copied code inside each generated handler, where the next AI edit drops it from the newest endpoint. Then keep a written inventory of your sensitive endpoints and test each one quarterly with a scripted burst: send 20 rapid attempts and confirm the throttle engages. The endpoints you forget are the ones that get attacked; the inventory is the control.

Worked example: Summit Scheduler, a booking SaaS

Summit Scheduler (fictional), with 1,450 user accounts, discovered its missing rate limit the hard way: an overnight credential-stuffing run made 212,000 login attempts in 7 hours; 38 accounts with reused passwords were taken over and used to send spam bookings. The rebuild put login throttling in shared middleware (5 failures per account per 15 minutes, 100 per IP per hour), capped OTP attempts at 5 per code, limited resets to 3 per hour, and alerted on throttle-event spikes. A repeat attempt two months later hit the limits within minutes, generated an alert at 03:12, and succeeded against zero accounts.

Your five-action checklist

  1. Inventory your sensitive endpoints: login, signup, password reset, OTP/code verification, and any endpoint that spends money per call.
  2. Add per-account and per-IP throttling in middleware or at the edge — never as per-handler code a future edit can drop.
  3. Count operations, not HTTP requests, so GraphQL batching and aliasing cannot multiply attempts past the limit.
  4. Return 429 with Retry-After, log every throttle event, and alert on spikes — the log is your intrusion detector.
  5. Burst-test each endpoint quarterly with 20 rapid failing attempts and confirm the limit engages.

What is Rate limiting?

capping how often a caller may perform an action in a time window — login attempts per account, resets per email, requests per IP. It converts password guessing from a bulk industrial process back into a slow, noisy, detectable one.

Sources

Frequently asked questions

Will rate limits lock out legitimate users?

Occasionally one user behind a shared IP (an office) can brush a per-IP ceiling — which is why per-account limits do the heavy lifting and lockouts need a self-serve unlock path by email. Design for the false positive, do not abandon the control.

Is a CAPTCHA a substitute for rate limiting?

No — it is a complement. CAPTCHAs raise the cost per attempt on web forms; APIs and OTP endpoints still need counters. Use both on login if abuse is active.

Why not just lock the account after 5 failures?

Hard lockouts hand attackers a denial-of-service against your users (lock anyone out by failing their login 5 times). Prefer delays, step-up challenges and IP throttles, with lockout reserved for extreme cases plus an emailed unlock.

Do I need this if I use a big auth provider?

Check rather than assume: providers offer throttling, but defaults vary and custom endpoints (your own OTP check, your reset flow) are yours. Test your live endpoints with a burst and see.

Related guides

Browse the full library on the guides index, run the checks in the launch audit, or compare plans on pricing.


Informational explainer, not a security guarantee. Scan your code free before every deploy.

← all guides

← Back