Summary
To gauge the impact of flawed pseudorandom number generators in network devices, Bitsight scanned the public Internet for RSA public keys and was able to factor the public modulus and recover the private keys for 41,225 network devices. Bitsight has also found that the prevalence of such vulnerable devices on the Internet has been declining in recent years; however, many still pose a risk to organizations that lack security controls to prevent the inadvertent exposure of unmanaged network assets to the public Internet.
Background
A mathematical principle that underpins the RSA public-key cryptosystem is that no known efficient method exists for factoring large integers. It is trivial to multiply two large prime numbers together, but factoring the product into its constituent primes remains computationally infeasible when the product is large enough. Embedded into a public key infrastructure (PKI) scheme, this asymmetry is the basis from which the majority of web clients authenticate Internet services across the globe.
To enable a variety of secure communications protocols such as HTTPS and SSH, a server requires a public and private key pair which can be used to authenticate the server to clients. The first step when generating such a key with RSA, is to randomly choose two prime numbers p and q. These primes must be kept secret for the security of the private key, but their product p * q = n, is shared as the modulus of the public key. The infeasibility of factoring the public modulus (n) back into the random primes selected by the server (p,q) is foundational to the security of RSA.
While integer factorization is computationally hard, efficient methods do exist for calculating the Greatest Common Divisor (GCD) for two large integers. When generating an RSA key, if two devices select the same value for p or q, it is trivial to recover the other prime values by calculating the GCD of the two public moduli. Given the very large space from which random prime values of p and q are selected, the odds of two separate key generations choosing the same prime values of p or q is extremely small; but as prior research has found; in practice, this can occur when flaws exists in the processes by which devices derive “random” prime numbers. These flaws create a proliferation of RSA public keys from which their associated private keys can be recovered, nullifying any security benefit they provide.
To assess the current and historical impact of this class of vulnerability, Bitsight scanned the public Internet for RSA public keys and computed the GCD across all collected keys based on a distributed batch implementation described in Hastings et al.
Declining Impact
Over a three month period, RSA keys were extracted from TLS certificates and SSH banners. In total, roughly 86 million unique RSA moduli were extracted from 157 million endpoints. Only 13,652 public key moduli were found to share a factor with another modulus in the collection, and these moduli were present across 41,225 different endpoints. This 13.7k vulnerable moduli number is substantially lower than prior studies have reported on factorable RSA keys
To validate this observed decrease, separate random samples of 10 million RSA keys were selected from each year since 2015, and a dramatic decrease in the fraction of RSA keys sharing a prime factor within each sample was observed each subsequent year, dropping from over 20,000 in 2015 to just over 1,200 in 2021.
The majority of devices with factorable keys online today are devices that have been reported as vulnerable in prior studies; suggesting that many vendors have largely addressed flaws in device entropy pools, yet legacy, unmanaged network devices remain a risk to organizations.