Throttle credential attempts in the application, per client address and per account
Amends ADR-0079: credential fields are bounded by the attempt limit, not priced by query shape.
Decision
Charge every password check, password hash and passkey challenge to a fixed-window counter keyed on the client address, and also to one keyed on the account when the attempt names one. Charge account creation once more, to a tighter per-address counter. The charge happens before the work runs, on every transport, whether or not the caller holds a bearer token. A password can't be verified without the proof a charge returns. The counters live in the Redis instance that never evicts keys, and they fail closed. The general request limiters fail open, because they bound request volume rather than guesses, and failing closed there would make every request depend on Redis.
The client address is the one the edge proxy observed, never a forwarding header the client supplied, and a build check keeps the proxy from trusting inbound ones. IPv6 clients are counted by network prefix. IP reputation stays with CrowdSec at the edge.
Why
Only the application can see what an attempt is. A failed GraphQL sign-in is an HTTP 200, one request can alias many credential fields, and the edge can't see which account is targeted. Per-account counting stops a guesser who rotates through residential proxies. Per-address counting limits password spraying to the addresses the sprayer holds. Charging at the credential check, not per request, means neither aliasing nor signing in first buys anything.
Rejected alternatives
- Rate limiting in the edge proxy. Traefik counts per node, and the load balancer spreads clients across nodes. It also can't see accounts, outcomes or aliases.
- Limits chosen by caller identity. An authenticated caller would get a larger budget, and an account costs nothing to create, so signing in first would buy more guesses.
- Pricing credential fields at the query-complexity ceiling. It bounds aliasing only, and must be kept equal to the ceiling by hand.
- Hard account lockout. Anyone could lock a victim out indefinitely.
- Equal-cost rejections to hide which addresses have accounts. Sign-up already answers that, so it hides nothing, and the dummy work it needs is one more credential path to get right.
- Failing open. A counter that can't count would let unlimited guesses through.
Consequences
Whether an address has an account is not secret. Someone spending an account's attempts can hold its password paths shut while they keep spending, which is the cost of per-account counting without permanent lockout; passkey sign-in stays open. Clients behind one shared address, such as carrier NAT, share one budget. A Redis outage or a full store refuses every charged action until Redis recovers. Every record an anonymous caller can make the store hold is bounded in size and rate-limited, but the number of counter keys grows with the number of addresses attacking, so a wide enough attack can still fill the store while it runs.