Attack of the week: DUHK
blog.cryptographyengineering.com
blog.cryptographyengineering.com
The X9.31 random number generator [in FortiOS] is implemented within a kernel module that exports a Linux character device. At boot time, the init process loads the module and replaces /dev/urandom with a node corresponding to the X9.31 character device.
We reverse-engineered the kernel module providing the X9.31 implementation [...] and found the hard-coded AES key used for the RNG. The hard-coded key was f3b1666d13607242ed061cabb8d46202. The key used in both the firmware dump and virtual appliance was the same. Although the documentation stated that the key was “generated external to the module”, the key is the same one used for the NIST test vectors [14] and appears to have been hard-coded into the source code.
// TODO generate key instead of hard-coding itMany appliance vendors have terrible self-made TLS stacks. There's a bunch of vendors whose names come up again and again when talking about stupid TLS bugs and vulnerabilities. Cisco, F5, Cavium, A10, Citrix, Fortinet are names that come to mind. And it's not only a problem for security, it's also a huge compatibility problem, as they tend to violate the protocol in ways that makes deploying new features and versions hard.
I've once given a talk where I tried to highlight this: https://www.youtube.com/watch?v=w3Sn5kMPzVA (slides unfortunately not in the video, but here https://int21.de/slides/auscert-tls/ )
And many sites use CDNs or cloud services for connection termination. Cloudflare and Amazon are surely on top of these things.
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-8... http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-7...
Given Dual-EC, one has to wonder whether this bad RNG design was by accident or on purpose, and how many other bad RNGs are out there. One also has to wonder whether we should all start hashing the outputs of every RNG before using them...
You also don't build backdoors by building bad products.
If the generator output was hashed after being encrypted, it would not be possible to perform the decryption step of the attack. You could still perform a brute force attack by encrypting and then hashing, but now you're brute forcing both the state and the timestamp together (i.e. you have to guess V XOR T, then encrypt, hash, and validate your guess), which will likely be much more difficult if the generator has been running for some amount of time. Without being able to invert the encryption step, an attacker has to basically guess ALL previous timestamps rather than just the one associated with the current output. If the attacker is able to see the first few outputs, the attack would still work, but it would be much harder to just start at an arbitrary point in time.
Edit: I still don't think the addition of a hashing step would make this a great generator design, but it would make it more resilient against this kind of attack.
One abstraction level up, hashing the output of a RNG is a bad countermeasure against a possibly-bad RNG. Good countermeasures including mixing the outputs of multiple RNGs and using protocols that don't require entropy.
Why? I would think it's a fair suggestion for defense in depth, especially if you need to expose the result as a nonce, and you don't want to leak anything else unwittingly. It's also a good idea if you're not sure whether the entropy is evenly distributed, which is where something like HKDF would also want to hash the entropy source.
"using protocols that don't require entropy"
That rules out most secure protocol handshakes.