Exploiting CSRF and OTP Reuse: How Weak Token Management Enables Password Reset Attacks, Leading…
A password reset endpoint accepted a PUT request with a JSON body containing email, OTP code, and new password, and was vulnerable to CSRF because it lacked CSRF protection. The OTP token did not expire after use when the request was made via CSRF, allowing an attacker to repeatedly change a victim's password with the same token.
Anyway, with no waste of time let’s talk about how I used a simple CSRF attack to exploit a weak token management which led to me taking over users account.
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 the password reset endpoint lacked CSRF protection and did not invalidate the OTP after use when the request was made cross-site.
Impact
An attacker could change a victim's password without their interaction beyond visiting a malicious page, leading to account takeover, and the OTP could be reused multiple times.
What the attacker needed
Victim visits a malicious page; attacker knows victim's email; attacker has a valid OTP for the victim
How it was found
- Intercept the forgot password request to receive the OTP in email.
- Create a CSRF proof-of-concept HTML page that sends a PUT request to the set-new-password endpoint with the victim's email, the OTP, and a new password.
- Open the HTML file in a browser to trigger the request.
- Attempt to log in with the old password to confirm the password was changed.
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.
A password reset form lets you set a new password if you provide a code sent to your email. The website did not check that the request came from its own pages, so another site could silently send the same request. Also, the code never expired when used this way, so the same code could be reused many times.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.