A Broken Authentication vulnerability occurs when the API returns the One-Time Password (OTP) directly in the response after a user requests it.
Intended flow:
User requests an OTP → OTP is sent via SMS, email, or app → User enters OTP → Server validates OTP
Vulnerable flow:
User requests an OTP → API responds with the OTP in the response body
Example:
{ "status": "OTP sent successfully", "otp": "123456" }
Any attacker who can view the API response (e.g., via a compromised mobile app, browser, or logs) can use the OTP to authenticate — without needing access to the actual delivery channel (SMS/email/etc.).
Anyone with access to the response (like a malicious app user or attacker using an intercepted token) can instantly retrieve the OTP and skip the verification process altogether.
If an attacker has or guesses valid usernames, they could generate OTPs on demand and use the returned values to gain unauthorized access to user accounts.
Attackers can script OTP generation using tools like curl, Burp Suite, or Postman to automate logins at scale — making the vulnerability much more exploitable
Sharing OTPs in responses may breach regulatory requirements such as GDPR, HIPAA, or PCI-DSS, leading to legal consequences or fines.
To secure OTP-based workflows, consider the following best practices:
Exposing OTPs in API responses is a high-risk security flaw that can be exploited easily if overlooked. It’s simple to fix but requires attention to detail in API design and dev practices.