+ All Categories
Home > Documents > Improving embedded security with S²E, KLEE and...

Improving embedded security with S²E, KLEE and...

Date post: 22-May-2020
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
29
The Avatar project: Improving embedded security with S²E, KLEE and Qemu http://www.s3.eurecom.fr/tools/avatar/ Luca Bruno <[email protected]>, J. Zaddach, A. Francillon, D. Balzarotti
Transcript
Page 1: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

The Avatar project:Improving embedded security with

S²E, KLEE and Qemu

http://www.s3.eurecom.fr/tools/avatar/

Luca Bruno <[email protected]>,J. Zaddach, A. Francillon, D. Balzarotti

Page 2: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

202/02/2014

About us

• Eurecom, a consortium of European universities in French riviera

• Security research group

– 9 people

• Applied system security

– Embedded systems

– Networking devices

– Critical infrastructures

Page 3: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

302/02/2014

Outline

• Embedded security

• Avatar overview

• Framework components

• Field testing

• Conclusions

Page 4: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

402/02/2014

Software everywhere

• Embedded devices are diverse – but all of them run software

Page 5: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

502/02/2014

Reasons for embedded security

• Embedded devices are ubiquitous

– Even if not visible, your lives depend on them

• Can operate for many years

– Legacy systems, no (security) updates

• Have large attack surfaces

– Networking, forgotten debug interfaces, etc.

• Sometime too easy to take­over/backdoor

Page 6: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

602/02/2014

Challenges in embedded security

• No source code available– Often monolithic binary­only firmwares

• No toolchain available

• No documentation available

• Unique tools (to flash and debug) for each manufacturer

Page 7: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

702/02/2014

Wishlist for security evaluation

• Typical PC­security toolbox

– Advanced debugging techniques

• Tracing

• Fuzzing

• Symbolic Execution

• Tainting

– Integrated tools

• IDA Pro

• GDB

• Netzob

A

B C

D E

>0≤0

<8 ≥8

0<x<8

Page 8: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

802/02/2014

Outline

• Embedded security

• Avatar overview

• Framework components

• Field testing

• Conclusions

Page 9: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

902/02/2014

Why Avatar

• Provide a framework for– In­vivo analysis of any kind of device– Advanced debugging– Easy prototyping

• Integrated workbench

– To use all techniques together on a live system

• Not only focused on security

– Debugging/profiling/tracing is hard in embedded environments

Page 10: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1002/02/2014

Avatar: basics

• Emulate embedded devices’ firmwares

• Forward peripheral accesses to the device under analysis

• Do NOT attempt to emulate peripherals

– No documentation

– Reverse engineering is difficult

Page 11: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1102/02/2014

Avatar overview

FirmwareEmbedded

device

Emulator Proxy

Avatar

EmulatorBackend

TargetBackend

Plugins

read/write memory

interrupt

read/write memory

valuevalue

interrupt

. . .mov r2, r0mov r3, r1add r3, r3, #1add r2, ip, r2ldr r2, [r2], #0cmp r2, r3 . . .

Page 12: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1202/02/2014

Avoid NIH syndrome

• S²E (Qemu+Klee) 

– for emulation and symbolic execution

• GDB and OpenOCD

– to attach components and devices

• Your own tools for analysis– IDA Pro, Capstone, Netzob...

Page 13: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1302/02/2014

Outline

• Embedded security

• Avatar overview

• Framework components

• Field testing

• Conclusions

Page 14: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1402/02/2014

LLVM under the hood

• S²E combines existing tools to achieve symbolic execution of x86/ARM binary code

– Qemu translates binary code to an intermediate representation (TCG)

– QEMU­LLVM translates TCG to LLVM bytecode

– KLEE executes LLVM bytecode symbolically

Page 15: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1502/02/2014

S²E in a nutshell

Emulator

RemoteMemplugin

S²EQMP/Lua

QemuGDB

Qemuconfig

VM state● Registers● CPU state● Memory

Qemuexecuter

Qemufrontend

LLVM

Symbolicstates

KLEE

TCG

S²Ehooks

Avatar

Page 16: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1602/02/2014

Python3 framework

Avatar

Analysis script

Targetbackend

GDBadapter

Telnetadapter

BinProtoadapter

GDB/MIadapter

Emulatorbackend

Memoryforwarder

QMP/Luainterface

GDBinterface

Configwriter

AnalysisPlugins

Emulator Target

Page 17: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1702/02/2014

Analysis platform

• Avatar provides analysis glue– Orchestrate execution– Bridge between emulator   device⟷

– Intercept/manipulate memory accesses– External integration, exposing GDB or 

JSON interfaces

Page 18: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1802/02/2014

Embedded target

Avatar

OpenOCD

Target device

In-memorystub

Target state● Registers● CPU state● Memory

JTAG

UART

Page 19: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

1902/02/2014

Target communication

• Either a debugging interface

– JTAG

– Debug Serial Interface

• Or code injection and a communication channel

– GDB Stub + Serial Port

Page 20: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2002/02/2014

Outline

• Embedded security

• Avatar overview

• Framework components

• Field testing

• Conclusions

Page 21: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2102/02/2014

Usecases

• Check  for hidden backdoors in HDD firmware

• Fuzzing/symbolic execution of SMS decoding on feature phone

• Vulnerabilities check on programmable  wireless sensors

Page 22: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2202/02/2014

Bottlenecks

• Emulated execution is much slower than execution on the real device

– Memory access forwarding through low­bandwidth channel is the bottleneck

– In one case down to ~10 instr./sec.

• Interrupts are tricky, can overwhelm emulation

Page 23: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2302/02/2014

Improving performance

• Point of Interest is often far down in the firmware

– Trap execution on device and transfer state to the emulator

● A large part of forwarded accesses are to non­IO memory

– Detect and drop forwarding for non­IO memory regions (stack, heap and code in the emulator)

● High­periodicity interrupts can be synthesized to avoid saturation

Page 24: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2402/02/2014

Outline

• Embedded security

• Avatar overview

• Framework components

• Field testing

• Conclusions

Page 25: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2502/02/2014

Limitations

• State consistency– DMA memory changes not tracked

• Timing consistency– Emulated execution time much slower than real 

execution time

• Symbolic execution– Coherency between HW and SW

• Bug­finding strategies to be improved

Page 26: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2602/02/2014

Recap

• Avatar is a tool to – Enable dynamic analysis– And perform symbolic execution– On embedded devices– Where only binary code is available

Page 27: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2702/02/2014

Questions?

Thank you for listening!

Thanks to Pascal Sachs and Luka Malisa who built an earlier prototype of the system, and Lucian Cojocar for contributions

Page 28: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2802/02/2014

References

• AVATAR web page: http://www.s3.eurecom.fr/tools/avatar/

• AVATAR: A Framework to Support Dynamic Security Analysis of Embedded Systems' Firmwares, Jonas Zaddach, Luca Bruno, Aurelien Francillon, Davide Balzarotti

• Howard: a dynamic excavator for reverse engineering data structures, Asia Slowinska, Traian Stancescu, Herbert Bos

• KLEE webpage: http://ccadar.github.io/klee/

• S2E webpage: https://s2e.epfl.ch/

• S2E: A Platform for In­Vivo Multi­Path Analysis of Software Systems, Vitaly Chipounov, Volodymyr Kuznetsov, George Candea

• The S2E Platform: Design, Implementation, and Applications, Vitaly Chipounov, Volodymyr Kuznetsov, George Candea

• QEMU webpage: http://qemu.org

• Dowsing for Overflows: A Guided Fuzzer to Find Buffer Boundary Violations, Istvan Haller, Asia Slowinska, Matthias Neugschwandtner, Herbert Bos

Page 29: Improving embedded security with S²E, KLEE and Qemus3.eurecom.fr/tools/avatar/bruno_avatar-fosdem14.pdf · Avatar overview Firmware Embedded device Emulator Proxy Avatar Emulator

2902/02/2014

Extra: GDB stub

• GDB can connect to targets using a serial interface and a simple protocol

• There is a stub implementation in the source code tree, but not for ARM and it’s bloated (for our purposes)

• 6 primitives are enough to give debugging support with software breakpoints:

Read bytes, write bytes, read registers, write registers, continue and get signal


Recommended