OTP Leaking Through Cookie Leads to Account Takeover
The website placed the one-time password (OTP) used for login into a cookie that was sent to the browser before the OTP was validated. An attacker who knew a victim's mobile number could request an OTP for that number, read the OTP from the cookie, and use it to log in as the victim.
This time I am going to discuss an OTP leaking vulnerability that leads to account takeover in an e-commerce website.
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 application generated the OTP and stored it in a client-side cookie before validating it, instead of keeping it server-side and only sending it to the user's phone.
Impact
An attacker who knows a victim's mobile number could take over the victim's account by reading the OTP from the cookie; the report also notes that registration did not validate mobile numbers or email addresses.
What the attacker needed
Victim's mobile number known; attacker can trigger OTP login for that number
How it was found
- Register an account on the website.
- Choose the login with OTP option and enter the registered mobile number.
- Inspect the cookies in the browser and observe a cookie containing the OTP value.
- Enter the OTP to validate it and log in successfully.
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 one-time password (OTP) is a short code sent to your phone to prove it is you when you log in. Here, the website put that secret code into a cookie, which is a small piece of data the website stores in your browser. Because the code was visible in the browser before it was even used, anyone who could trigger a login for someone else's phone number could read the code and log in as that person.
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.