{"success":true,"name":"rate-limit-and-slow-down-endpoints-attackers-can-hammer","description":"Building login, signup, password reset, OTP, or any endpoint that sends messages","category":"ai-brimind","path":"ai-brimind/rate-limit-and-slow-down-endpoints-attackers-can-hammer/SKILL.md","file":"SKILL.md","content":"---\nname: rate-limit-and-slow-down-endpoints-attackers-can-hammer\ndescription: \"Building login, signup, password reset, OTP, or any endpoint that sends messages\"\n---\n\n# Rate-Limit and Slow Down Endpoints Attackers Can Hammer\n\n## When to use\nYou are creating an endpoint that checks credentials, sends emails/SMS, creates accounts, or costs money per call, and nothing yet limits how often one client can hit it.\n\n## Example request\nA login endpoint with no limit → a bot tries thousands of passwords per minute; add rate limiting and lockout/backoff (brute-force protection). A 'forgot password' form that says 'this email does not exist' → attackers use it to discover valid accounts; always answer the same way (user enumeration). An OTP check with unlimited tries → a 6-digit code only has a million options and falls fast; cap attempts and expire codes (OTP brute force). A contact form that sends email on every request → bots turn your server into a spam machine and burn your quota; throttle per IP and add a CAPTCHA if needed (abuse of costly actions).\n\n## Instructions\nAct like a defender who assumes every public endpoint will be hit by a script, not a person. Before finishing the endpoint, classify what an attacker gains by calling it many times: guessing secrets (passwords, OTPs, tokens), discovering valid accounts, creating junk data, or making you pay (email, SMS, compute). For each gain, apply the matching brake: rate limiting per IP and per account, attempt counters with lockout or increasing delays, short expiry on codes and reset links, identical responses whether an account exists or not, and CAPTCHAs or verification only where automation pressure is real. Check first whether the framework, gateway, or hosting platform already offers rate limiting as a built-in feature before writing a custom counter — and if you must store attempts yourself, store them server-side, never in something the client can reset. Test your own design by asking: 'if I ran this request in a loop 10,000 times, what breaks or leaks?' If the answer is 'nothing stops me', the endpoint is not done. Only ship once each abusable endpoint has a named limit and you can explain how it defeats the specific attack loop (credential stuffing, enumeration, quota burning), not just how it behaves for one polite user.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #518\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}