AWS Cognito brute force protection: lockout, MFA and password policy
Codemia Knowledge Hub ·
An Amazon Cognito user pool defends against brute-force password guessing mainly with a built-in account lockout: after five failed sign-in attempts the user is locked out, and the lockout grows with each further failure. On top of that you can require multi-factor authentication (MFA), enforce a strong password policy and use anomaly detection to challenge suspicious sign-ins.
Account lockout after failed sign-ins
After five failed sign-in attempts with a user's password, Cognito locks that user out for one second. The lockout then doubles with each additional failed attempt, up to a maximum of about 15 minutes. This makes rapid password guessing against one account impractical.
- Fixed behavior: the threshold and durations are set by Cognito, not configured per user pool, and AWS notes that the behavior is subject to change.
- Temporary, not permanent: users can try again once the lockout period ends, so a lockout does not permanently block legitimate users.
- Reset: the counter resets when the user signs in successfully after a lockout expires, or makes no sign-in attempts for 15 consecutive minutes.
Throttling of authentication requests
Cognito also limits how quickly authentication requests can be made, which slows attempts that come from a single source. Combined with the doubling lockout, each consecutive failure makes the next guess wait longer.
Multi-factor authentication (MFA)
MFA requires a second form of verification besides the password, so an attacker who guesses the password still needs another factor.
- Second factor options: Cognito supports SMS one-time passwords (OTPs) and time-based OTPs from authenticator apps.
- Enforcement: you can configure the user pool to require MFA before users can access their accounts.
Password policies
Strong passwords make guessing much harder, and Cognito lets you customize the password policy.
- Complexity: require a minimum length and a mix of character types such as letters, numbers and symbols.
- History: with the Essentials or Plus feature tier, you can prevent users from reusing previous passwords.
- No expiration: passwords for local users do not expire automatically. To force periodic changes, track password age yourself and require a reset.
Anomaly detection
Cognito can use machine learning to spot sign-in patterns that suggest an attack.
- Sign-in analysis: models analyze behavior to flag irregular login attempts.
- Automatic response: when it detects an anomaly, Cognito can require MFA for that session.
Summary of the defenses
| Defensive mechanism | Description |
| Account lockout | Locks the user after five failed attempts, doubling up to about 15 minutes. |
| Rate limiting | Limits authentication attempts to slow rapid attack cycles. |
| Multi-factor authentication | Requires an additional verification step beyond password entry. |
| Password policies | Enforces strong password requirements to minimize guessability. |
| Anomaly detection | Uses ML models to detect unusual sign-in activities indicating attacks. |
Related reading
- How AWS MSK and Confluent Schema Registry and Confluent Kafka connect recommended to use together?
- How can I access Amazon DynamoDB via Python?
- How can I access my AWS MSK managed kafka queue from my local machine and EC2 instances in other regions
- How can I access S3/S3n from a local Hadoop 2.6 installation?
- How can I add NSAppTransportSecurity to my info.plist file?
- How can I allow a Group to assume a Role?
- How can I automatically move messages off DLQ in Amazon SQS?
- How can I automatically start a node.js application in Amazon Linux AMI on aws?
System design interview problems on this topic
- Design Dropbox: solution and walkthrough
- Design a Global Content Distribution Network: solution and walkthrough
- Design a Serverless Architecture Framework: solution and walkthrough
- Design Youtube or Netflix: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.