automated and adjustable side-channel protection for sgx ... · background: side-channel aiacks...

26
DR.SGX Automated and Adjustable Side-Channel Protection for SGX using Data Location Randomization Tommaso Frassetto Ferdinand Brasser Ahmad-Reza Sadeghi Srdjan Capkun Kari Kostiainen Alexandra Dmitrienko TU Darmstadt, Germany ETH Zurich, Switzerland University of Würzburg, Germany

Upload: others

Post on 14-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

DR.SGXAutomated and Adjustable Side-Channel Protection for SGX using Data Location

Randomization

Tommaso FrassettoFerdinand Brasser

Ahmad-Reza Sadeghi

Srdjan CapkunKari Kostiainen Alexandra Dmitrienko

TU Darmstadt,Germany

ETH Zurich,Switzerland

University of Würzburg,Germany

Page 2: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

The Big Picture

SGX

RAM

Side channel leakage

DR.SGX

Page 3: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Background: Intel SoEware Guard Extensions

Application Sensitive code ApplicaPon

OS

RAM

Page 4: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

ApplicaPon Enclave ApplicaPon

OS

RAM EPC

EPC: Enclave Page Cache

Background: Intel Software Guard Extensions

Page 5: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

ApplicaPon Application

OS

RAM

EPC: Enclave Page Cache

Enclave

EPC

Background: Intel Software Guard Extensions

Page 6: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

ApplicaPon Application

OS

RAM

EPC: Enclave Page Cache

Enclave

EPC

Background: Intel Software Guard Extensions

Page 7: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

ApplicaPon Application

OS

RAM

EPC: Enclave Page Cache

Enclave

EPC

Background: Intel Software Guard Extensions

Page 8: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

ApplicaPon Application

OS

RAM

CachesPaging

Enclave

EPC

Background: Intel SoEware Guard Extensions

Page 9: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Application ApplicaPon

OS

RAM

CachesPaging

Enclave

EPC

Background: Intel Software Guard Extensions

Page 10: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Background: Side-channel AIacks

Paging

• Trivially achievable by a malicious OS• Just mark all pages as

unavailable, then monitor page faults

Caching

• Requires more involved attacks, e.g., Prime+Probe:

1. Access cache lines2. Let victim execute3. Check if own lines still in

cache• Demonstrated against SGX

[Brasser et al., So\ware Grand Exposure: SGX Cache A]acks Are PracPcal. WOOT ’17][Xu et al., Controlled-Channel Attacks: Deterministic Side Channels for Untrusted Operating Systems. IEEE S&P ’15.]

Page 11: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Side-channel Mitigations: Other Approaches

Side-channel resilient code

Oblivious Execution

AnnotaPon-based protecPons

Requires:• High expertise• Vast effort

Requires:• High expertise• Significant

effort

Extremely high overhead

(up to 220×)

[Ahmad et al., Obfuscuro, NDSS 2019]

Page 12: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

DR.SGX: Goals

• SemanPc-agnosPc side-channel protecPon for data accesses• No program-specific knowledge required•More pracPcal overhead than Oblivious ExecuPon

Page 13: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Adversary Model

The a4acker can:

• Launch so\ware-based side-channel a]acks on enclave data• Caches + Paging• 64 byte granularity

• Fully control OS and host applicaPon

The attacker cannot:• Use physical side channels• Power

• Target code accesses• DR.SGX only protect data

accesses• Use transient execution

bugs• E.g., no Foreshadow

Page 14: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

DR.SGX: Data Location Randomization

static const unsigned char FSb[256] = {0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,

... };

int mbedtls_aes_setkey_enc( ... ) {... ((uint32_t) FSb[(RK[3] >> 8) & 0xFF]) ...

}

Page 15: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

DR.SGX: Data Location Randomization

FSb0..63

FSb64..127

FSb128..191

FSb192..255

Initial memory layout (L0)

FSb64..127

FSb0..63

FSb192..255

FSb128..191

L1

π1

FSb192..255

FSb64..127

FSb128..191

FSb0..63

L2

π2

static const unsigned char FSb[256] = {0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,

... };

int mbedtls_aes_setkey_enc( ... ) {... ((uint32_t) FSb[(RK[3] >> 8) & 0xFF]) ...}

Run-time address resolver

Page 16: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

DR.SGX: Components

Compile time

Data access instrumentation

Run Pme

Efficient data permutation

Run-time address resolver

Oblivious (re-)randomizaPon

Page 17: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

DR.SGX: Compiler-based Instrumentation

var[256] = 42;

*(var + 256) = 42;

*(addr_resolve(var + 256)) = 42;

Page 18: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Efficient Data PermutaPon

• How to efficiently store a permutation?• A permutation table requires space• Very little storage space in the CPU• Storing the table in memory requires oblivious access to it…

• Solution: Small-domain Format-preserving Encryption

Page 19: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Efficient Data Permutation

ApplicaPon cache line idenPfier Cache line offset (6 bits)

Randomized cache line idenPfier Cache line offset (6 bits)

FFX(Format-Preserving Encryption)

Page 20: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Improving Performance: PermutaPon Buffer

• FFX requires 10 AES encryptions• 100 AES rounds per address resolution

• Our solution: the Permutation Buffer• Buffer of 256 recently used addresses• Substantially improves performance

•We access every cache line in the buffer at every access• No leakage due to the permutation buffer

Page 21: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

(Re-)Randomization under attacker’s observation

• DR.SGX uses non-temporal instrucPons that evade caches• A]acker sPll gets page-granularity data

• IniPal randomizaPon: we access all pages for every write• A]acker gets no informaPon during iniPal permutaPon

Page 22: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Performance: NbenchO

verh

ead

10×

15×

20×

25×

30×

NumSort

StringSort

BitopsEmFloat

FourierAssign

IDEAHuffman

NNET LU

Geo Mean

Page 23: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Performance: Re-randomizaPon WindowO

verh

ead

10×

15×

20×

25×

30×

NumSort

StringSort

BitopsEmFloat

FourierAssign

IDEAHuffman

NNET LU

Geo Mean

No re-random. w = 10M w = 3M w = 1M w = 300K

Page 24: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Security

• Security depends on the enclave’s access patterns:• No predictable accesses: Initial randomization is sufficient• Predictable accesses: Information may leak during 1-2

randomization cycles after the predictable access•More details in the paper

Page 25: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Conclusion

• DR.SGX introduces semantic-agnostic side-channel protection for SGX• Reasonable performance overhead due to optimized implementation• Configurable side-channel protection

Page 26: Automated and Adjustable Side-Channel Protection for SGX ... · Background: Side-channel AIacks Paging •Trivially achievable by a malicious OS •Just mark all pages as unavailable,

Q?Ferdinand Brasser, Srdjan Capkun, Alexandra Dmitrienko, Tommaso Frassetto, Kari Kostiainen and Ahmad-Reza Sadeghi.

DR.SGX: Automated and Adjustable Side-Channel Protection for SGX using Data Location Randomization