Git Product home page Git Product logo

spectre-attack-sgx's Introduction

spectre-attack-sgx

Sample code demonstrating a Spectre-like attack against an Intel SGX enclave.

Overview

Given our ongoing research on Intel SGX here in the LSDS group at Imperial College London, a question that occurred to us immediately on first hearing of the recent Meltdown and Spectre attacks is what are the security implications of speculative execution side channels for Intel SGX enclaves?

This repository contains a proof-of-concept attack (SGXSpectre) showing it is indeed possible to use a speculative execution side-channel to leak data from an Intel SGX enclave.

Attack Outline

The attack is similar conceptually to the conditional branch misprediction Spectre attack of Kocher et al. The main difference is that we move the secret data (secret) and the victim function (victim_function) and overflow array (array1) inside the enclave. The attacker executes victim_function using an ecall, passing it the index x used to index into array1.

Code Layout

  • SGXSpectre/main/main.c: Contains the untrusted code to create the enclave and mount the SGXSpectre attack.
  • SGXSpectre/enclave/enclave_attack.c: Contains the enclave secret data and victim function.

Caveats

  • The attack requires that the array1_size variable (used to verify that x is within the bounds of array1) must not be cached. For simplicity our proof-of-concept currently stores array1_size outside the enclave, allowing the attacker to flush it with a clflush instruction before each invocation of the victim function. In reality this would be unsafe, since the bounds check should not rely on a value stored in untrusted memory. However the attack could be adapted to keep array1_size inside the enclave by using an alternative mechanism to flush it before each invocation (e.g. load other data whose address coincides in the cache).

  • For simplicity we keep the array2 array whose entries are probed by the attacker outside the enclave. As mentioned in the Spectre paper, a prime+probe attack could be used to infer the accesses to array2 if it is not accessible to the attacker (e.g. if it is moved inside the enclave).

How to run the code

  1. Install Intel(R) SGX SDK for Linux* OS
  2. Build the SGXSpectre project with the prepared Makefile:
    • Hardware Mode: $ make
    • Simulation Mode: $ make SGX_MODE=SIM
  3. Execute the binary directly: $ ./sgxspectre
  4. Remember to "make clean" before switching build mode

spectre-attack-sgx's People

Contributors

danokeeffe avatar

Watchers

James Cloos avatar Wayne Munro avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.