towards automated dynamic analysis for linux-based ...€¦ · towards automated dynamic analysis...

22
Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen 1 , Manuel Egele 2 , Maverick Woo 1 , David Brumley 1 1 Carnegie Mellon University, 2 Boston University {ddchen , pooh , dbrumley }@ cmu.edu, [email protected]

Upload: others

Post on 11-Nov-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Towards Automated Dynamic Analysis for Linux-based Embedded Firmware

Dominic Chen1, Manuel Egele2, Maverick Woo1, David Brumley1

1Carnegie Mellon University, 2Boston University{ddchen, pooh, dbrumley}@cmu.edu, [email protected]

Page 2: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

2

Page 3: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

FIRMADYNE

• First system for full-system emulation of embedded Linux-based firmware

• Provides large-scale automated dynamic analysis

– Built-in vulnerability detection

– Tested on 9.5k extracted firmware images

• Objective: Continuous integration for firmware

3

Page 4: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Background

• Embedded devices are important

– Low visibility by end-users

– Critical network infrastructure

– Software rarely upgraded

• Difficult to analyze

– RISC-based architectures: MIPS, ARM, etc.

– No direct interface into device firmware

– Fixed hardware peripherals; no ‘Plug and Play’

– Significant variety; hard to scale

4

Page 5: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Firmware Architectures

5

0

500

1000

1500

2000

2500

3000

3500

4000

4500

5000

MIPS ARM Unknown x86-64 PPC MIPS-64 x86 Other

Nu

mb

er

of

Fir

mw

are

Im

ag

es

Big Endian Little Endian Unknown

*

*

*

Page 6: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Related Work

• Zaddach et al., “Avatar: A framework to support dynamic security analysis of embedded systems’ firmwares”, NDSS 2014– Software emulation with partial offload to hardware

– Doesn’t scale: requires hardware and connection to debug port

• Costin et al., “A large-scale analysis of the security of embedded firmwares”, USENIX 2014– Static extraction and analysis of firmware

– Relatively cursory analysis and can’t verify results; classic trade-offs of false positives vs. false negatives

6

Page 7: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Dynamic Approaches

• Application-level– Extract webpages and perform analysis– Custom interpreter modifications

• Process-level– Emulate original applications in user-mode– Different hardware and execution environment

• System-level– Boots entire filesystem with modified kernel– Supports all applications using original environment

7

Page 8: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

FTP

Sites

Support

Websites Filesystem Kernel

Architecture

Identification

Initial

Emulation

MIPS

Little-Endian

Network

IdentificationExploit

Verification

“&& cat 0xDEADBEEF”

8

Network

Reachable

eth0: 192.168.1.100

eth1: 10.0.0.1

eth2: 128.2.42.52

Page 9: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Filesystem Recovery

• Firmware format is not standardized

– Can be compressed, include photos, etc.

• Solution: Develop custom extractor for filesystems

– Searches for UNIX-like filesystems

– Includes heuristics to avoid recursive extraction

• Improved existing unpacking tools

– jefferson: User-mode extractor for JFFS2

– sasquatch: Heuristic-based extractor for SquashFS

9

Page 10: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Device Configuration

• Firmware requires NVRAM peripheral to boot

– Used as volatile configuration store

• Solution: Emulate NVRAM peripheral with userspace library

– Compatible with different C runtime libraries

– Self-initializes with default NVRAM values used during factory reset

10

Page 11: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Network Inference

• Devices expect different network configuration

– eth0 vs. lan0, wlan0, wan0, vs. ath0, br0, etc.

• Solution: Use custom kernel with software instrumentation to infer networking

– Parse kernel log to infer expected configuration

– Track IP addresses, bridges, and VLANs

– Restart with new configuration

11

Page 12: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Automated Analyses

• Accessible Webpages

– Checks for unauthenticated webpages

– Command injection/information disclosure

• SNMP Information

– Dumps public SNMP data

– Information disclosure

• Vulnerability Detection

– Checks for presence of vulnerabilities

12

Page 13: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Firmware Analysis Progress by Vendor

13

0

1000

2000

3000

4000

5000

6000

Downloaded Extracted ArchitectureIdentified

InitialEmulation

NetworkInferred

NetworkReachable

Exploited

Nu

mb

er

of

Fir

mw

are

Im

ag

es

Other QNAP Polycom TRENDnet

TP-Link OpenWrt ZyXEL Synology

Tomato by Shibby D-Link Netgear

Page 14: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Vulnerability Analysis

• Discovered 14 previously-unknown vulnerabilities– New vulnerabilities can be automatically tested

across entire dataset

– Selected 60 applicable vulnerabilities from Metasploit

• Of 1,971 firmware images that were network reachable, 43%* (846) were vulnerable to at least one exploit– Estimated to affect 89+ different products

14* Corrected

Page 15: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Unknown Vulnerabilities

• Discovered 14 unknown vulnerabilities that affect 69 firmware images across 12+ products using our analyses– Command Injection (Netgear)

– Buffer Overflow (D-Link)

– Information Disclosure (D-Link & Netgear)

• Responsible disclosure to vendors and CERT– VU#548680: Affected D-Link devices

– VU#615808: Affected Netgear devices• Fix is expected by end of February/mid-March

15

Page 16: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Netgear Command Injection (CVE-2016-1555)

• Unauthenticated webpages with debug functionality were accidentally included

– Used to write manufacturing data, e.g. MAC addresses, firmware region, and serial number

– Can detect with our instrumentation

• Form input is passed directly as command-line argument to shell

– Affects 65 firmware images across 7+ products

16

Page 17: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

D-Link Buffer Overflow (CVE-2016-1558)

• Web server sets dlink_uid cookie to track sessions for authenticated users

– Value is passed to strlen() then memcpy()

• Setting the cookie to a long string crashes the web server at e.g. 0x41414141

– Affects 13 firmware images across 5+ products

17

Page 18: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

D-Link & Netgear Information Disclosure

• Unauthenticated services provide sensitive information

– Web pages (CVE-2016-1556)

– SNMP queries (CVE-2016-1557, CVE-2016-1559)

• Insecure default configuration

– Affects 54 firmware images across 10+ products

18

Page 19: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Code Reuse

• Sercomm Backdoor (CVE-2014-0659)– Unauthenticated remote attackers can dump configuration– Affects 282 firmware images across 16+ products from our

dataset– Our results show On Networks and TRENDnet are also

affected

• MiniUPnPd Denial of Service (CVE-2013-0229)– Parsing flaws in open-source internet-facing UPnP daemon– Affects 169 firmware images across 14+ products from our

dataset

• OpenSSL ChangeCipherSpec (CVE-2014-0224)– TLS implementation allows attacker to downgrade cipher– Affects 169 firmware images across 27+ products from our

dataset

19

Page 20: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Classification of Tested Vulnerabilities

20

5%4%

16%

33%1%

7%

1%

33% Authentication Bypass

Backdoor

Buffer Overflow

Command Execution

Cryptographic Flaw

Denial of Service

File Upload

Information Disclosure

Page 21: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Conclusion

21

• FIRMADYNE allows full-system emulation and dynamic analysis of Linux-based firmware– Infers network configuration of firmware

– Emulates hardware peripherals, e.g. NVRAM

– Automatically checks for vulnerabilities across dataset

• 43% of all network reachable firmware images are vulnerable to at least one exploit– Future work in investigating code sharing among OEM’s

• Open-source and available today– https://github.com/firmadyne

– Patches welcome!

Page 22: Towards Automated Dynamic Analysis for Linux-based ...€¦ · Towards Automated Dynamic Analysis for Linux-based Embedded Firmware Dominic Chen1, Manuel Egele2, Maverick Woo 1, David

Questions

22

• Dominic Chen ([email protected])