Skip to content
Account takeover Write-up Advanced

Password reset code brute-force vulnerability in AWS Cognito

The password reset function of AWS Cognito allowed more guesses of the six-digit reset code than documented when requests were sent concurrently. An attacker could guess the code and change the password of accounts without multi-factor authentication.

Pentagrid Follow

Published on pentagrid.ch

The password reset function of AWS Cognito allows attackers to change the account password if a six-digit number (reset code) sent out by E-mail is correctly entered. By using concurrent HTTP request techniques, it was shown that an attacker can do more guesses on this number than mentioned in the AWS documentation…

Pentagrid AG, on pentagrid.ch

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a race condition in the rate-limiting logic of AWS Cognito's confirm_forgot_password, allowing concurrent requests to bypass the intended attempt limit.

Impact

An attacker who guessed the correct reset code could set a new password for the attacked AWS Cognito account, leading to account takeover if multi-factor authentication was not enabled.

What the attacker needed

Attacker's requests forwarded quickly to Cognito; Know valid email addresses with accounts; Attacked accounts lack multi-factor authentication; Victim ignores reset emails

The fix

The issue was fixed by AWS on 2021-04-20, after which only 20 code mismatches could be provoked.

How it was found

  1. Set up an AWS Lambda with the Chalice library and AWS Cognito components.
  2. Create an AWS Cognito user account and request a password reset via email.
  3. Send a request to the confirm_forgot_password function with an incorrect code and observe a code mismatch response.
  4. Send the incorrect code request about 30 times to trigger a limit exceeded response.
  5. Wait several hours or use a different account, then request a new password reset.
  6. Use Turbo Intruder with the race.py script to send many concurrent requests with different codes, repeating after cool-down until a 200 response is received.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When you forget your password, a website may email you a short number to prove it's you. This number is secret, so the site must limit how many times someone can guess it. Here, by sending many guesses at the same moment, an attacker could try far more numbers than the site intended, and if they guessed right they could take over the account.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

More by Pentagrid

View all

2 more disclosed reports, best first.

More from AWS

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.