The login endpoint is hit with millions of credential-stuffing requests from thousands of IPs. How do you protect it?

IntermediateScenarioSecurity incidents
Answer

Situation read → It's distributed, so blocking single IPs won't work. You need layered rate limiting and bot detection at the edge, before traffic reaches the app.

What I'd do →

  1. Put AWS WAF (or Cloudflare) in front with a rate-based rule scoped to the login path:
{
  "Name": "login-rate-limit",
  "Priority": 1,
  "Action": { "Block": {} },
  "Statement": {
    "RateBasedStatement": {
      "Limit": 100, "AggregateKeyType": "IP", "EvaluationWindowSec": 300,
      "ScopeDownStatement": { "ByteMatchStatement": {
        "FieldToMatch": { "UriPath": {} }, "SearchString": "/api/login",
        "PositionalConstraint": "STARTS_WITH", "TextTransformations": [{ "Priority": 0, "Type": "NONE" }] } }
    }
  },
  "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "login-rate" }
}
  1. Add the AWS managed rule groups for known bad IPs, and the Account Takeover Prevention (ATP) group for login pages.
  2. Add a CAPTCHA or challenge action on suspicious requests instead of blocking real users.
  3. In the app: per-account lockout with backoff, and MFA to make stolen passwords useless.
  4. Watch for successful logins from the attack sources and force password resets for those accounts.

Why → Edge controls protect capacity; app controls protect accounts. You need both.

Interview tip → Separate "keep the service up" from "keep accounts safe"; they are two different goals.

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents