Skip to content
Crypto Disclosed report Intermediate CVE-2023-28835

Insecure randomness for default password in file sharing when password policy app is disabled

When the password policy app is disabled, the file sharing feature generates share-link passwords using a non-cryptographic random number generator. An attacker might be able to predict or guess the generated password and access the shared files without knowing it.

gorei Follow

Originally disclosed on HackerOne

  • Triaged in 3 days
  • Fixed in 5 months
  • Disclosed after 5 months

Summary by the program

Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-7w2p-rp9m-9xp9

The report

Summary:

Sharing links can be protected with a password. However, the function used for generating this password is using cryptographically insecure RNG.

server-25.0.0\apps\files_sharing\src\utils\GeneratePassword.js (lines 36-55):

PHP
export default async function() {
	// password policy is enabled, let's request a pass
	if (config.passwordPolicy.api && config.passwordPolicy.api.generate) {
		try {
			const request = await axios.get(config.passwordPolicy.api.generate)
			if (request.data.ocs.data.password) {
				return request.data.ocs.data.password
			}
		} catch (error) {
			console.info('Error generating password from password_policy', error)
		}
	}

	// generate password of 10 length based on passwordSet
	return Array(10).fill(0)
		.reduce((prev, curr) => {
			prev += passwordSet.charAt(Math.floor(Math.random() * passwordSet.length))
			return prev
		}, '')
}

The first part of the function handles the password generation in a safe way when a password policy is present. However, there is another variant generating the password using Math.random function, which is not appropriate for use in a security-sensitive context.

Citation from MDN Web Docs: "Note: Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method."

Supporting Material/References:

Impact

An attacker might be able to access the shared files even without knowledge of the password.

The original report as published on HackerOne, by gorei. 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

The fallback password generator uses Math.random, which is not a cryptographically secure random number generator, instead of a secure API such as the Web Crypto API.

Impact

An attacker might be able to access the shared files even without knowledge of the password; this only applies when the password policy app is disabled, since otherwise a safe generator is used.

What the attacker needed

Password policy app is disabled; attacker can predict the generated password

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.

When you protect a shared file with a password, the software has to invent that password for you. This report says that in one situation it invents it with a random function that is not designed to be unpredictable, so someone could work out the password and open the shared files. Random numbers used for security need a special, unpredictable source.

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.