How to Find Bugs in USB Device Drivers

How to Find Bugs in USB Device Drivers

Don’t trust your USB How to find bugs in USB device drivers OpenSource Security Ralf Spenneberg 2 Motivation • compromise systems via USB • find bugs, fix or exploit them :-) ms_s3c Sergej Schumilo - [email protected] 3 BadUSB (2014) Facedancer (2012) USB Fuzzing for the Masses (2011) ms_s3c Sergej Schumilo - [email protected] 4 Impact • CVE-2013-1285 • CVE-2013-1680 ms_s3c Sergej Schumilo - [email protected] 5 Plug and Root? Darrin Barrall and David Dewey 2005 at Black Hat ms_s3c Sergej Schumilo - [email protected] 6 USB in a nutshell driver initialization driver specific function usb-core-driver specific driver subsystems HID SCSI Enumeration r8192u_usb network Endpoint data transfer udlfb framebuffer ms_s3c Sergej Schumilo - [email protected] 7 Enumeration usb core driver specific device driver Vendor: 0x0bb4 (HTC) ! Product: 0x0a09 (PocketPC Sync) ms_s3c Sergej Schumilo - [email protected] 8 vUSBf Framework • usage of QEMU and KVM for virtualization • usage of USB Redirection interface for USB data injection • send usb traffic through TCP, UDP or Unix sockets • wrap usb data into USB Redirection protocol headers • it supports USB 1.0, 1.1, 2.0, 3.0 ms_s3c Sergej Schumilo - [email protected] 9 USB Redirection redirserver redir specific QEMU USB- emulated VM- libusb usb traffic Device HC Kernel 2. Losungsansatz¨ ! Figure 1. Aufbau usbredirserver • provides remote USB-device Die Anforderungen an das Fuzzing-Framework waren Der USB-Traffic wird dabei logisch zwischen libusb und unteranderem die elengante Losung¨ der langsamen • dempart emuliertenof the SPICE Host-Controller suite (HC) ubertragen¨ (Abb.1). Ausfuhrgeschwindigkeit,¨ die Gegebenheit einer hohen Reell werden die Pakete jedoch in Form von USB- Reproduzierbarkeit und die moglichst¨ luckenlosen¨ Pro- Redirection-Paketen gekapselt. Fur¨ den Verbindungsauf- tokollierung des Impacts verschiedenster USB-Payload. bau und die USB-Redirection-Kommunikation ist in diesem Daruber¨ hinaus sollte das Framework moglichst¨ erweiterbar ms_s3cFall die Software ”usbredirserver” undSergej dieSchumilo QEMU - schumilo@fh-muenster eigene .de sein. Die folgenden Losungsans¨ atze¨ ermoglicht¨ erst die Schnittstelle zustandig.¨ Da das USB-Redirection-Protokoll Implementierung eines USB-Fuzzing-Frameworks, welche relativ einfach ist, lasst¨ sich mit geringe Aufwand diese alle von diesen Anforderungen erfullt.¨ Verbindung auch per Man-In-The-Middle abhoren¨ bzw. gezielt verandern.¨ Dies erlaubt bereits USB-Fuzzing 2.1. Host-Virtualisierung ohne grundlegendes Verstandnis¨ des USB-Protokolls. Al- ternativ lasst¨ sich auch ein USB-Gerat¨ mit Hilfe des USB-Redirection-Protokolls emulieren und somit auch Das Framework setzt fur¨ die Realisierung der gegebenen stateful-USB-fuzzing ermoglichen,¨ ohne dafur¨ jedoch ein Anforderungen auf die im Linux-Kernel integrierte Virtual- physikalisch verfugbares¨ und angeschlossenene USB-Gerat¨ isierungsinfrastruktur KVM, um damit die anzugreifenden vorraus zusetzen. Systeme zu virtualisieren. Da KVM nur den Hypervisior darstellt, wird dieser in Kombination mit QEMU, welches Vorteile in der Verwendung des USB-Redirection- dazu dient weitere benotigte¨ Gerate¨ zu emulieren, zu einer Protokoll sind außerdem die fehlende Limitierung der vollstandigen¨ Virtualisierungslosung.¨ Da diese Virtual- verfugbaren¨ Endpoints, sprich es konnten¨ theoretisch alle isierungslosung,¨ im Gegensatz zu anderen kommerziellen 31 Endpoints verwendet werden. Außerdem unterstutzt¨ das Losungen,¨ unter verschiedenen GPL-Versionen lizensiert USB-Redirection-Protokoll auch das USB 3.0 Protokoll. ist, bietet sie uns damit großtm¨ ogliche¨ Flexibilitat¨ in dieser Verwendung und der Erweiterbarkeit. 2.3. Harddrive-Virtualisierung Die Nutzung von QEMU impliziert fur¨ die virtuellen 2.2. USB-Virtualisierung Maschinen die Verwendung von Image-Dateien oder reellen Partitionen, welche fur¨ die Bereitstellung des Spe- Als USB-Schnittstelle wird das sogenannten USB- icherplatzes der virtuellen Festplatten benotigt¨ werden. Redirecton-Protokoll [5] verwendet, welches zum Zeit- Hierzu verwenden wir Image-Files im QCOW2-Format punkt dieses Papers nur in Kombination mit dem QEMU (QEMU Copy-On-Write). Ein Aufbau fur¨ eine virtuelle eigenen Interface nutzbar ist. Das USB-Redirection- Maschine sieht in der trivialsten Form wie folgt aus: Proktoll ermoglicht¨ die Ubertragung¨ von USB-Traffic in QCOW2-Image Form von TCP, UDP oder Unix-Sockets und dient ur- QEMU load (ca. 2GB) + Snapshot sprunglich¨ der Bereitstellung von entfernten USB-Gerate¨ in virtuellen Umgebungen. Figure 2. Trivialer Aufbau f ¨urQEMU Fur¨ die Bereitstellung eines entfernten USB-Gerates,¨ di- ent die Software ”usbredirserver”, welche Teil der USB- Alternativ lasst¨ sich im QCOW2-Image noch ein Snap- Redirection-Suite ist und es erlaubt ein eingestecktes USB- shot hinterlegen, damit beim Laden der VM der gesicherte Gerat¨ im Netzwerk bereit zustellen. Hierfur¨ wird das Zustand sofort wiederhergestellt wird und man sich zum USB-Gerat¨ per libusb auf dem Host-System an eine eige- Beispiel das Hochfahren des Betriebssystem ersparen nen Treiber-Implementierung gebunden und alle Anfragen kann. Das QCOW2-Image wachst¨ in diesem Fall um ca. des Guest-System werden an die Treiber-Implementierung der Große¨ des Arbeitsspeichers, sowie den Festplatten- durch gereicht. Dadurch entsteht eine logische Verbindung Anderungen.¨ zwischen dem Guest-System und dem USB-Gerat.¨ 2 10 QEMU usbredir- interface VM QEMU monitoring console - monitoring process start - load snapshot - recognition for image corruption QEMU- Contoller ms_s3c Sergej Schumilo - [email protected] 11 QEMU USB-Emulator USB-Traffic usbredir- interface VM traffic fuzzing QEMU monitoring console - monitoring process start descriptor fuzzing Fuzzer-Modul - load snapshot - recognition for image corruption Read or generate Device-Descriptor QEMU- Contoller ms_s3c Sergej Schumilo - [email protected] 12 QEMU USB-Emulator USB-Traffic usbredir- VM monitoring interface per serial port traffic fuzzing Monitoring- QEMU monitoring console Modul - monitoring process start descriptor fuzzing Fuzzer-Modul - load snapshot - recognition for image corruption Read or generate Device-Descriptor QEMU- Contoller write to logfile ms_s3c Sergej Schumilo - [email protected] 13 instance #3 instance #2 instance #1 QEMU USB-Emulator USB-Traffic usbredir- VM monitoring interface per serial port traffic fuzzing Monitoring- QEMU monitoring console Modul - monitoring process start descriptorfuzzing Fuzzer-Modul - load snapshot - recognition for image corruption Read or generate Device-Descriptor read testcase QEMU- Contoller write to logfile testcase- pooltestcase- pooltestcase- pool Testcase-Distributor ms_s3c Sergej Schumilo - [email protected] 14 vUSBf reload mode start QEMU load snapshot send payload write impact to logfile ms_s3c Sergej Schumilo - [email protected] 15 vUSBf Non-reload mode start QEMU load snapshot send payload yes no issue write impact to detected? logfile ms_s3c Sergej Schumilo - [email protected] 16 Reproducibility • test cases are related to unique IDs • file export for a sequence of test cases • offers high reproducibility in combination with snapshots ms_s3c Sergej Schumilo - [email protected] 17 vUSBf Performance reload mode non reload mode 0,5 vUSBf (1 process) 0,5 50 vUSBf Multiprocessing 120 150 vUSBf Clustering 320 0 100 200 300 400 tests per seconds ms_s3c Sergej Schumilo - [email protected] 18 vUSBf Performance runtime for 1 million tests: reload mode non reload mode 23d 4h vUSBf (1 process) 23d 4h 5h 30m vUSBf Multiprocessing 2h 18m 1h 48m vUSBf Clustering 51m 0 1,6547619047619 3,30952380952381 ms_s3c Sergej Schumilo - [email protected] 19 Demo ms_s3c Sergej Schumilo - [email protected] 20 Challenges • Linux monitoring is simple! • other OS? • investigation / fixing of bugs • additional specific USB-emulators ms_s3c Sergej Schumilo - [email protected] BUG: Bad rss-counter state mm:ffff880002a13c00 idx:1 val:2 BUG: Bad rss-counter state mm:ffff8800057e4a80 idx:1 val:2 21 BUG: Bad rss-counter state mm:ffff8800057e5180 idx:1 val:2 BUG: Bad rss-counter state mm:ffff8800057e5880 idx:1 val:2 BUG: Bad rss-counter state mm:ffff880006390e00 idx:1 val:2 BUG: Bad rss-counter state mm:ffff880006391500 idx:1 val:2 BUG: Bad rss-counter state mm:ffff880006391c00 idx:1 val:2 BUG: Bad rss-counter state mm:ffff880007d0c700 idx:1 val:2 BUG: unable to handle kernel NULL pointer dereference at 0000000000000002 Conclusion: BUG: unable to handle kernel NULL pointer dereference at 0000000000000003 BUG: unable to handle kernel NULL pointer dereference at 0000000000000004 BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 BUG: unable to handle kernel NULL pointer dereference at 000000000000000f BUG: unable to handle kernel NULL pointer dereference at 0000000000000042 BUG: unable to handle kernel NULL pointer dereference at 0000000000000043 BUG: unable to handle kernel NULL pointer dereference at 0000000000000044 BUG: unable to handle kernel NULL pointer dereference at 0000000000000046 BUG: unable to handle kernel NULL pointer dereference at 0000000000000048 BUG: unable to handle kernel NULL pointer dereference at 0000000000000058 vast amount of bugs :-)! BUG: unable to handle kernel NULL pointer dereference at 0000000000000068 BUG: unable to handle kernel NULL pointer dereference at 0000000000000070 BUG: unable to handle kernel NULL pointer dereference at 0000000000000098 ! BUG: unable to handle kernel

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    22 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us