A group of researchers from Austria’s Graz University of Technology have demonstrated that malware running on Intel SGX (Software Guard Extensions) can attack the host and can be used to extract RSA private keys.
SGX, an isolation mechanism introduced by Intel in their micro-processors to protect code and data from modification or disclosure, uses special execution environments called enclaves and which work in encrypted memory area, thus protecting an application’s secrets from attackers. According to Intel, cryptographic keys should be stored inside enclaves, because they can thwart side-channel attacks.
While some argued before that the hardware-supported isolation could result in super malware inside enclaves, others refuted the fears, saying that enclaves always run with user space privileges and cannot perform any I/O operations. In a newly published paper (PDF), Graz University of Technology researchers prove that enclave malware can indeed attack its hosting system.
“We demonstrate a cache attack from within a malicious enclave that is extracting secret keys from co-located enclaves. Our proof-of-concept malware is able to recover RSA keys by monitoring cache access patterns of an RSA signature process in a semi-synchronous attack. The malware code is completely invisible to the operating system and cannot be analyzed due to the isolation provided by SGX,” the paper reads.
This attack, the report says, is the first malware running on real SGX hardware that abuses the SGX protection features to conceal itself. The researchers were able to demonstrate the attack both in a native environment and across multiple Docker containers and explain that they performed a Prime+Probe cache side-channel attack on a co-located SGX enclave running an up-to-date RSA implementation that was using a constant-time multiplication primitive.
The attack was successful despite the lack of timers, large pages, physical addresses, and shared memory in SGX enclaves. Moreover, the researchers were able to extract 96% of an RSA private key from a single trace in a semi-synchronous attack, and even managed to “extract the full RSA private key in an automated attack from 11 traces within 5 minutes.”
The paper reveals that both the target program (which uses SGX to protect an RSA signing application) and the malicious application are unprivileged and run on the same host machine. The malware keeps the attack code inside an SGX enclave to avoid detection, with the loader being used only to start the enclave. The malware can remain undetected even if state-of-the-art malware detection software is used, the researchers say.
Countermeasures to prevent such attacks are also proposed: exponent blinding and bit slicing at source level; enclave coloring, removing access to high-resolution timers, allowing cloud provider to access and scan enclaves for malicious activities, heap randomization, and Intel CAT (cache allocation technology) at OS level; and combining Intel CAT with SGX and using secure RAM at hardware level.
“Besides not fully preventing malicious enclaves, SGX provides protection features to conceal attack code. Even the most advanced detection mechanisms using performance counters cannot detect our malware. Intel intentionally does not include SGX activity in the performance counters for security reasons. However, this unavoidably provides attackers with the ability to hide attacks as it eliminates the only known technique to detect cache side-channel attacks,” the researchers say.