Leaky Processors: Stealing Your Secrets with Foreshadow Jo Van Bulck - - PowerPoint PPT Presentation

leaky processors stealing your secrets with foreshadow
SMART_READER_LITE
LIVE PREVIEW

Leaky Processors: Stealing Your Secrets with Foreshadow Jo Van Bulck - - PowerPoint PPT Presentation

Leaky Processors: Stealing Your Secrets with Foreshadow Jo Van Bulck imec-DistriNet, KU Leuven jo.vanbulck@cs.kuleuven.be jovanbulck OWASP BeNeLux-Days, November 30, 2018 A primer on software security Secure program: convert all input


slide-1
SLIDE 1

Leaky Processors: Stealing Your Secrets with Foreshadow

Jo Van Bulck

↸ imec-DistriNet, KU Leuven jo.vanbulck@cs.kuleuven.be jovanbulck

OWASP BeNeLux-Days, November 30, 2018

slide-2
SLIDE 2

A primer on software security

Secure program: convert all input to expected output

INPUT OUTPUT

1 / 20

slide-3
SLIDE 3

A primer on software security

Buffer overflow vulnerabilities: trigger unexpected behavior

INPUT OUTPUT

1 / 20

slide-4
SLIDE 4

A primer on software security

Safe languages & formal verification: preserve expected behavior

INPUT OUTPUT

1 / 20

slide-5
SLIDE 5

A primer on software security

Side-channels: observe side-effects of the computation

INPUT OUTPUT

1 / 20

slide-6
SLIDE 6

Evolution of “side-channel attack” occurrences in Google Scholar

1990 1994 1998 2002 2006 2010 2014 2018 3000 4000 2000 1000

DO WE JUST SUCK AT... COMPUTERS?

  • YUP. ESPECIALLY SHARED ONES.

Based on github.com/Pold87/academic-keyword-occurrence and xkcd.com/1938/ 2 / 20

slide-7
SLIDE 7
slide-8
SLIDE 8

CPU cache timing side-channel

Cache principle: CPU speed ≫ DRAM latency → cache code/data

CPU + cache DRAM memory

while true do maccess(&a); endwh

3 / 20

slide-9
SLIDE 9

CPU cache timing side-channel

Cache miss: Request data from (slow) DRAM upon first use

CPU + cache DRAM memory

while true do maccess(&a); endwh cache miss a

3 / 20

slide-10
SLIDE 10

CPU cache timing side-channel

Cache hit: No DRAM access required for subsequent uses

CPU + cache DRAM memory

while true do maccess(&a); endwh cache hit a

3 / 20

slide-11
SLIDE 11

Cache timing attacks in practice: Flush+Reload

if secret do maccess(&a); else maccess(&b); endif flush(&a); start_timer maccess(&a); end_timer

CPU + cache DRAM memory a

4 / 20

slide-12
SLIDE 12

Cache timing attacks in practice: Flush+Reload

if secret do maccess(&a); else maccess(&b); endif flush(&a); start_timer maccess(&a); end_timer

CPU + cache DRAM memory cache miss secret=1, load 'a' into cache a

4 / 20

slide-13
SLIDE 13

Cache timing attacks in practice: Flush+Reload

if secret do maccess(&a); else maccess(&b); endif flush(&a); start_timer maccess(&a); end_timer

CPU + cache DRAM memory a cache hit fast access(&a) → secret=1

4 / 20

slide-14
SLIDE 14

Cache timing attacks in practice: Flush+Reload

if secret do maccess(&a); else maccess(&b); endif flush(&a); start_timer maccess(&b); end_timer

CPU + cache DRAM memory cache miss slow access(&b) → secret=1 cache miss b

4 / 20

slide-15
SLIDE 15

A primer on software security (revisited)

Side-channels: observe side-effects of the computation

INPUT OUTPUT

5 / 20

slide-16
SLIDE 16

A primer on software security (revisited)

Constant-time code: eliminate secret-dependent side-effects

INPUT OUTPUT

5 / 20

slide-17
SLIDE 17

A primer on software security (revisited)

Transient execution: HW optimizations do not respect SW abstractions (!)

INPUT OUTPUT

5 / 20

slide-18
SLIDE 18
slide-19
SLIDE 19

Out-of-order and speculative execution

Key discrepancy: Programmers write sequential instructions

6 / 20

slide-20
SLIDE 20

Out-of-order and speculative execution

Key discrepancy: Programmers write sequential instructions Modern CPUs are inherently parallel ⇒ Speculatively execute instructions ahead of time

6 / 20

slide-21
SLIDE 21

Out-of-order and speculative execution

Overflow exception Roll-back

Key discrepancy: Programmers write sequential instructions Modern CPUs are inherently parallel ⇒ Speculatively execute instructions ahead of time Best-effort: What if triangle fails? → Commit in-order, roll-back square . . . But side-channels may leave traces (!)

6 / 20

slide-22
SLIDE 22
slide-23
SLIDE 23

Transient execution attacks: Welcome to the world of fun!

CPU executes ahead of time in transient world Success → commit results to normal world Fail → discard results, compute again in normal world

7 / 20

slide-24
SLIDE 24

Transient execution attacks: Welcome to the world of fun!

CPU executes ahead of time in transient world Success → commit results to normal world Fail → discard results, compute again in normal world Transient world (microarchitecture) may temp bypass architectural software intentions: Delayed exception handling Control flow prediction

7 / 20

slide-25
SLIDE 25

Transient execution attacks: Welcome to the world of fun!

Key finding of 2018 ⇒ Transmit secrets from transient to normal world Transient world (microarchitecture) may temp bypass architectural software intentions: Delayed exception handling Control flow prediction

7 / 20

slide-26
SLIDE 26

Transient execution attacks: Welcome to the world of fun!

Key finding of 2018 ⇒ Transmit secrets from transient to normal world Transient world (microarchitecture) may temp bypass architectural software intentions: CPU access control bypass Speculative buffer overflow/ROP

7 / 20

slide-27
SLIDE 27
slide-28
SLIDE 28

Meltdown: Transiently encoding unauthorized memory

Unauthorized access

8 / 20

slide-29
SLIDE 29

Meltdown: Transiently encoding unauthorized memory

Unauthorized access Transient out-of-order window

  • racle array

secret idx

8 / 20

slide-30
SLIDE 30

Meltdown: Transiently encoding unauthorized memory

Unauthorized access Transient out-of-order window Exception (discard architectural state)

8 / 20

slide-31
SLIDE 31

Meltdown: Transiently encoding unauthorized memory

Unauthorized access Transient out-of-order window

  • racle array

cache hit

Exception handler

8 / 20

slide-32
SLIDE 32

Mitigating Meltdown: Unmap kernel addresses from user space

OS software fix for faulty hardware (↔ future CPUs)

9 / 20

slide-33
SLIDE 33

Mitigating Meltdown: Unmap kernel addresses from user space

OS software fix for faulty hardware (↔ future CPUs) Unmap kernel from user virtual address space → Unauthorized physical addresses out-of-reach (˜cookie jar)

SMAP+SMEP user kernel user

context switch

unmapped kernel

context switch switch address space Gruss et al. “KASLR is dead: Long live KASLR”, ESSoS 2017 [GLS+17] 9 / 20

slide-34
SLIDE 34
slide-35
SLIDE 35

Rumors: Meltdown immunity for SGX enclaves?

“[enclaves] remain protected and completely secure” — International Business Times, February 2018

“[enclave memory accesses] redirected to an abort page, which has no value” — Anjuna Security, Inc., March 2018

10 / 20

slide-36
SLIDE 36

Rumors: Meltdown immunity for SGX enclaves?

https://wired.com and https://arstechnica.com 10 / 20

slide-37
SLIDE 37

Enclaved execution attack surface: TCB reduction

https://informationisbeautiful.net/visualizations/million-lines-of-code/ 11 / 20

slide-38
SLIDE 38

Enclaved execution attack surface: TCB reduction Mem HDD OS kernel

Trusted Untrusted

CPU App App TPM Hypervisor App App

11 / 20

slide-39
SLIDE 39

Enclaved execution attack surface: TCB reduction

Mem HDD OS kernel CPU App App TPM Hypervisor Enclave app

Intel SGX promise: hardware-level isolation and attestation

11 / 20

slide-40
SLIDE 40

Enclaved execution attack surface: TCB reduction

Mem HDD OS kernel CPU App App TPM Hypervisor Enclave app

Trusted CPU → exploit microarchitectural bugs/design flaws

Van Bulck et al. “Foreshadow: Extracting the Keys to the Intel SGX Kingdom with Transient Out-of-Order Execution”, USENIX 2018 [VBMW+18] 11 / 20

slide-41
SLIDE 41
slide-42
SLIDE 42

Building Foreshadow

12 / 20

slide-43
SLIDE 43

Building Foreshadow

L1 terminal fault challenges

Foreshadow can read unmapped physical addresses from the cache (!)

12 / 20

slide-44
SLIDE 44

Foreshadow-NG: Breaking the virtual memory abstraction

PT walk?

L1D vadrs padrs T ag? CPU micro-architecture

L1 cache design: Virtually-indexed, physically-tagged

13 / 20

slide-45
SLIDE 45

Foreshadow-NG: Breaking the virtual memory abstraction

PT walk?

L1D vadrs padrs T ag? CPU micro-architecture

Page fault: Early-out address translation

13 / 20

slide-46
SLIDE 46

Foreshadow-NG: Breaking the virtual memory abstraction

PT walk?

L1D vadrs CPU micro-architecture

padrs Tag? Pass to out-of-order

L1-Terminal Fault: match unmapped physical address (!)

13 / 20

slide-47
SLIDE 47

Foreshadow-NG: Breaking the virtual memory abstraction

PT walk?

L1D vadrs CPU micro-architecture

padrs Tag? Pass to out-of-order

SGX?

Foreshadow-SGX: bypass enclave isolation

13 / 20

slide-48
SLIDE 48

Foreshadow-NG: Breaking the virtual memory abstraction

PT walk?

L1D vadrs CPU micro-architecture

Tag? Pass to out-of-order

SGX? EPT walk?

host padrs

guest padrs

Foreshadow-VMM: bypass virtual machine isolation

13 / 20

slide-49
SLIDE 49

Mitigating Foreshadow

14 / 20

slide-50
SLIDE 50

Mitigating Foreshadow

Future CPUs (silicon-based changes)

https://newsroom.intel.com/editorials/advancing-security-silicon-level/ 14 / 20

slide-51
SLIDE 51

Mitigating Foreshadow

OS kernel updates (sanitize page frame bits)

https://wiki.ubuntu.com/SecurityTeam/KnowledgeBase/L1TF 14 / 20

slide-52
SLIDE 52

Mitigating Foreshadow

Intel microcode updates

⇒ Flush L1 cache on enclave/VMM exit + disable HyperThreading

https://software.intel.com/security-software-guidance/software-guidance/l1-terminal-fault 14 / 20

slide-53
SLIDE 53

Mitigating Foreshadow/L1TF: Hardware-software cooperation

15 / 20

slide-54
SLIDE 54
slide-55
SLIDE 55

Some good news?

https://www.technologyreview.com/the-download/611879/intels-foreshadow-flaws-are-the-latest-sign-of-the-chipocalypse/ https://www.intel.com/content/www/us/en/architecture-and-technology/l1tf.html 16 / 20

slide-56
SLIDE 56

Some good news?

https://www.zdnet.com/article/azure-confidential-computing-microsoft-boosts-security-for-cloud-data/ 16 / 20

slide-57
SLIDE 57

Some good news?

https://www.zdnet.com/article/azure-confidential-computing-microsoft-boosts-security-for-cloud-data/ 16 / 20

slide-58
SLIDE 58

Foreshadow fallout: Dismantling the SGX ecosystem

Remote attestation and secret provisioning Challenge-response to prove enclave identity

App enclave

17 / 20

slide-59
SLIDE 59

Foreshadow fallout: Dismantling the SGX ecosystem

CPU-level key derivation Intel == trusted 3th party (shared CPU master secret)

17 / 20

slide-60
SLIDE 60

Foreshadow fallout: Dismantling the SGX ecosystem

CPU-level key derivation Intel == trusted 3th party (shared CPU master secret)

17 / 20

slide-61
SLIDE 61

Foreshadow fallout: Dismantling the SGX ecosystem

Fully anonymous attestation Intel Enhanced Privacy ID (EPID) group signatures

17 / 20

slide-62
SLIDE 62

Foreshadow fallout: Dismantling the SGX ecosystem

The dark side of anonymous attestation Single compromised EPID key affects millions of devices . . .

17 / 20

slide-63
SLIDE 63

Foreshadow fallout: Dismantling the SGX ecosystem

EPID key extraction with Foreshadow Active man-in-the-middle: read + modify all local and remote secrets (!)

App enclave

17 / 20

slide-64
SLIDE 64

Reflections on trusting trust “No amount of source-level verification or scrutiny will protect you from using untrusted

  • code. [. . . ] As the level of program gets

lower, these bugs will be harder and harder to

  • detect. A well installed microcode bug will be

almost impossible to detect.”

— Ken Thompson (ACM Turing award lecture, 1984)

18 / 20

slide-65
SLIDE 65

Research challenges: Universal classification and evaluation

Transient cause? Spectre-type microarchitec- tural buffer Meltdown-type fault type Spectre-PHT Spectre-BTB Spectre-RSB Spectre-STL mistraining strategy Cross-address-space Same-address-space PHT-CA-IP PHT-CA-OP ⭑ PHT-SA-IP ⭑ PHT-SA-OP ⭑ in-place (IP) vs., out-of-place (OP) Cross-address-space Same-address-space BTB-CA-IP BTB-CA-OP BTB-SA-IP ⭑ BTB-SA-OP ⭑ Cross-address-space Same-address-space RSB-CA-IP RSB-CA-OP ⭐ RSB-SA-IP RSB-SA-OP ⭐ Meltdown-NM Meltdown-AC ⭐ Meltdown-DE ⭐ Meltdown-PF Meltdown-UD ⭐ Meltdown-SS ⭐ Meltdown-BR Meltdown-GP Meltdown-US Meltdown-P Meltdown-RW Meltdown-PK ⭑ Meltdown-XD ⭐ Meltdown-SM ⭐ Meltdown-MPX Meltdown-BND ⭑ prediction fault Canella et al. “A Systematic Evaluation of Transient Execution Attacks and Defenses”, arXiv preprint [CVBS+18] 19 / 20

slide-66
SLIDE 66
slide-67
SLIDE 67

Conclusions and take-away

https://foreshadowattack.eu/

Hardware + software patches Update your systems! (+ disable HyperThreading)

20 / 20

slide-68
SLIDE 68

Conclusions and take-away

https://foreshadowattack.eu/

Hardware + software patches Update your systems! (+ disable HyperThreading) ⇒ New class of transient execution attacks ⇒ Importance of fundamental side-channel research ⇒ Security cross-cuts the system stack: hardware, hypervisor, kernel, compiler, application

20 / 20

slide-69
SLIDE 69

References I

  • C. Canella, J. Van Bulck, M. Schwarz, M. Lipp, B. von Berg, P. Ortner, F. Piessens, D. Evtyushkin, and D. Gruss.

A systematic evaluation of transient execution attacks and defenses. arXiv preprint arXiv:1811.05441, 2018.

  • D. Gruss, M. Lipp, M. Schwarz, R. Fellner, C. Maurice, and S. Mangard.

KASLR is dead: Long live KASLR. In International Symposium on Engineering Secure Software and Systems, pp. 161–176. Springer, 2017.

  • P. Kocher, J. Horn, A. Fogh, , D. Genkin, D. Gruss, W. Haas, M. Hamburg, M. Lipp, S. Mangard, T. Prescher, M. Schwarz, and Y. Yarom.

Spectre attacks: Exploiting speculative execution. In Proceedings of the 40th IEEE Symposium on Security and Privacy (S&P’19), 2019.

  • M. Lipp, M. Schwarz, D. Gruss, T. Prescher, W. Haas, A. Fogh, J. Horn, S. Mangard, P. Kocher, D. Genkin, Y. Yarom, and M. Hamburg.

Meltdown: Reading kernel memory from user space. In Proceedings of the 27th USENIX Security Symposium (USENIX Security 18), 2018.

  • J. Van Bulck, M. Minkin, O. Weisse, D. Genkin, B. Kasikci, F. Piessens, M. Silberstein, T. F. Wenisch, Y. Yarom, and R. Strackx.

Foreshadow: Extracting the keys to the Intel SGX kingdom with transient out-of-order execution. In Proceedings of the 27th USENIX Security Symposium. USENIX Association, August 2018.

  • J. Van Bulck, F. Piessens, and R. Strackx.

Nemesis: Studying microarchitectural timing leaks in rudimentary CPU interrupt logic. In Proceedings of the 25th ACM Conference on Computer and Communications Security (CCS’18). ACM, October 2018.

  • O. Weisse, J. Van Bulck, M. Minkin, D. Genkin, B. Kasikci, F. Piessens, M. Silberstein, R. Strackx, T. F. Wenisch, and Y. Yarom.

Foreshadow-NG: Breaking the virtual memory abstraction with transient out-of-order execution. Technical Report https: // foreshadowattack. eu/ , 2018. 21 / 20

slide-70
SLIDE 70
slide-71
SLIDE 71

Spectre v1: Speculative buffer over-read

secret user buffer

Programmer intention: never access out-of-bounds memory

22 / 20

slide-72
SLIDE 72

Spectre v1: Speculative buffer over-read

secret user buffer

Programmer intention: never access out-of-bounds memory Branch can be mistrained to speculatively (i.e., ahead of time) execute with idx ≥ LEN in the transient world

22 / 20

slide-73
SLIDE 73

Spectre v1: Speculative buffer over-read

secret user buffer

Programmer intention: never access out-of-bounds memory Branch can be mistrained to speculatively (i.e., ahead of time) execute with idx ≥ LEN in the transient world Side-channels leak out-of-bounds secrets to the real world

22 / 20

slide-74
SLIDE 74

Mitigating Spectre v1: Inserting speculation barriers

secret user buffer

Programmer intention: never access out-of-bounds memory

23 / 20

slide-75
SLIDE 75

Mitigating Spectre v1: Inserting speculation barriers

secret user buffer

Programmer intention: never access out-of-bounds memory Insert speculation barrier to tell the CPU to halt the transient world until idx got evaluated ↔ performance

23 / 20

slide-76
SLIDE 76

Mitigating Spectre v1: Inserting speculation barriers

secret user buffer

Programmer intention: never access out-of-bounds memory Insert speculation barrier to tell the CPU to halt the transient world until idx got evaluated ↔ performance Huge error-prone manual effort, no reliable automated compiler approaches yet. . .

23 / 20

slide-77
SLIDE 77