2022-01-22 15:04:17 +01:00
OCTOPUS
---
2022-01-22 15:09:33 +01:00
Samuel AUBERTIN - EURECOM - 2022
2022-01-22 15:04:17 +01:00
![SPECTRE Octopus Logo ](logo.png "SPECTRE Octopus Logo" )
2022-04-13 17:37:29 +02:00
**OCTOPUS** is a [Spectre ](https://spectreattack.com/spectre.pdf ) V1 (_Bounds Check Bypass_) + V2 (_Branch Target Injection_) vulnerabilty and mitigation tester.
2022-01-22 15:04:17 +01:00
2022-02-02 15:21:25 +01:00
It measures and uploads the success rate of the Spectre attacks on your CPU using different compilers:
2022-01-23 19:37:24 +01:00
2022-02-02 15:20:17 +01:00
- [GCC ](https://gcc.gnu.org/ )
- [Clang ](https://clang.llvm.org/ )
2022-01-23 19:37:24 +01:00
2022-04-13 17:37:29 +02:00
... compilation/linking flags such as:
2022-01-22 15:09:33 +01:00
2022-04-12 11:43:25 +02:00
- Optimisation levels (```-O```).
- Static/dynamic linking.
2022-04-13 17:37:29 +02:00
and mitigations:
- [Masking ](https://github.com/torvalds/linux/blob/cb6416592bc2a8b731dabcec0d63cda270764fc6/arch/x86/include/asm/barrier.h#L27 ) and [lfence ](https://www.intel.com/content/www/us/en/developer/articles/troubleshooting/using-intel-compilers-to-mitigate-speculative-execution-side-channel-issues.html ) against Spectre V1.
- [RETPOLINE ](https://support.google.com/faqs/answer/7625886 ) against Spectre V2.
2022-01-28 16:42:43 +01:00
2022-04-12 11:43:25 +02:00
## Supported platforms
- x86_64 with SSE
## Supported distributions
- _Alpine 3.15_
- _RHEL 8_
- _Fedora 35_
2022-04-13 17:37:29 +02:00
- _Ubuntu 20.04_
2022-04-12 11:43:25 +02:00
- _OpenBSD 7.0_
2022-04-12 11:53:17 +02:00
## Docker support
A _Dockerfile_ is provided and used by ```make docker``` but be wary: the compiled binaries inside the docker image are heavily dependent on the CPU platform/version and _not_ portable.
You **have** to build the image on the actual CPU you want to test, otherwise you may stumble upon ```core dumped: illegal instruction``` errors.
2022-04-07 12:05:25 +02:00
2022-04-13 17:37:29 +02:00
## WSL support
The code runs on _WSL2_ using the default distribution (Ubuntu).
To install WSL, from a priviledged PowerShell prompt:
```PS C:\Users\user> wsl --install```.
Once the installation is complete, you can install the dependencies and run the experiment from the WSL console:
```
$ sudo apt update & & sudo apt upgrade -y & & sudo apt install git make gcc clang lld
$ git clone https://gitlab.eurecom.fr/aubertin/octopus.github
$ cd octopus
$ make all
```
2022-01-28 16:42:43 +01:00
## Results
Results are stored as JSON objects in an unique file for each run, following this pattern: ```result-$(UUID).json```
2022-01-22 15:09:33 +01:00
## Dependencies
2022-01-22 15:04:17 +01:00
2022-04-12 11:53:17 +02:00
- Compilers: ```clang``` and ```gcc```
2022-02-02 15:20:17 +01:00
- Linker: ```lld```
- For upload: ```openssh``` and ```uuid```
2022-04-12 11:43:25 +02:00
- The C library static symbols, on Fedora: ```glibc-static```
## Running the experiment
2022-01-22 15:04:17 +01:00
2022-04-12 11:43:25 +02:00
```make``` will build, execute and upload the experiment results.
2022-01-22 15:04:17 +01:00
2022-04-12 11:43:25 +02:00
### PoC only
2022-01-22 15:04:17 +01:00
2022-04-12 11:53:17 +02:00
```make poc``` will compile and execute v1 and v2 executables once using clang and no optimisations.
2022-04-12 11:43:25 +02:00
### Within docker
```make docker``` will build, execute and upload the experiment results within Docker.
```make dockerbuild``` will only build the experiment images named _octopus_ .
```make dockerpoc``` will run the PoC within Docker.
2022-01-27 15:36:02 +01:00
### Build only
2022-04-12 11:43:25 +02:00
```make build``` will only build the experiment binaries.
2022-02-02 15:20:17 +01:00
2022-04-12 11:53:17 +02:00
### Cleanup
```make clean``` will remove experiment binaries and result files.
2022-02-02 15:20:17 +01:00
2022-04-12 11:53:17 +02:00
```make dockerclean``` will remove the _octopus_ image.
2022-01-27 15:36:02 +01:00
2022-04-12 12:59:16 +02:00
## Common errors
- ```core dumped: illegal instruction```: Either your CPU does not support _SSE_ or you compiled the executables on a different CPU than the one you are testing.
## Results aggregation and upload
2022-01-22 15:04:17 +01:00
2022-01-28 16:42:43 +01:00
Results are automatically uploaded to a server with a dedicated account using ```sftp```.
2022-01-23 19:37:24 +01:00
Here is an exhaustive list of the data sent:
- CPU model name and microcode version.
- Kernel version and compilation date.
- GCC and clang versions.
- The list of mitigations enabled at runtime.
- The cache timings of the processor computed by the ```calibrate_threshold()``` function.
- Each spectre execution success rate.
**NONE** of this data will be used for anyhting else except this experiment.
2022-01-22 15:09:33 +01:00
2022-01-28 16:42:43 +01:00
## References
2022-04-12 11:43:25 +02:00
- [Spectre Attacks: Exploiting Speculative Execution ](https://spectreattack.com/spectre.pdf )
Both implementations were inspired by:
2022-01-22 15:09:33 +01:00
- [ErikAugust gist ](https://gist.github.com/ErikAugust/724d4a969fb2c6ae1bbd7b2a9e3d4bb6 )
- [genua GmbH PoC ](https://github.com/genua/meltdown )