Summary
This is a proof-of-concept exploit of the PortSmash microarchitecture attack, tracked by CVE-2018-5407.
Setup
Prerequisites
A CPU featuring SMT (e.g. Hyper-Threading) is the only requirement.
This exploit code should work out of the box on Skylake and Kaby Lake. For other SMT architectures, customizing the strategies and/or waiting times in
is likely needed.
OpenSSL
Download and install OpenSSL 1.1.0h or lower:
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
tar xzf openssl-1.1.0h.tar.gz
cd openssl-1.1.0h/
export OPENSSL_ROOT_DIR=/usr/local/ssl
./config -d shared --prefix=$OPENSSL_ROOT_DIR --openssldir=$OPENSSL_ROOT_DIR -Wl,-rpath=$OPENSSL_ROOT_DIR/lib
make -j8
make test
sudo checkinstall --strip=no --stripso=no --pkgname=openssl-1.1.0h-debug --provides=openssl-1.1.0h-debug --default make install_sw
If you use a different path, you’ll need to make changes to
and
.
Tooling
freq.sh
Turns off frequency scaling and TurboBoost.
sync.sh
Sync trace through pipes. It has two victims, one of which should be active at a time:
- The stock
openssl
running
dgstcommand to produce a P-384 signature.
- A harness
ecc
that calls scalar multiplication directly with a known key. (Useful for profiling.)
The script will generate a P-384 key pair in
if it does not already exist.
The script outputs
which is what
signed, and you should be able to verify the ECDSA signature
afterwards with
openssl dgst -sha512 -verify secp384r1.pem -signature data.sig data.bin
In the
tool case,
and
are meaningless and
is not created.
For the
commands in
, the cores need to be two logical cores of the same physical core; sanity check with
$ grep '^core id' /proc/cpuinfo
core id : 0
core id : 1
core id : 2
core id : 3
core id : 0
core id : 1
core id : 2
core id : 3
So the script is currently configured for logical cores 3 and 7 that both map to physical core 3 (
).
spy
Measurement process that outputs measurements in
. To change the
strategy, check the port defines in
. Only one strategy should be active at build time.
Note that
is actually raw clock cycle counter values, not latencies. Look in
to understand the data format if necessary.
ecc
Victim harness for running OpenSSL scalar multiplication with known inputs. Example:
./ecc M 4 deadbeef0123456789abcdef00000000c0ff33
Will execute 4 consecutive calls to
with the given hex scalar.
parse_raw_simple.py
Quick and dirty hack to view 1D traces. The top plot is the raw trace. Everything below is a different digital filter of the raw trace for viewing purposes. Zoom and pan are your friends here.
You might have to adjust the
variable if the plots are too aggressively clipped.
Python packages:
sudo apt-get install python-numpy python-matplotlib
Usage
Turn off frequency scaling:
./freq.sh
Make sure everything builds:
make clean
make
Take a measurement:
./sync.sh
View the trace:
python parse_raw_simple.py timings.bin
You can play around with one victim at a time in
. Sample output for the
victim is in
.
Credits
- Alejandro Cabrera Aldaya (Universidad Tecnológica de la Habana (CUJAE), Habana, Cuba)
- Billy Bob Brumley (Tampere University of Technology, Tampere, Finland)
- Sohaib ul Hassan (Tampere University of Technology, Tampere, Finland)
- Cesar Pereida García (Tampere University of Technology, Tampere, Finland)
- Nicola Tuveri (Tampere University of Technology, Tampere, Finland)