read it twice! - usenix... tocttou.so tocttou.bmp 1

41
Read It Twice! A mass-storage-based TOCTTOU attack Collin Mulliner and Benjamin Mich´ ele Security in Telecommunications Technische Universit¨ at Berlin and Telekom Innovation Laboratories Germany {collin,ben}@sec.t-labs.tu-berlin.de August 7, 2012 Collin Mulliner and Ben Mich´ ele (SECT) Read It Twice! August 7, 2012 1 / 27

Upload: others

Post on 26-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Read It Twice!A mass-storage-based TOCTTOU attack

Collin Mulliner and Benjamin Michele

Security in TelecommunicationsTechnische Universitat Berlin and Telekom Innovation Laboratories

Germanycollin,[email protected]

August 7, 2012

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 1 / 27

Page 2: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

What is this talk about?

Compromising CE devices via emulated USB mass-storage

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 2 / 27

Page 3: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

What is this talk about?

Compromising CE devices via emulated USB mass-storage

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 2 / 27

Page 4: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Our contribution

Mass-storage-based time-of-check-to-time-of-use (TOCTTOU)attack: Read It Twice (RIT)

Mass-storage device that changes its content between check andexecute/install phase of a connected hostCircumvention of block and file system caches

Black box analysis of file accesses to mass-storage devices

Method and toolMaps block accesses to file accesses at run time

POC against a Samsung TV, using our RIT analysis and attack tool

Used in this talk to demonstrate the general attack and tool

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 3 / 27

Page 5: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Our contribution

Mass-storage-based time-of-check-to-time-of-use (TOCTTOU)attack: Read It Twice (RIT)

Mass-storage device that changes its content between check andexecute/install phase of a connected hostCircumvention of block and file system caches

Black box analysis of file accesses to mass-storage devices

Method and toolMaps block accesses to file accesses at run time

POC against a Samsung TV, using our RIT analysis and attack tool

Used in this talk to demonstrate the general attack and tool

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 3 / 27

Page 6: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Our contribution

Mass-storage-based time-of-check-to-time-of-use (TOCTTOU)attack: Read It Twice (RIT)

Mass-storage device that changes its content between check andexecute/install phase of a connected hostCircumvention of block and file system caches

Black box analysis of file accesses to mass-storage devices

Method and toolMaps block accesses to file accesses at run time

POC against a Samsung TV, using our RIT analysis and attack tool

Used in this talk to demonstrate the general attack and tool

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 3 / 27

Page 7: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Software installation: Program flow

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 4 / 27

Page 8: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Software installation: Program flow and attack

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 4 / 27

Page 9: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

POC: Shell on Samsung TV

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 5 / 27

Page 10: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Modern TV features

USB interface for mass-storage

Watch moviesInstall appsUpgrade firmware

CI+ card slot for pay TV

Network and Internet connection

Integrated camera and microphone

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 6 / 27

Page 11: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Modern TV features

USB interface for mass-storage

Watch moviesInstall appsUpgrade firmware

CI+ card slot for pay TV

Network and Internet connection

Integrated camera and microphone

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 6 / 27

Page 12: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Conflict of interest

User

Enable missing features

Fix bugs

Customize product

Record pay TV

Vendor

Protect intellectual property

Avoid warranty issues

Adhere to the specifications

Protect multimedia content

Locked-down devices

User access disabled by vendor . . .

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 7 / 27

Page 13: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Conflict of interest

User

Enable missing features

Fix bugs

Customize product

Record pay TV

Vendor

Protect intellectual property

Avoid warranty issues

Adhere to the specifications

Protect multimedia content

Locked-down devices

User access disabled by vendor . . .

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 7 / 27

Page 14: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Conflict of interest

User

Enable missing features

Fix bugs

Customize product

Record pay TV

Vendor

Protect intellectual property

Avoid warranty issues

Adhere to the specifications

Protect multimedia content

Locked-down devices

User access disabled by vendor . . .

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 7 / 27

Page 15: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Samsung LExxB650: Content library / app launcher

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 8 / 27

Page 16: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Samsung LExxB650: Two types of apps

clmeta.dat

XML file

Contains app category

Evaluated at install time

Evaluated at load time

Unprivileged apps

Category Wellness, . . .

Macromedia Flash-based

No signature required

Privileged apps

Category Game

Shared objects

Native code

Run as root

Require valid signature forinstallation, but not at run time

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 9 / 27

Page 17: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Samsung LExxB650: Two types of apps

clmeta.dat

XML file

Contains app category

Evaluated at install time

Evaluated at load time

Unprivileged apps

Category Wellness, . . .

Macromedia Flash-based

No signature required

Privileged apps

Category Game

Shared objects

Native code

Run as root

Require valid signature forinstallation, but not at run time

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 9 / 27

Page 18: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Samsung LExxB650: Two types of apps

clmeta.dat

XML file

Contains app category

Evaluated at install time

Evaluated at load time

Unprivileged apps

Category Wellness, . . .

Macromedia Flash-based

No signature required

Privileged apps

Category Game

Shared objects

Native code

Run as root

Require valid signature forinstallation, but not at run time

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 9 / 27

Page 19: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Samsung LExxB650: Two types of apps

clmeta.dat

XML file

Contains app category

Evaluated at install time

Evaluated at load time

Unprivileged apps

Category Wellness, . . .

Macromedia Flash-based

No signature required

Privileged apps

Category Game

Shared objects

Native code

Run as root

Require valid signature forinstallation, but not at run time

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 9 / 27

Page 20: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

clmeta.dat: Unprivileged app

<?xml version ="1.0" encoding ="utf -8"?>

<contentlibrary >

<contentpack id=" tocttou">

<category >Wellness </category >

<title language_id =" English">tocttou </title >

<startpoint language_id =" English">

tocttou.so </ startpoint >

<thumbnailpath >tocttou.bmp </ thumbnailpath >

<totalsize >1</totalsize >

</contentpack >

</contentlibrary >

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 10 / 27

Page 21: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

clmeta.dat: Privileged app

<?xml version ="1.0" encoding ="utf -8"?>

<contentlibrary >

<contentpack id=" tocttou">

<category >Game </category >

<title language_id =" English">tocttou </title >

<startpoint language_id =" English">

tocttou.so </ startpoint >

<thumbnailpath >tocttou.bmp </ thumbnailpath >

<totalsize >1</totalsize >

</contentpack >

</contentlibrary >

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 11 / 27

Page 22: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

App install: Two apps on USB mass-storage

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 12 / 27

Page 23: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

App install: TV checks all folders for apps

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 13 / 27

Page 24: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

App install: TV offers unprivileged apps

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 14 / 27

Page 25: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

App install: User chooses app

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 15 / 27

Page 26: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

App install: TV copies app folder to internal flash memory

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 16 / 27

Page 27: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

App install: TV copies app folder to internal flash memory

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 16 / 27

Page 28: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Requirements for TOCTTOU attack

USB mass-storage device

Able to change content while connectedClient or OTG USB interface to connect to host

Content change triggered by file accesses

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 17 / 27

Page 29: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Implementation

Gumstix developer board running Linux

USB OTG port

Linux USB stack offers mass-storage emulation via Gadget API

linux/drivers/usb/gadget/file storage.c → g file storage.ko

Modifications

Block and file system access tracking for FAT16/32Switch file system based on file access counters

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 18 / 27

Page 30: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Tool output: Unprivileged app installation

11:18:56 TOCTTOU (DIR)

11:18:56 CLMETA.DAT (471b) [/TOCTTOU]

11:18:56 CLMETA.DAT -> read completed!

11:18:56 CACHE (DIR)

11:18:57 CLMETA.DAT (450b) [/CACHE]

11:18:57 CLMETA.DAT -> read completed!

11:19:29 CACHE.BMP (843758b) [/CACHE]

11:19:29 CACHE.BMP -> read completed!

11:19:29 TOCTTOU.BMP (490734b) [/TOCTTOU]

11:19:29 TOCTTOU.BMP -> read completed!

11:19:52 TOCTTOU.SO (4608b) [/TOCTTOU]

11:19:52 TOCTTOU.SO -> read completed!

→ Directories are scannedfor clmeta.dat files

→ Apps are displayedwith their icon

→ Tocttou app foldercopied to internal memory

TOCTTOU attack would fail/TOCTTOU/clmeta.dat read only once from emulated storage!

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 19 / 27

Page 31: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Tool output: Unprivileged app installation

11:18:56 TOCTTOU (DIR)

11:18:56 CLMETA.DAT (471b) [/TOCTTOU]

11:18:56 CLMETA.DAT -> read completed!

11:18:56 CACHE (DIR)

11:18:57 CLMETA.DAT (450b) [/CACHE]

11:18:57 CLMETA.DAT -> read completed!

11:19:29 CACHE.BMP (843758b) [/CACHE]

11:19:29 CACHE.BMP -> read completed!

11:19:29 TOCTTOU.BMP (490734b) [/TOCTTOU]

11:19:29 TOCTTOU.BMP -> read completed!

11:19:52 TOCTTOU.SO (4608b) [/TOCTTOU]

11:19:52 TOCTTOU.SO -> read completed!

→ Directories are scannedfor clmeta.dat files

→ Apps are displayedwith their icon

→ Tocttou app foldercopied to internal memory

TOCTTOU attack would fail/TOCTTOU/clmeta.dat read only once from emulated storage!

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 19 / 27

Page 32: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Block cache

Problem

TV’s OS caches all block accesses tomass-storage in unused RAM

Replace clmeta.dat in block cache

Force TV to read large file between checkingand copying of clmeta.dat

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 20 / 27

Page 33: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Block cache

Problem

TV’s OS caches all block accesses tomass-storage in unused RAM

Replace clmeta.dat in block cache

Force TV to read large file between checkingand copying of clmeta.dat

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 20 / 27

Page 34: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Candidate files

11:18:56 TOCTTOU (DIR)

11:18:56 CLMETA.DAT (471b) [/ TOCTTOU]

11:18:56 CLMETA.DAT -> read completed! [1/2]

11:18:56 CACHE (DIR)

11:18:57 CLMETA.DAT (450b) [/CACHE]

11:18:57 CLMETA.DAT -> read completed! [2/2] [S!]

11:19:29 CACHE.BMP (843758b) [/CACHE]

11:19:29 CACHE.BMP -> read completed!

11:19:29 TOCTTOU.BMP (490734b) [/ TOCTTOU]

11:19:29 TOCTTOU.BMP -> read completed!

11:19:52 TOCTTOU.SO (4608b) [/ TOCTTOU]

11:19:52 TOCTTOU.SO -> read completed!

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 21 / 27

Page 35: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Candidate files

11:18:56 TOCTTOU (DIR)

11:18:56 CLMETA.DAT (471b) [/ TOCTTOU]

11:18:56 CLMETA.DAT -> read completed! [1/2]

11:18:56 CACHE (DIR)

11:18:57 CLMETA.DAT (450b) [/CACHE]

11:18:57 CLMETA.DAT -> read completed! [2/2] [S!]

11:19:29 CACHE.BMP (843758b) [/CACHE]

11:19:29 CACHE.BMP -> read completed!

11:19:29 TOCTTOU.BMP (490734b) [/ TOCTTOU]

11:19:29 TOCTTOU.BMP -> read completed!

11:19:52 TOCTTOU.SO (4608b) [/ TOCTTOU]

11:19:52 TOCTTOU.SO -> read completed!

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 21 / 27

Page 36: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Output of successful attack

TOCTTOU (DIR)

CLMETA.DAT (471b) [/ TOCTTOU]

CLMETA.DAT -> read completed! [1/2]

CACHE (DIR)

CLMETA.DAT (272630223b) [/CACHE]

CLMETA.DAT -> read completed! [2/2] [file system switched !]

CACHE.BMP (843758b) [/ CACHE]

CACHE.BMP -> read completed!

TOCTTOU (DIR)

TOCTTOU (DIR)

TOCTTOU.BMP (490734b) [/ TOCTTOU]

TOCTTOU.BMP -> read completed!

TOCTTOU.SO (4608b) [/ TOCTTOU]

TOCTTOU.SO -> read completed!

CLMETA.DAT (471b) [/ TOCTTOU]

CLMETA.DAT -> read completed! [3/2]

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 22 / 27

Page 37: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

TV’s Wellness apps after successful attack

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 23 / 27

Page 38: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

POC: Summary

Execution of own native code on TV

Present unprivileged app to TV

Elevate privileges between check and install

Execute app with full privileges, i.e., root user

Start telnet daemon

Disable firmware upgrade signature check→ Modify firmware

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 24 / 27

Page 39: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Countermeasures

Copy to internal trusted memory before check and install/execute

Low-cost embedded devicesSufficient free memory available?

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 25 / 27

Page 40: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Future work

Further CE devices

App install codeFirmware upgrade process

Further mass-storage devices

SD cardsHard disks

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 26 / 27

Page 41: Read It Twice! - USENIX... tocttou.so tocttou.bmp 1

Questions?

fgsect.de

collin,[email protected]

Collin Mulliner and Ben Michele (SECT) Read It Twice! August 7, 2012 27 / 27