Fine with "1234"? An Analysis of SMS One-Time Password Randomness in Android Apps

Siqi Ma, Juanru Li, Hyoungshick Kim, Elisa Bertino, Surya Nepal, Diethelm Ostry, Cong Sun

Abstract

SMS One-Time Passwords (OTPs) are a cornerstone of mobile authentication, yet their security relies entirely on the unpredictability of server-side Pseudo-Random Number Generators (PRNGs). This paper investigates the security of these systems by introducing OTP-Lint, a black-box dynamic analysis tool designed to evaluate OTP randomness without access to server-side source code. By analyzing 2,022 Android apps, the study reveals that nearly 20% generate predictable OTPs, exposing users to account hijacking via guessing and replay attacks.

Introduction

SMS OTPs are a standard method for user authentication, relying on the assumption that generated numbers are uniquely unpredictable. This unpredictability depends on secure PRNGs. However, developers often implement PRNGs incorrectly—for example, by using static seeds, predictable timestamps, or cryptographically insecure algorithms like Mersenne Twister.

A major roadblock for security researchers is that OTP generation happens on the server side, making traditional static code analysis impossible. To address this, the authors developed a method to assess the cryptographic security of these server-side PRNGs purely from the outside by observing the OTP sequences sent to the client device.

Methodology: The OTP-Lint Pipeline

The authors developed OTP-Lint, an automated dynamic analysis tool that evaluates OTP randomness through a three-stage pipeline:

  1. Authentication Locator: Identifying login screens is challenging due to custom variable naming. OTP-Lint uses a fuzzing-inspired approach combined with Natural Language Processing (NLP) to identify login Activity components based on code dependencies rather than simple keyword matching.
  2. Request Processor: The tool automatically interacts with the app's UI using Android's UI Automator and Monkey. It inputs a phone number, triggers the OTP request, and extracts the received OTP directly from the rooted device's SMS database.
  3. Vulnerability Detector: OTP-Lint collects a sequence of OTPs and tests them against three core randomness rules derived from RFCs and known bad practices: avoiding static values, avoiding specific patterns (like fixed period lengths), and avoiding predictable seeds.
The architecture of OTP-Lint, featuring the Authentication Locator and Vulnerability Detector.

Experimental Setup

The authors analyzed 6,431 top-listed Android apps across 21 categories from Google Play (1,000 apps) and Tencent MyApp (5,431 apps). Out of these, OTP-Lint successfully identified 2,022 apps that actively implemented SMS OTP login, forming the core dataset for randomness evaluation.

Key Results and Findings

The analysis revealed widespread vulnerabilities in the implementation of SMS OTPs across the mobile ecosystem. Out of 2,022 apps tested, 399 apps (19.7%) generated predictable OTPs that violated basic randomness rules.

Summary of apps violating randomness rules as detected by OTP-Lint.

Major Vulnerabilities Identified:

  • Static OTPs: 41 apps used a completely static OTP value for every login attempt.
  • Insecure Algorithms: 162 apps generated a repeated sequence of OTPs with a fixed period length of 624, strongly indicating the use of the insecure Mersenne Twister (MT19937) algorithm. The authors successfully reversed the seeds for all of these apps using off-the-shelf tools.
  • Predictable Binary Patterns: 125 apps generated OTPs with predictable binary representations, such as shifting binary digits iteratively, which drastically reduces the search space for an attacker.
  • Single Point of Failure: 194 of the vulnerable apps relied on OTP as their sole authentication mechanism (no password required), leaving them completely exposed to account takeovers.

Discussion and Insights

The study highlights a phenomenon of "Security Theater," where apps implement OTPs that appear random to humans in decimal format but are cryptographically trivial to predict. By analyzing GitHub and Stack Overflow, the authors found that developers frequently copy-paste insecure PRNG initialization code, such as seeding with a constant value. Furthermore, even when OTPs look random in base-10, converting them to binary often reveals simple bit-shifting operations or parity patterns that compromise security.

Conclusion and Future Work

OTP-Lint demonstrates that a significant portion of the Android ecosystem is vulnerable to OTP prediction attacks. While effective, the tool currently relies on predefined rules extracted from known bad code. Future work aims to incorporate more robust, generalized statistical tests, such as the NIST SP 800-22 suite, to evaluate the randomness of unseen PRNGs and overcome challenges posed by code obfuscation and packing.

Summary updated

BibTeX
@inproceedings{ma2021fine,
  author = {Siqi Ma and Juanru Li and Hyoungshick Kim and Elisa Bertino and Surya Nepal and Diethelm Ostry and Cong Sun},
  title = {{Fine with "1234"? An Analysis of SMS One-Time Password Randomness in Android Apps}},
  booktitle = {ICSE},
  year = {2021},
  doi = {10.1109/icse43902.2021.00148},
}
Figure