> For the complete documentation index, see [llms.txt](https://notes.dollarboysushil.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.dollarboysushil.com/web-application-pentest/bugforge/business-logic-flaw/cheesy-does-it-forgot_password-flaw.md).

# Cheesy Does It  (forgot\_password flaw)

Level: Easy\
Points: 10\
Type: Daily Challenge

During register/login we can see forgot password feature.

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2FVnotk0j9iwHX4xkrb8j4%2Fimage.png?alt=media&amp;token=022ee031-af87-407e-b613-a651e3630127" alt=""><figcaption></figcaption></figure>

Forgot-password takes only one arguement i.e `username` , we can pass any username here.

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2FHmFg8M2VW8WOfI1pAhJf%2Fimage.png?alt=media&amp;token=af38eb0a-9ee9-44c6-a05c-9470604d9b17" alt=""><figcaption></figcaption></figure>

Once username is passed, OTP is sent to account's email address. The ui doesnot takes the value more than 4 digit.\
Meaning we can try to bruteforce the OTP.

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2Fk3wWyR1TyNltnYoapNiV%2Fimage.png?alt=media&amp;token=16a00ea7-8261-40ce-a885-b95175908adf" alt=""><figcaption></figcaption></figure>

There is no any rate limiting system and we can successfully bruteforce the OTP.\
After successfull OTP bruteforce, we get the reset\_token

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2Fr9wpLAAxb2TOlRRP9xpw%2Fimage.png?alt=media&amp;token=b06cd174-2ffa-4f27-ae89-e116cb499bc5" alt=""><figcaption></figcaption></figure>

From the js file,we can get idea on how to use the reset\_token to change the password.

POST request to /api/verify-token with values of&#x20;

* `username`&#x20;
* `reset_token`&#x20;
* `new_password`

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2FMOuV7upQ0OOklpTecmwq%2Fimage.png?alt=media&amp;token=7fff660b-0fa2-48eb-9b55-559dd73d3e3e" alt=""><figcaption></figcaption></figure>

Password successfully changed.

Now, we can login as admin and get the flag.

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2F4PAPAnElODKIbGkObpo3%2Fimage.png?alt=media&amp;token=1d5c8c30-2810-49e4-b51f-5f7691bac823" alt=""><figcaption></figcaption></figure>
