Reduced purmations on encryption
The secure random generator used a 64-character alphabet to build a 16-byte initialisation vector, so the IV only had 96 bits of entropy instead of 128. This raised the chance of IV reuse, which could weaken confidentiality of encrypted data.
Originally disclosed on HackerOne
- Triaged in 23 days
- Fixed in 25 days
- Paid in 25 days
- Disclosed after 6 months
OC\Security\SecureRandom::generate
Reduced Permutations
OC\Security\SecureRandom::generate will by default use a-Z0-9+/ (64 bytes) character set. The numbers are not predictable, due to the use of random_int.
Most notably the OC\Security\Crypto::encrypt method uses an IV with a length of 16 bytes. It is chosen randomly via OC\Security\SecureRandom::generate with the default character set. There are 256 possible bytes, but in this case it is actually 64 bytes. The permutations is 64^16 (instead of 256^16), which equates to a 12-byte, or 96-bit IV (instead of the expected 16-byte, or 128-bit IV). Use raw bytes when doing cryptographic operations, via random_bytes.
Do not use OC\Security\Crypto::generate for cryptographic keys.
Cache Timing Attacks
It is potentially vulnerable to cache timing attacks because the secret number is used as an index to look up a byte value in string. Read more about cache-timing attacks here.
Impact
-
Reduced permutations increase the chances of IV re-use (which can destroy confidentially), and bring encryption key strength down (chances are still too low with a 256-bit encryption key).
-
If the complex cache timing attack vector exists, and is abused: it is possible to determine secret values generated with
OC\Security\SecureRandom::generate.
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 random generator produced characters from a 64-symbol alphabet instead of raw bytes, so a 16-character IV carried only 96 bits of entropy.
What the attacker needed
Theoretical timing side channel
The fix
Cryptographic operations should use raw random bytes, for example via random_bytes, rather than the character-based generator.
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.
Encryption often needs a random starting value called an initialisation vector (IV) so that the same message encrypts differently each time. Here the random value was built from only 64 possible characters per position rather than all 256 byte values, so there were far fewer possible IVs than expected. Fewer possibilities means the same IV is more likely to appear twice, which can leak information about the encrypted data.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.