Generated passwords are not fully validated by HIBPValidator
The password generator validated a candidate password against the Have I Been Pwned check before shuffling its characters, so the string that was actually issued could differ from the one that passed validation. In rare cases a weak or breached password could therefore be handed to a user.
- Triaged in 3 hours
- Fixed in 16 days
- Paid in 16 days
- Disclosed after 3 months
Summary by the program
Advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-c7mw-9q4r-8qwr
The report
Summary:
If the Nextcloud server generates a secure random password (e.g. for sharing files), the validation is checked before the shuffle function str_shuffle() is called. In very rare cases it could happen, that a password is validated by HIBPValidator before str_shuffle(), but would not validate after shuffle.
Steps To Reproduce:
Since the password generation is usung random chars, the source code must be manipulated to see the problem.
For instance take the password "Password123". Shuffle the Password to "o3rw1sasd2P".
In Generator::generate()
- delete: $password .= $chars = $this->random->generate($length, $chars);
- insert: $password = "o3rw1sasd2P"
Let the validator check the password
- delete: $password = str_shuffle($password);
- insert: $password = "Password123";
See the insecure password "Password123" in UI.
Supporting Material/References:
https://github.com/nextcloud/password_policy/blob/master/lib/Generator.php
Impact
In very rare cases the password generator may generate weak passwords.
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 validation step was placed before the character shuffle, so the checked value and the issued value were not the same string.
Impact
In very rare cases the password generator may generate weak passwords.
What the attacker needed
Server generates passwords automatically; source code modified to reproduce
How it was found
- Modify the generator so the password is set to a fixed weak value before validation.
- Let the validator check that fixed value.
- Replace the shuffle step so the weak value is used as the final password.
- Observe the weak password shown in the interface.
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 a site creates a password for you, it should check that the password is not already known to attackers. Here the check ran on one version of the password, but the characters were then rearranged and the rearranged version was the one actually used. Because the check and the final password were not the same string, a bad password could slip through.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.