Vulnerability Fixation
Client-Side OTP Generation

Client-Side OTP Generation

If OTPs are generated client-side and exposed in requests or responses, it severely compromises their security, rendering the authentication process vulnerable.

Additionally, if the OTP logic or algorithm is hardcoded in client-side code, attackers can reverse-engineer it to predict future OTPs or bypass the verification entirely. Such implementations allow attackers to impersonate legitimate users, perform unauthorized transactions, or gain access to sensitive information.

Vulnerability

  • When OTPs are generated on the client (browser or mobile app), attackers can view or manipulate them easily since the client environment is not secure.
  • Exposed OTPs in requests or scripts can be intercepted, replayed, or reverse engineered. This defeats the purpose of OTPs as secure, server-issued tokens meant for temporary authentication.
Impact

Client-side OTP generation exposes systems to:

  • MITM & Replay Attacks: OTPs can be intercepted or reused.
  • Credential Stuffing: Attackers automate OTP reuse across accounts.
  • Account Compromise: Leads to data breaches and loss of user trust.
  • Organizations may also face compliance violations and financial loss.
Solution

  • Generate OTPs Server-Side: Use cryptographic libraries (e.g., TOTP/HOTP via pyotp, Google Authenticator APIs) for secure OTP creation.
  • Encrypt Transmission: Always use HTTPS/TLS and avoid exposing OTPs in URLs or plaintext requests.
  • Secure Delivery: Send OTPs only through trusted channels like SMS, email, or authenticator apps.
  • Implement Rate Limiting.

Also Read :