Question presented to candidate: "An attacker scripts thousands of login attempts per second against your /login endpoint, trying every password in a common wordlist. What specifically stops this, versus what stops a flood of requests trying to simply overwhelm your server's capacity?"
What a strong answer should cover:
- Brute-force protection and general DoS protection are related but genuinely distinct concerns: brute-force specifically targets guessing a secret (a password) through repeated attempts; DoS targets overwhelming capacity through sheer request volume — the fixes overlap significantly (rate limiting) but the specific configuration and additional layers differ.
- 📌 Verified, not assumed: a real rate-limiting middleware (
express-rate-limit,max: 3per window) allowed the first 3 requests through with 200 responses (theratelimit-remainingheader correctly counting down 2, 1, 0), then genuinely blocked requests 4 and 5 with a real 429 status — confirmed directly, not described. - For brute-force specifically: rate limiting should be tighter and keyed by the target identity (the specific username/account being attempted, not just source IP — an attacker can distribute attempts across many IPs), and account lockout or exponential backoff after repeated failures adds a second, complementary layer beyond a flat rate limit.
- For general DoS/volume-based protection: a request body size limit (preventing a single oversized payload from consuming excessive memory/CPU to parse), a connection/request timeout (preventing a slow or stalled client from holding a connection open indefinitely), and — at the infrastructure layer, beyond application code — a CDN/WAF absorbing volumetric attacks before they ever reach the application at all.
- A precise answer names that application-level rate limiting alone cannot fully stop a sufficiently large, distributed volumetric attack — that requires infrastructure-level mitigation (a CDN, a dedicated DoS-protection service) in front of the application, which application-level rate limiting complements rather than replaces.
- Correct password hashing (
scrypt/pbkdf2, covered fully with a real verified hash-and-verify pair in its own dedicated question) is itself a passive brute-force defense — a deliberately slow hashing algorithm makes each individual guess attempt computationally expensive for an attacker even if they somehow bypassed rate limiting entirely.
Clarifying questions expected:
- "Is the concern brute-forcing a specific secret, or a general flood of traffic trying to overwhelm capacity?" — the two share some defenses but need different specific configuration.
- "Is infrastructure-level mitigation (a CDN/WAF) already in place, or does this need to be handled entirely at the application layer?"
Code / implementation expected: Yes — the real, measured rate-limiter behavior (200s counting down to a genuine 429) is the concrete, convincing proof of the core mechanism, cross-linked to the dedicated password-hashing question for the complementary, passive brute-force defense.