- Home
- Skills
- APIs & Backend
- API Rate Limiting and Brute-Force Protection with 429s
Works with the AI Agents you already use
API Rate Limiting and Brute-Force Protection with 429s
Add or audit API rate limits: per user, key and route, login and LLM cost limits, spoof-proof client IP, Redis, 429 + Retry-After, tested. PROTECTED / GAPS / WIDE OPEN.
$5
API Rate Limiting and Brute-Force Protection with 429s
Example session with this skill installed
Audit rate limiting on our Express API. It runs 3 instances on Render behind Cloudflare. We use express-rate-limit with 100 req / 15 min on everything. There's a /login, /reset-password, and /api/ai/chat that calls OpenAI.
- Read your context and instructions
- Compiled the api rate limiting
Rate limiting: api — VERDICT: WIDE OPEN
Deployment facts
Instances: 3 · Proxy chain: Cloudflare → Render → Express · Store: in-memory (default) · Client IP source: req.ip with trust proxy = true
Gaps found
| # | Severity | Gap | Fix |
|---|---|---|---|
| 1 | Critical | trust proxy: true trusts any X-Forwarded-For, so a client resets its limit by sending a new fake IP (express-rate-limit warns ERR_ERL_PERMISSIVE_TRUST_PROXY) | trust only the real hops; key on CF-Connecting-IP and only accept origin traffic from Cloudflare |
| 2 | High | In-memory store on 3 instances: effective limit is up to 300 per window | rate-limit-redis on the existing Redis |
| 3 | High | /login shares the global limit; no per-account limit | 5 tries / 15 min per normalized email + 20 / 15 min per IP |
| 4 | High | /api/ai/chat has no cost limit | 50k tokens / user / day budget + 2 concurrent streams |
| 5 | Medium | /reset-password can email any address 100 times | 3 / hour per target email |
| 6 | Low | 429 body is plain text and only legacy X-RateLimit-* headers are sent | JSON error body + standardHeaders: 'draft-8' |
Limits (proposed)
| Scope | Key | Limit | Algorithm | Store down | Source |
|---|---|---|---|---|---|
| Global | user id, else IP | 300 / min | sliding window | fail-open + alert | ASSUMED, tune from logs |
| Login | email + IP | 5 / 15 min, 20 / 15 min | fixed window | fail-closed | ASSUMED, common baseline |
| Reset | target email | 3 / hour | fixed window | fail-closed | your business rule |
| AI chat | user id | 50k tokens / day, 2 concurrent | token budget | fail-closed | your OpenAI budget |
Test results
test/rate-limit.spec.ts: 6/6 pass. Request 6 to /login for one email returns 429 with Retry-After: 893. Changing X-Forwarded-For no longer resets the count. Limit holds across 2 local instances sharing Redis.
Verdict will move to PROTECTED once gaps 1 to 4 are deployed.
Connects securely to your tools. The creator never sees your data.
About this skill
Most APIs have either no rate limit or one that does not work: an in-memory limiter on three instances, a key based on a spoofable X-Forwarded-For, or a single global limit that leaves login, password reset and the LLM endpoint wide open. That is how you get credential stuffing, SMS pumping and a surprise bill.
This skill gives your coding agent a procedure and a reference file covering the standards (RFC 6585 429, Retry-After, the IETF RateLimit header draft, OWASP API4:2023) and the main libraries. It:
- Maps every route and tags it: auth, expensive, write, read, webhook
- Audits what exists: store, key, proxy trust settings, what a blocked client gets, and whether limits run before expensive work
- Designs layered limits: edge, global per identity, stricter per-route, account-based login/OTP limits, token or money budgets for LLM calls, and concurrency limits
- Picks the algorithm per limit (token bucket, GCRA, sliding window) and explains why
- Implements with your framework's maintained library (express-rate-limit, @fastify/rate-limit, NestJS Throttler, Upstash, DRF, Flask-Limiter, Rack::Attack, Laravel, Go) and a shared store
- Gets the real client IP behind your CDN or load balancer, and groups IPv6 by prefix
- Returns 429 with Retry-After and RateLimit headers, without revealing whether an account exists
- Tests it, including a spoofing test and a cross-instance test
- Returns a limits table and a verdict: PROTECTED, GAPS or WIDE OPEN
Who it is for: backend developers, SaaS founders and API owners who need limits that hold up, not just a middleware line.
Safety: asks before adding infrastructure, and marks any limit number it had to assume as ASSUMED so you can tune it from real traffic.
Honesty note: it only reports tests it actually ran.
Requires Redis or similar for multi-instance apps. Cannot fix upstream ISP-level DDoS. User must provide traffic metrics for non-assumed limits.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 29 days ago