A new side-channel vulnerability has been found called PortSmash that uses a timing attack that to steal info from other processes running in the same CPU core with SMT/hyper-threading enabled.
Utilizing this attack, researchers were able to steal the private decryption key from an OpenSSL thread running in the same core as their exploit.
For those that dont know, SMT/Hyper-threading is when one physical CPU core is split into two virtual logical cores that can be used two run two separate process threads at once.
This method can increase performance as the two threads will utilize idle CPU resources more efficiently to execute instructions faster.
A side channel timing attack is when an attacker analyzes how fast a thread executes particular instructions and utilizes that info to work backwards to discover what data was used as input.
The PortSmash vulnerability was discovered by researchers Billy Bob Brumley, Sohaib ul Hassan, Cesar Pereida Garcia, and Nicola Tuveri from the Tampere University of Technology in Finland as well as Alejandro Cabrera Aldaya from the Universidad Tecnologica de la Habana CUJAE in Cuba.
An advisory was made to the OSS-Sec mailing list and their research has been submitted as a paper titled “Port Contention for Fun and Profit” as a IACR eprint, which is currently awaiting moderation before it’s released.
In an email with the researchers, Nicola Tuveri explained to us that port contention was used to measure how long it took OpenSSL to perform an operation.
Using these measurements, the researchers were able to work backwards to recover a private key.
“Shortly and simplifying, with SMT and two threads per core, a process running on one thread will have its own instructions and data, but will share some hardware resources with a process running on the colocated thread.
Instructions will be decoded independently in simpler micro-operations and pipe-lined in the CPU to the corresponding Execution Units. (Execution Units are the actual silicon areas that are specialized to handle specific operations: i.e, there are a few EU dedicated to integer additions/subtraction, separate ones for integer multiplication, other for floating point arithmetic, etc.)
Every core has a complete set of EUs to support the whole instruction set, and threads on the same core share access to the EUs.
EUs are grouped together in bundles each accessible through a port: microops from the two threads are issued to the available ports, and another micro-component, the core scheduler, optimizes for fairness and performance when the same microop can be issued to different equivalent EUs behind different ports.
These ports are the object of the discussed port contention. Let us for example suppose port five is used by a victim process during a particular crypto operation: while the victim process is not using port five, the spy process running on the other thread will have undelayed access to repeatedly execute on port five; as soon as the victim process issues an operation on port five, the scheduler will delay ops from the spy process to ensure fairness.
The spy process can therefore measure the delay in the execution of its operations for port five, and determine when the victim process is using the same port.
This is the signal that can then be processed to ultimately recover a private key.” – stated Nicola Tuveri.
While the researchers have only tested this vulnerability against Intel Skylake and Kaby Lake processors, they also expect it to work on AMD Ryzen processors.
“We verified it on Intel Skylake and Kaby Lake, but just because we did not have access to different machines with SMT,” Nicola Tuveri told CBNN. “We expect it to work also on AMD Ryzen, but left this to future work.”
The researchers shared a proof-of-concept exploit that only targets OpenSSL. The team chose to target OpenSSL because they are familiar with the code base and because it is so widely used, but that the “PortSmash technique is not tied to a particular software.”
Therefore, it is only a matter of time until diligent researchers and attackers port the PoC to steal info from other apps.
Protecting yourself from the PortSmash vulnerability
The only way to mitigate this attack is to disable SMT/Hyper-threading on a computer, which OpenBSD has already done by default since this summer when another timing attack was released called TLBleed.
“We recommend disabling SMT/Hyper-threading as a countermeasure. OpenBSD, for instance, already disables it by default since this summer.”