BOOK THIS SPACE FOR AD
ARTICLE ADIntroduction
During a routine security assessment of a web application, I discovered a critical email verification bypass vulnerability. This flaw could allow an attacker to gain unauthorized access to a victim’s account by exploiting weaknesses in the OTP (One-Time Password) generation and validation process. Here, I’ll walk you through the steps to reproduce the vulnerability, its impact, and recommendations to fix it.
1.Login to an account you control:
Log in using your own account with an email like hacker@gmail.com.2. Change the email address:
Go to the “Change Email” section of the application and change the email to another one you own, such as victim@gmail.com.An OTP will be sent to verify the new email address (e.g., 187182).3.Log out and back in:
Log back into your account using your original credentials.4.Change the email to the victim’s email:
Now, change the email address to a victim’s email (e.g., victim@example.com) and log out.5.Log in using the victim’s email:
Attempt to log in using the victim’s email address. The system will prompt for an OTP to verify the email.Enter the OTP (187182) that was sent earlier to your own email address (hacker@gmail.com).6.Email verified successfully:
The system accepts the OTP, verifies the victim’s email, and grants you access to the account.The vulnerability arises because:
Non-unique OTPs: The system generates the same OTP for multiple email addresses, failing to differentiate between accounts or contexts.Weak OTP validation: The OTP is not linked to a specific session, email address, or request.Lack of OTP invalidation: The OTP remains valid even after it is used or when the context changes.This vulnerability can lead to:
Account Takeover (ATO):An attacker can gain full control of a victim’s account by verifying their email address.Loss of User Data:
Sensitive information stored in the account may be exposed to unauthorized users.Security Breach:
Exploiting this flaw across multiple accounts could lead to widespread user compromise.
1.Unique OTPs:
Generate a unique OTP for each email verification request.Use secure random number generators for OTP creation.2.Link OTPs to Context:
Associate OTPs with the specific email address and session for which they are generated.OTPs should not work outside their intended context.3.Invalidate OTPs After Use:
Once an OTP is successfully used, it should be invalidated immediately.4.Add Expiration and Rate Limits:
Set an expiration time for OTPs and limit the number of OTP requests per user in a given time frame.5.Audit Logs and Alerts:
Maintain logs of email change requests and notify users of any changes to their account.This vulnerability demonstrates the importance of robust OTP implementation for email verification. Developers must ensure that OTPs are unique, context-aware, and properly invalidated to prevent misuse.
If you are a developer, consider adopting the recommendations above to secure your platform. For fellow security researchers, keep exploring and reporting vulnerabilities to make the web a safer place for everyone.
Thank you for reading!
— Muralidharan
Connect with me on LinkedIn: Muralidharan