EPOXY: Shielding Bare-Metal Embedded Systems Mathias Payer - - PowerPoint PPT Presentation

epoxy shielding bare metal embedded systems
SMART_READER_LITE
LIVE PREVIEW

EPOXY: Shielding Bare-Metal Embedded Systems Mathias Payer - - PowerPoint PPT Presentation

EPOXY: Shielding Bare-Metal Embedded Systems Mathias Payer (@gannimo), Purdue University Jointly with Abraham Clements and Saurabh Bagchi http://hexhive.github.io 1 Bugs are everywhere? https://en.wikipedia.org/wiki/Pwn2Own 2 Trends in


slide-1
SLIDE 1

1

EPOXY: Shielding Bare-Metal Embedded Systems

Mathias Payer (@gannimo), Purdue University Jointly with Abraham Clements and Saurabh Bagchi http://hexhive.github.io

slide-2
SLIDE 2

2

https://en.wikipedia.org/wiki/Pwn2Own

Bugs are everywhere?

slide-3
SLIDE 3

3

Trends in Memory Errors*

* Victor van der Veen, https://www.vvdveen.com/memory-errors/, updated Feb. 2017

slide-4
SLIDE 4

4

Software is unsafe and insecure*

  • Low-level languages (C/C++) trade type safety

and memory safety for performance

– Our systems are implemented in C/C++ – Too many bugs to find and fix manually

* SoK: Eternal War in Memory. Laszlo Szekeres, Mathias Payer, Tao Wei, and Dawn Song. In IEEE S&P'13

Google Chrome: 76 MLoC glibc: 2 MLoC Linux kernel: 14 MLoC

slide-5
SLIDE 5

5

Control-Flow Hijack Attack

slide-6
SLIDE 6

6

Attack scenario: code injection

  • Force memory corruption to set up attack
  • Redirect control-flow to injected code

Code Heap Stack

slide-7
SLIDE 7

7

Attack scenario: code reuse

  • Find addresses of gadgets
  • Force memory corruption to set up attack
  • Redirect control-flow to gadget chain

Code Heap Stack

slide-8
SLIDE 8

8

Defenses protect desktops/servers

  • Address Space Layout Randomization

– Shuffles address space, requires information leak

  • Data Execution Prevention

– Prohibits code injection, requires ROP

  • Stack Canaries

– Prohibits stack smashing, requires direct write

slide-9
SLIDE 9

9

Control-Flow Integrity

slide-10
SLIDE 10

10

Control-Flow Integrity (CFI)*

  • Restrict a program’s dynamic control-flow to

the static control-flow graph

– Requires static analysis – Dynamic enforcement mechanism

  • Forward edge: virtual calls, function pointers
  • Backward edge: function returns

* Control-Flow Integrity. Martin Abadi, Mihai Budiu, Ulfar Erlingsson, Jay Ligatti. CCS ‘05 * Control-Flow Integrity: Protection, Security, and Performance. Nathan Burow, Scott A. Carr, Joseph Nash, Per Larsen, Michael Franz, Stefan Brunthaler, Mathias Payer. ACM CSUR ‘18, preprint: https://nebelwelt.net/publications/files/18CSUR.pdf

slide-11
SLIDE 11

11

Control-Flow Integrity (CFI)

CHECK(fn); (*fn)(x); CHECK_RET(); return 7

Attacker may corrupt memory, code ptrs. verified when used

slide-12
SLIDE 12

12

CFI: limitations

  • CFI provides incremental security

– Attacker can choose between valid targets – Data-flow attacks are out of scope

  • Strength of CFI depends on static analysis

– Coarse-grained: all functions are allowed – Fine-grained: arity or function prototype

slide-13
SLIDE 13

13

Are we making progress?

2007 2017

slide-14
SLIDE 14

14

The State of the IoT

slide-15
SLIDE 15

15

Defenses deployed on IoT devices

slide-16
SLIDE 16

16

Bare-metal devices

(c) dekuNukem, hackaday.io (c) Felix, lowpowerlab.com (c) bunnie, bunniestudios.com (c) yenra

slide-17
SLIDE 17

17

Security challenges

  • Single application

– No separate privilege levels (kernel/user)

  • No MMU (virtual memory)

– Defenses limited to physical memory space

  • Tight constraints

– Runtime, memory, battery

slide-18
SLIDE 18

18

IoT security stack

Security Hardware Global Data Stack Code Bare-metal Application Unused or trivially bypassed Vulnerable to: Stack smashing Code injection Global data corruption IO Always accessible Single (Root) execution domain No ROP defenses Sensitive IO

RAM Flash

slide-19
SLIDE 19

19

Let’s exploit like in ‘99

(c) MGM

slide-20
SLIDE 20

20

EPOXY*

* Embedded Privilege Overlay across (X) hardware for anY software

slide-21
SLIDE 21

21

EPOXY design

EPOXY LLVM-based compiler Sensitive IO Hardened Application Source Code

  • LLVM-based compiler
  • Protects against

– Code injection – IO manipulation – Control-flow hijack* – Data corruption*

* Probabilistic, strength may vary (tm)

slide-22
SLIDE 22

22

Embedded systems: opportunities

  • No separation between “apps” or user/kernel

– Only few instructions require privileges

  • Small memory size: MBs of Flash, KBs of RAM

– Memory is dedicated, may reuse all slack space

  • Tight runtime constraints

– Execution is interrupt driven, use slack

  • Low power requirements

– Limit overhead to few instructions

slide-23
SLIDE 23

23

Mission 1: privilege separation

(c) AMC, Walking Dead

slide-24
SLIDE 24

24

Before EPOXY

Code Global Data Stack IO Application Security HW Sensitive IO Privileged Execution

slide-25
SLIDE 25

25

Privilege separation

  • Static analysis identifies restricted operations

– Specific instructions per ISA – Sensitive memory-mapped registers (MPU, IO)

  • Instrumentation to

– Configure MPU to drop privileges – Raise privileges selectively

  • Enable security hardware

– Enforce W^X code, RW data – Protect access to security hardware, I/O

slide-26
SLIDE 26

26

Privilege overlay: benefits

Code Global Data Stack IO Security HW Sensitive IO Enabled, Access Restricted Access Restricted Unprivileged Execution Privileged Execution Set to RX, Enforces Code Integrity Set to RW, Stops Code Injection

slide-27
SLIDE 27

Evaluation: privileged instructions

Application Tool Exe Priv Priv % PinLock EPOXY 823K 1.4K 0.17% FreeRTOS-MPU 823K 813K 98.78% FatFS-uSD EPOXY 33.3M 3.9K 0.01% FreeRTOS-MPU 34.1M 33.0M 96.77% TCP-Echo EPOXY 310M 1.5K <0.001% FreeRTOS-MPU 322M 307.0M 95.34%

slide-28
SLIDE 28

28

Mission 2: stop stack smashing

(c) Nintendo

slide-29
SLIDE 29

* V. Kuznetsov et al., Code Pointer Integrity, OSDI 2014

RAM Stack .data .bss heap Stack UnSafeStack Guard Region

Stack integrity through SafeStack

  • Split stack into safe stack and unsafe stack*
  • Move unsafe objects to unsafe stack
  • Protects against stack smashing
slide-30
SLIDE 30

Mission 3: shuffle

slide-31
SLIDE 31

EPOXY

  • Shuffle globals, stack, and code

– Protects against ROP – Protects against global data corruption

Seed Binary 1 Binary 2 Binary 3 Binary 4

Seed 1 Seed 2 Seed 3 Seed 4

Diversification

Sources

slide-32
SLIDE 32

RAM .data .bss heap Stack UnSafeStack A B D A B C D .data B b d c a a c b d .bss C 1 2 4 3 Flash foo bar baz bar2 foo2 handler Jumps to handler

Binary 1

invalid execution E Padding Stack UnSafeStack heap handler foo foo2 bar2 bar baz

Diversification

slide-33
SLIDE 33

EPOXY: full feature set

Code Global Data Stack IO Hardened Application Security HW Sensitive IO Enabled, Access Restricted Access Restricted UnSafeStack Isolate Unsafe Data

Protected stack, ROP Protections

Global Data Protected ROP Protections Unprivileged Execution Privileged Execution Set to RX, Enforces Code Integrity Set to RW, Stops Code Injection

slide-34
SLIDE 34

Evaluation: ROP gadgets

# Surviving Across App Total 2 5 25 50 Last PinLock 294K 14K 8K 313 48 FatFS-uSD 1,009K 39K 9K 39 32 TCP-Echo 676K 22K 9K 985 700 107

Using ROPgadget compiler to identify surviving gadgets across # diversified binaries

slide-35
SLIDE 35

Performance impact (BEEP)

Runtime SS PO All Min

  • 7.3%
  • 1.3%
  • 11.7%

Ave

  • 3.5%

0.1% 1.1% Max 4.4% 2.1% 14.2% Energy SS PO All Min

  • 4.2%
  • 10.3%
  • 10.2%

Ave 0.2%

  • 0.2%

2.5% Max 7.3% 2.8% 17.9% SS: SafeStack, PO: Privilege Overlay

slide-36
SLIDE 36

Performance impact

P i n L o c k F a t F S - u S D T C P - E c h o 1 5 1 0 5 5 1 0 1 5 % I n c r e a s e E n e r g y S S P O P i n L o c k F a t F S - u S D T C P - E c h o 1 5 1 0 5 5 1 0 1 5 % I n c r e a s e R u n t i m e S S P O

IoT Apps Runtime IoT Apps Energy

slide-37
SLIDE 37

37

Conclusion

slide-38
SLIDE 38

38

  • Embedded systems need protection

– Currently no defenses, easy target

  • Fast forward embedded security by 3 decades

– Privilege separation, mitigate code injection – Safe stack protects against stack smashing – Diversification instead of ASLR

  • Meets runtime, memory, energy requirements

Source: https://github.com/HexHive/EPOXY

Conclusion

slide-39
SLIDE 39

39

Thank you! Questions?

Mathias Payer (@gannimo), Purdue University http://hexhive.github.io