AWS Cognito 用户池如何防御暴力破解攻击
How AWS Cognito User Pool defends against bruteforce attacks
我将使用 AWS Cognito 用户池产品作为应用程序的用户目录,有几个问题:
- Amazon 是否限制了对 Cognito 用户池的请求?如果是,调用的速率限制是多少?
- Cognito 如何抵御对 login/password 的暴力破解攻击?
是的,Cognito 用户池通过使用各种安全机制来防止暴力攻击。节流是其中一种机制。我们不共享限制,因为它们会动态变化。
经过几个小时的搜索,我在源代码中发现了这两个异常:
TooManyFailedAttemptsException This exception gets thrown when the
user has made too many failed attempts for a given action (e.g., sign
in).
HTTP Status Code: 400
TooManyRequestsException This exception gets thrown when the user has
made too many requests for a given operation.
HTTP Status Code: 400
此外,我尝试使用错误的凭据登录以测试限制,在 5 次尝试后出现 NotAuthorizedException: Password attempts exceeded
异常。
在类似的情况下,我尝试暴力破解忘记密码,但在 10 次尝试失败后我得到 LimitExceededException: Attempt limit exceeded, please try after some time.
我认为他们就是这样做的。
这包含有关 Cognito 锁定策略的最新文档。
We allow five failed sign-in attempts. After that we start temporary lockouts with exponentially increasing times starting at 1 second and doubling after each failed attempt up to about 15 minutes. Attempts during a temporary lockout period are ignored. After the temporary lockout period, if the next attempt fails, a new temporary lockout starts with twice the duration as the last. Waiting about 15 minutes without any attempts will also reset the temporary lockout. Please note that this behavior is subject to change.
与其(或除了)关注暴力破解登录端点,我认为忘记密码流程值得关注。
忘记密码电子邮件包含一个 6 位代码,可用于设置新密码。
此代码的有效期为 1 小时。 User Pools code validity resource quotas.
在我的测试中,在节流生效之前,我可以在一小时内为单个用户尝试 5 次设置新密码 (LimitExceededException: Attempt limit exceeded, please try after some time.
)
现在,如果我计算正确,一个代码有 1000000 个可能的值(根据我的测试,我从未见过以 0
开头的代码,因此可能更少)。你有 5 attempts/hr 来猜密码。因此,每小时您都有 5/1000000*100=0.0005%
机会在不知道代码的情况下成功重置密码。
这是一个小机会吗?好像是。
考虑一次大规模攻击并发重试强制多个用户,我晚上应该睡个好觉吗?我不知道!
为了一劳永逸地解决这个问题,为什么Cognito不能使用更长的难以猜测的代码(我想晚上睡个好觉)。也许这与在短信中使用相同的代码机制这一事实有关。我希望有官方评论。
我将使用 AWS Cognito 用户池产品作为应用程序的用户目录,有几个问题:
- Amazon 是否限制了对 Cognito 用户池的请求?如果是,调用的速率限制是多少?
- Cognito 如何抵御对 login/password 的暴力破解攻击?
是的,Cognito 用户池通过使用各种安全机制来防止暴力攻击。节流是其中一种机制。我们不共享限制,因为它们会动态变化。
经过几个小时的搜索,我在源代码中发现了这两个异常:
TooManyFailedAttemptsException This exception gets thrown when the user has made too many failed attempts for a given action (e.g., sign in).
HTTP Status Code: 400
TooManyRequestsException This exception gets thrown when the user has made too many requests for a given operation.
HTTP Status Code: 400
此外,我尝试使用错误的凭据登录以测试限制,在 5 次尝试后出现 NotAuthorizedException: Password attempts exceeded
异常。
在类似的情况下,我尝试暴力破解忘记密码,但在 10 次尝试失败后我得到 LimitExceededException: Attempt limit exceeded, please try after some time.
我认为他们就是这样做的。
这包含有关 Cognito 锁定策略的最新文档。
We allow five failed sign-in attempts. After that we start temporary lockouts with exponentially increasing times starting at 1 second and doubling after each failed attempt up to about 15 minutes. Attempts during a temporary lockout period are ignored. After the temporary lockout period, if the next attempt fails, a new temporary lockout starts with twice the duration as the last. Waiting about 15 minutes without any attempts will also reset the temporary lockout. Please note that this behavior is subject to change.
与其(或除了)关注暴力破解登录端点,我认为忘记密码流程值得关注。
忘记密码电子邮件包含一个 6 位代码,可用于设置新密码。
此代码的有效期为 1 小时。 User Pools code validity resource quotas.
在我的测试中,在节流生效之前,我可以在一小时内为单个用户尝试 5 次设置新密码 (LimitExceededException: Attempt limit exceeded, please try after some time.
)
现在,如果我计算正确,一个代码有 1000000 个可能的值(根据我的测试,我从未见过以 0
开头的代码,因此可能更少)。你有 5 attempts/hr 来猜密码。因此,每小时您都有 5/1000000*100=0.0005%
机会在不知道代码的情况下成功重置密码。
这是一个小机会吗?好像是。
考虑一次大规模攻击并发重试强制多个用户,我晚上应该睡个好觉吗?我不知道!
为了一劳永逸地解决这个问题,为什么Cognito不能使用更长的难以猜测的代码(我想晚上睡个好觉)。也许这与在短信中使用相同的代码机制这一事实有关。我希望有官方评论。