rate limiting a public worker endpoint — the rate limit binding, a durable object, or kv
public signup and a password reset endpoint on a worker, both currently unprotected, and someone spent last tuesday evening hammering the reset one. i want something that stops abuse without me writing an accounting system. i've read that the rate limit binding is per location, which sounds like it means a determined person just gets a fresh bucket in every city.
@borrowck_ben · 5mo ago
Your reading is right and it matters less than you think. The docs are upfront: limits are local to the Cloudflare location your worker runs in, there's a separate limit per key per location, and the whole thing is described as permissive, eventually consistent and deliberately not an accurate accounting system.
So yes, in theory an attacker distributed across twenty locations gets twenty buckets. In practice the person hammering your reset endpoint on a Tuesday evening is coming from one place, and the binding stops them with about six lines of config. The other constraint to know before you design around it: the period must be either 10 or 60 seconds. Nothing longer. If you wanted "5 resets per hour per email," that binding cannot express it.
Reply
Report