Skip to content
Crypto Disclosed report Intermediate

Predictable Random Number Generator

The mobile application uses a predictable random number generator in several places, including where OAuth user identifiers and notification thread names are created. An attacker who can observe or guess these values could potentially predict tokens or identifiers used for validation, though the text does not demonstrate a concrete exploit.

d4rkrai Follow

Originally disclosed on HackerOne

  • Disclosed after 4 months

Description: The mobile application uses a predictable Random Number Generator (RNG). Under certain conditions this weakness may jeopardize mobile application data encryption or other protection based on randomization. For example, if encryption tokens are generated inside of the application and an attacker can provide application with a predictable token to validate and then execute a sensitive activity within the application or its backend.

Example of insecure code: Random random = new Random(); byte bytes[] = new byte[20]; random.nextBytes(bytes);

Example of secure code: SecureRandom random = new SecureRandom(); byte bytes[] = new byte[20]; random.nextBytes(bytes);

Details: There is 'new Random()' found in file 'org/jsoup/helper/DataUtil.java': line 211: StringBuilder stringBuilder = new StringBuilder(32);

line 212: Random random = new Random();

line 213: for (int i = 0; i < 32; i++) { There is 'new Random()' found in file 'com/owncloud/android/ui/notifications/NotificationUtils.java': line 31: stringBuilder.append("NotificationDelayerThread_");

line 32: stringBuilder.append(new Random(System.currentTimeMillis()).nextInt());

line 33: HandlerThread handlerThread = new HandlerThread(stringBuilder.toString(), 10); There is 'new Random()' found in file 'com/owncloud/android/jobs/MediaFoldersDetectionJob.java': line 48: public static final String TAG = "MediaFoldersDetectionJob";

line 49: private Random randomId = new Random();

line 50: There is 'new Random()' found in file 'com/owncloud/android/authentication/AuthenticatorActivity.java': line 1672: stringBuilder2.append("OAuth_user");

line 1673: stringBuilder2.append(new Random(System.currentTimeMillis()).nextLong());

line 1674: str = stringBuilder2.toString();

Reference: https://developer.android.com/reference/java/util/Random.html https://developer.android.com/reference/java/security/SecureRandom.html

Impact

When a non-cryptographic PRNG is used in a cryptographic context, it can expose the cryptography to certain types of attacks.

Often a pseudo-random number generator (PRNG) is not designed for cryptography. Sometimes a mediocre source of randomness is sufficient or preferable for algorithms that use random numbers. Weak generators generally take less processing power and/or do not use the precious, finite, entropy sources on a system. While such PRNGs might have very useful features, these same features could be used to break the cryptography.

The original report as published on HackerOne, by d4rkrai. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code uses java.util.Random, which is not cryptographically secure, instead of SecureRandom for values that may need to be unpredictable.

Impact

The weakness could expose cryptography to certain types of attacks if the predictable values are used in a security context, but the text does not show a working exploit.

What the attacker needed

Ability to supply or influence a predictable token

The fix

The code should use SecureRandom instead of Random for any values that need to be unpredictable.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A random number generator is a tool that produces numbers that look unpredictable. Some generators are not truly random and can be guessed if you know how they work. This report says the app uses such a weak generator in a few places, which might let someone predict values that are supposed to be secret.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.