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 →
- 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" }
}
- Add the AWS managed rule groups for known bad IPs, and the Account Takeover Prevention (ATP) group for login pages.
- Add a CAPTCHA or challenge action on suspicious requests instead of blocking real users.
- In the app: per-account lockout with backoff, and MFA to make stolen passwords useless.
- 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.
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner