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

TL;DR

Researchers have developed OTP-Lint, a novel automated tool that identifies security vulnerabilities in SMS One-Time Password (OTP) implementations without needing access to server-side source code. By analyzing over 6,000 Android apps, they discovered that nearly 20% of apps using SMS OTPs generate predictable or even static values, leaving millions of users vulnerable to account hijacking.

What Problem Does This Paper Address?

The security of SMS-based authentication hinges on a single premise: the one-time password must be a truly unpredictable pseudo-random number (PRN). If a Pseudo-Random Number Generator (PRNG) is poorly implemented—for instance, by using a static seed or a cryptographically insecure algorithm—the resulting "random" codes become predictable.

The major challenge for security researchers is that OTP generation almost always happens on the server-side. Since the source code is hidden behind a black box, traditional static analysis can't see how the numbers are made. Previous studies focused on open-source systems, leaving the vast ecosystem of proprietary Android app backends largely unvetted. This paper aims to bridge that gap by analyzing the outputs of these systems to infer the vulnerabilities within.

Methods

The authors built OTP-Lint, a pipeline designed to interact with apps just like a human user would, but at scale. The workflow consists of three main components:

  1. Authentication Locator: This uses a "fuzzing-inspired" approach to find login screens. Instead of just looking for keywords like "login" (which can be ambiguous), it analyzes code dependencies and compares them against a library of authentication-related code snippets harvested from GitHub.
  2. Request Processor: Once a login screen is found, the tool identifies the specific UI elements (like the "Send SMS" button) using keyword matching and UI parsing. It then uses an automated exerciser to input a phone number and trigger OTP requests.
  3. Vulnerability Detector: This is the core engine. It collects a sequence of OTPs and tests them against three fundamental randomness rules:
  4. Rule 1 (No Statics): The OTP shouldn't be the same every time.
  5. Rule 2 (No Patterns): The sequence shouldn't repeat, and the binary representation shouldn't show predictable shifts or parity patterns.
  6. Rule 3 (No Predictable Seeds): The generator shouldn't be initialized with a constant (like srand(1)) or a simple timestamp.
Fig. 1. Workflow of OTP-Lint.

To identify specific flaws, the researchers simulated common insecure PRNG implementations (like Mersenne Twister or LCG with static seeds) and checked if the app's OTPs matched these simulated sequences.

Datasets

The study analyzed a total of 6,431 popular Android apps:

  • 1,000 apps from the Google Play Store.
  • 5,431 apps from Tencent MyApp (a major Chinese app market).

The researchers also crawled 9,134 GitHub repositories to build their "candidate list" of common authentication code patterns, ensuring the tool could recognize diverse implementation styles.

Key Insights and Ideas

  • The "Black Box" Inference: The most clever aspect of this work is using the output of a PRNG to identify the algorithm and parameters used on a hidden server. For example, by observing a repeat cycle of exactly 624 numbers, they could confidently identify the use of the Mersenne Twister (MT19937) algorithm.
  • Developer Shortcuts: The study highlights a disconnect between cryptographic theory and developer practice. Many developers use default language functions (like rand() in PHP or Python’s random) which are explicitly documented as insecure for cryptography, or they fail to provide enough entropy when seeding these functions.
  • Security Theater: The authors describe some implementations as "security theater"—they provide the feeling of security (a ticking timer, a 6-digit code) without the actual protection of randomness.

Key Results

Out of the 2,022 apps that successfully implemented SMS OTP login, 399 (19.7%) violated at least one randomness rule.

Breakdown of the 399 apps that violated the three defined randomness rules.
  • Static Values: 41 apps were found using static OTPs. In some cases, the "one-time" password never changed, essentially acting as a second, easily guessable static password.
  • Predictable Patterns: 354 apps failed Rule 2. The most common failure was Rule 2-1 (repeated sequences), often linked to the Mersenne Twister algorithm.
  • Single-Factor Vulnerability: Perhaps most concerningly, 194 of the vulnerable apps used SMS OTP as their only authentication method. For these apps, an attacker who predicts the OTP gains full access to the account without needing a password.
  • Category Trends: Apps in the "Video Players & Editors" and "Entertainment" categories were significantly more likely to have weak OTP implementations compared to Finance or Social apps.

Limitations and Future Work

The authors acknowledge several hurdles:

  • Code Packing and Obfuscation: OTP-Lint failed to analyze 2,416 apps because they used advanced protection techniques that prevented decompilation or automated UI interaction.
  • Scope of Patterns: The tool currently looks for known insecure patterns. It might miss highly complex or custom-built PRNG vulnerabilities that don't match the researchers' simulated models.
  • Ethical Constraints: To avoid interfering with production servers or triggering anti-fraud systems, the researchers capped their requests at 1,000 per app. Some long-period patterns might require more samples to detect.

Future work could involve integrating more robust statistical tests (like the NIST SP 800-22 suite) to detect even subtler deviations from true randomness.

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