Pseudorandom Black Swans: Cache Attacks on CTR_DRBG

Shaanan Cohney, Andrew Kwong, Shahar Paz, Daniel Genkin, Nadia Heninger, Eyal Ronen, Yuval Yarom

TL;DR

This paper reveals that the NIST-standardized pseudorandom generator, CTR_DRBG, is highly vulnerable to cache-based side-channel attacks. By exploiting legacy "T-table" AES implementations found in popular libraries like OpenSSL and NetBSD, the authors demonstrate how an attacker can recover a generator's internal state and subsequently steal long-term TLS authentication keys or decrypt private communications.

What Problem Does This Paper Address?

Cryptographic protocols rely on high-quality randomness for everything from session keys to digital signatures. If a Pseudorandom Generator (PRG) is predictable, the entire security stack collapses. While the security community has spent decades hardening encryption algorithms against side-channel attacks (which leak information through physical characteristics like power consumption or memory access patterns), PRGs have largely been ignored.

The authors tackle a critical gap: Are the PRGs we use in production actually resistant to microarchitectural side-channel attacks? They specifically look at CTR_DRBG, the most popular PRG design recommended by NIST, and find that "hard-learned lessons" from encryption side-channels were never applied to the PRG implementations that feed them.

Methods

The authors employ two primary attack vectors targeting the underlying block cipher (AES) used by CTR_DRBG:

  1. Asynchronous Cache Attack (Flush+Reload): Targeting systems like NetBSD and OpenSSL’s FIPS module, the authors use the Flush+Reload technique to monitor memory access patterns to AES "T-tables" (pre-computed lookup tables). Because these lookups are key-dependent, observing which cache lines are accessed allows an attacker to reconstruct the AES key and the internal counter of the PRG.
  2. Blind Differential Cryptanalysis (SGX): In a more restricted environment like Intel SGX, the attacker might not be able to see the PRG's output. The authors developed a novel differential attack that leverages the fact that CTR_DRBG encrypts an incrementing counter. By observing cache access patterns across just three consecutive AES encryptions, they can recover the state without ever seeing a single bit of the generated random numbers.
  3. Protocol-Level Exploitation: They show how to "wind the generator forward" to predict future values, such as the nonces used in ECDSA signatures, which allows for the recovery of the victim's long-term private key.

Datasets

The paper does not use traditional machine learning datasets. Instead, it evaluates:

  • Real-world Implementations: OpenSSL 1.0.2 FIPS module, NetBSD kernel, FortiOS, and mbedTLS-SGX.
  • NIST CMVP Database: The authors scraped the NIST Cryptographic Module Validation Program database to assess the prevalence of CTR_DRBG in the industry.

Key Insights and Ideas

  • The "Certified" Trap: One of the most surprising findings is that OpenSSL’s FIPS-certified module is more vulnerable than the standard version. To maintain certification, it uses a legacy, hand-coded T-table AES implementation for its PRG, even when the CPU supports side-channel-resistant hardware AES (AES-NI).
  • Design vs. Implementation: While CTR_DRBG is theoretically sound, the NIST standard (SP 800-90A) doesn't account for side-channel leakage. The authors show that if the state is compromised via a side-channel, the design lacks the "forward security" needed to protect past or future outputs effectively.
  • TLS as an Oracle: The authors found they could force a TLS client to generate large amounts of PRG output by using a massive (16KB) RSA certificate. This provides the attacker with enough "leaky" AES operations to reliably recover the PRG state.

Key Results

  • State Recovery Speed: On a standard desktop, the authors recovered the PRG state in an average of 19 seconds.
  • Efficiency in SGX: The "blind" attack on SGX-based HTTPS clients succeeded using only three AES encryptions, allowing for passive decryption of TLS traffic.
  • Market Prevalence: Scraping the NIST database revealed that 67.8% of all validated cryptographic modules use CTR_DRBG, making this a systemic vulnerability.
  • Key Theft: They successfully demonstrated an end-to-end attack that recovers long-term ECDSA private keys from a TLS client connecting to a malicious server.

Limitations and Future Work

  • Hardware Mitigation: The attack is mitigated if the implementation uses hardware-accelerated AES (like Intel's AES-NI), which does not use lookup tables. However, the paper proves that many "secure" and "certified" systems still fall back to software tables.
  • Noise Sensitivity: The SGX attack is sensitive to system noise; in their tests, it succeeded in about 36% of trials under noisy conditions, though this is still a high enough success rate for a practical exploit.
  • Future Directions: The authors suggest that future PRG standards must explicitly require side-channel resistance and that implementers should move away from T-table-based designs entirely, even for "randomness" generation.

Summary updated

BibTeX
@inproceedings{cohney2020pseudorandom,
  author = {Shaanan Cohney and Andrew Kwong and Shahar Paz and Daniel Genkin and Nadia Heninger and Eyal Ronen and Yuval Yarom},
  title = {{Pseudorandom Black Swans: Cache Attacks on CTR\_DRBG}},
  booktitle = {Sp},
  year = {2020},
  doi = {10.1109/sp40000.2020.00046},
}
Figure