exploitation over hdmi-cec - paper.seebug.org conf... · samsung blu-ray player (mips) targeted...

53
HIGH-DEF FUZZING EXPLOITATION OVER HDMI-CEC name = "Joshua Smith" job = "Senior Security Researcher" job += "Zero Day Initiative" irc = "kernelsmith" twit = "@kernelsmith"

Upload: others

Post on 28-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

HIGH-DEF FUZZINGEXPLOITATION OVER HDMI-CEC

name = "Joshua Smith" job = "Senior Security Researcher" job += "Zero Day Initiative" irc = "kernelsmith" twit = "@kernelsmith"

Page 2: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Previous ResearchHDMI – Hacking Displays Made Interesting

Andy DavisBlackHat EU 2012

Page 3: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

What is HDMI?High Def Multimedia Interface

HDMI is a specificationImplemented as Cables & ConnectorsSuccessor to DVIHas Quite a Few Features

Page 4: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

What is CEC?Consumer Electronics ControlHDMI featureAllows user to command & control up to 15 devicesCan relay commands from remotesIt is what automatically changes your TV inputHas some other intriguing features...

Page 5: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Why?Wanted to research an area that was relatively untouchedI do not have mad hardware skillsI like RISC targets & assemblyAnother attack vector for mobile devices via:

Mobile High-Definition Link (MHL) ~ Samsung & HTCSlimport ~ LG, Google Nexus, Blackberry

My son is completely obsessed with cords/wires, espHDMI

Page 6: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Specs & FeaturesHistory

1.0 (Dec 2002), 1.1 (May 2004), 1.2 (Aug 2005)Boring stuff

1.2a (Dec 2005)Fully specified Consumer Electronics ControlThis is the good stuff, for vulnerabilities anyway

Page 7: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Specs & FeaturesHistory Continued

1.3 - 1.3c (Jun 2006 through Aug 2008)Whizz-bang A/V improvements & new connectors

1.4 (May 2009)Most widely deployed and availableFeatures++: 4k, HEC, ARC, 3D, micro connectorSome that might interest us (next)

2.0 (Sep 2013)New hotness: 4K video @60fps, Dual View, 3D++, CEC++

Page 8: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Specs & FeaturesInteresting 1.4 Features

HEC (HDMI Ethernet Connection)Sounds tasty100Mb/sEnables traditional networking w/HDMI

ARC (Audio Return Channel)

Page 9: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC Details1-wire bidirectional serial busSlow: 500Mb/sUses AV.link protocol to perform remote control functionsFor HDMI:

CEC wiring is mandatoryCEC functionality (software mainly) is optional

Page 10: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC's GoalsSimplify system integrationCommon protocolExtendable (vendor-specific commands)Commands are grouped together into Feature Sets

For example, one-touch play (OTP)TV on, text view on (optional), set active source

Page 11: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

NotableImplementations

Commercial industry uses various trade namesAnynet+ (Samsung), Aquos Link (Sharp), BRAVIALink/Sync (Sony)SimpLink (LG), VIERA Link (Panasonic), EasyLink(Philips), etc

Open SourcelibCEC (dual commercial license)Android HDMI-CEC

Page 12: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Android HDMI-CEC

Not-HDMI CECSlimportMobile High-Definition Link (MHL)

Notes: TODO: add tidbits about Slimport and MHL, likeoverloading the connector etc

Page 13: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC AddressingPHYSICAL

N.N.N.N where 0x0<=N<=0xFLike F.A.4.0Obtained on hot-plug from EDIDThe root display is always 0.0.0.0If attached to 1st input on root: 1.0.0.0Required as CEC has a notion of switching

Page 14: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC AddressingLOGICAL

L where 0x0<=L<=0xFRoot display is always 0By product typeNegotiated w/other devicesExample: first STB in system is always 3Non-CEC devices only have physical addr

Page 15: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Logical AddressesAddress Device Address Device

0 TV 8 Playback Dev 2

1 Rec. Device 1 9 Rec Device 3

2 Rec. Device 2 10 Tuner 4

3 Tuner 1 11 Playback Dev 3

4 Playback Dev 1 12 Reserved

5 Audio System 13 Reserved

6 Tuner 2 14 Free Use

7 Tuner 3 15 Unreg/Broadcast

Page 16: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC Protocol

Page 17: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Blocks & FramesBlocks

Each block is 10 bitsMax of 16 blocks (14 purely data blocks)

Frames(1bit) Start bit(10bits) Header block(10bits) Opcode block(10bits) Optional data block(s)

Page 18: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Header BlockSource Dest EoM Ack

3 2 1 0 3 2 1 0 E A(4bits) Logical address of source(4bits) Logical address of dest(2bits) Control bits (EoM & Ack)Example: 0100:0000:0:0 = Src 4, Dest 0

Page 19: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Data BlockData EoM Ack

7 6 5 4 3 2 1 0 E A(8bits) Data (Big-endian/MSB first)(2bits) Control bits (EoM & Ack)Example: 01000001:1:0 = "A"

Page 20: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC ProtocolPinging and Polling

The "Ping"EOM bit in header is set to 1Used to poll for devices etc (fuzz monitor?)

Source & dest addresses will be differentAlso used for allocating Logical Addresses

Source & dest addresses are the same

Page 21: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC ProtocolAdditional Info

All numbers > 1 byte are transmitted as big-endianAll bit sequences are sent MSB firstMessages can be directly addressed, broadcast, or bothShould ignore a message coming from address 15, unless:

Message invokes a broadcast responseMessage has been sent by a CEC SwitchThe message is Standby

Page 22: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC ProtocolThe Long and Short of It...

10:64:44:65:66:43:6F:6E:20:32:33

1F:82:10.00

SD:OP:41:42:43:44:45:46

Page 23: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC ProtocolExample Messages

Name ID Feature Set Addr Parameters

Poll Sys Info Direct

Get CEC Ver 9F Sys Info Direct

CEC Version 9E Sys Info Direct CEC Version

Set OSD Name 47 OSD Xfer Direct OSD Name

Set OSD Str 64 OSD Disp Direct DispCtrl,Str

Active Source 82 OTP, RC Bcast Phys Addr

Page 24: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

CEC ProtocolTransmission (Flow) Control

3 mechanisms to provide reliable frame transfer1. Frame re-transmissions (1 to 5)2. Flow control3. Frame validation (ignore msgs w/wrong #args)A message is assumed correctly received when:

It has been transmitted and acknowledgedA message is assumed to have been acted upon when:

Sender does not receive Feature Abort w/in 1sec

Page 25: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Common SequencesAddressing

1. Discovery (poll etc) of new physical address2. Allocation (of logical address)3. Report by broadcasting ReportPhysicalAddressBecome active source

1. Broadcast an ActiveSource to declare intention2. Presently active source shall act appropriately

Page 26: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Feature SetsOne-Touch Play (OTP)

ImageViewOn* 40:04 (assumes playback dev 1)TextViewOn 4F:0D (optional, remove displayed menus)ActiveSource 4F:82 (assumes playback dev 1)

Page 27: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Attack VectorsHDMI Ethernet Channel (HEC)Network connectivity to things thought un-networkedGreat place to hideTargetable devices

TVs, BluRays, receivers, "TV Sticks", game consoles?Mobile phones & tablets

Devices implementing MHL/SlimportKnown popular mobile devices that implement MHL

Page 28: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Attack SurfaceCEC commandsHEC commandsCDC commands

Page 29: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Finding VulnsApproaches

Identify "at-risk" messages & fuzzSource Code Analysis

Hard to come by except libCEC & AndroidReverse Engineering

Can be hard to get all the firmwarezExpect different architectures

MIPS, ARM, ARC etcMIPS is generally most popular so far

Page 30: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Interesting MessagesString operations

Set OSD Name (0x47)Preferred name for use in any OSD (menus)

Set OSD String (0x64)Text string to the TV for display

Set Timer Program Title (0x67)Set the name of a program associated w/a timer

Vendor-specific MessagesBecause who knows what they might do

Page 31: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

In Order to FuzzWe Need to Answer Some Questions

How can we send arbitrary CEC messages?How can we detect if a crash occurred?

Page 32: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Sending MessagesHardware

~0 {lap,desk}tops with HDMI-CECMany have HDMI, none have CEC

AdaptersPulse-Eight USB-HDMIRainShadow HDMI-CEC to USB Bridge

Raspberry PiRPi & P8 adapter both use libCEC :)

Page 33: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Sending MessagesSoftware

Pulse-Eight driver is open source (libCEC)Dual-licensed actually (GPLv2/Commercial)Python SWIG-based bindingsSupports a handful of devices

Page 34: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Fuzzing CEClibCEC

Can send CEC messages with:Raspberry Pi + libCECP8 USB-HDMI adapter + libCEC

But can we really send arbitrary CEC messages?lib.Transmit(CommandFromString("10:82:41:41:41:41:41:41:41:41:41"))

YES. It would appear at least.

To know for sure, had to ensure libCEC was not validating.

Page 35: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Demo

Page 36: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Fuzzing ProcessIt has been with Python + RainbowTech serial API

I actually did not know this until late in the researchRainbowTech device has a nice simple serial APINot much complex functionalityI had already started down the path below

libCEC + Python since pyCecClient is already a thingCan use the P8 USB adapter and/or Raspberry Pi(s)May port to Ruby since SWIG & Ruby++

done

Page 37: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Fuzzing ProcessMajor Steps

ID Target and Inputs

Generate Fuzzed Data

Execute Fuzzed Data

Monitor for Exceptions

Determine Exploitability

Fuzzing: Brute Force Vulnerability Discovery (Sutton, Michael; Greene, Adam; Amini, Pedram)

Page 38: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Generate Fuzzed DataStarted with "long" strings and string-based messagesFormat stringsParameter abuseVendor-specific messagesSimple bit-flippingAdopted some from Davis work

Page 39: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Execute Fuzzed1. Poll device2. Send message

Page 40: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Monitor for Exceptions1. Check for ack if applicable2. Poll again3. If debug, use that4. If shell, check if service/app still running5. If TV, will probably notice crash, fun, hard to automate6. If exception, record msg & state & debug details if avail

Page 41: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

DETERMINE EXPLOITABILITYThis is kind of an adventure unless debugSpecific to each device

Page 42: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

FuzzingComplications

Getting Hold of DevicesThey are around you however, just need to lookCan also emulate w/QEMU + firmware

Speed500 bits/sNot much we can do about thatFuzz multiple devices simultaneouslyRE targets to focus the fuzz

Page 43: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

FuzzingComplications Continued

DebuggingNeed to get access to the device

Probably no debuggerOften painful to compile one for it

Collect DataDeduplicateRepro

Page 44: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

TargetsHome Theater Devices

Samsung Blu-ray Player (MIPS)Targeted because already have shell(Thx Ricky Lawshae)Local shell to get on & study device

Philips Blu-ray PlayerSamsung TVPanasonic TVChromecastAmazon Fire TV Stick

Page 45: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

TargetsMobile devices

Kindle FireGalaxy S5 (S6 dropped MHL)Galaxy NoteChromebook

Page 46: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

FuzzingResults

Page 47: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Vulns DiscoveredDemos & Videos

Panasonic TVSamsung Blu-ray Player

Page 48: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

app_player

Page 49: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

ExploitationBackground InfoBarriersSamsung TV

Page 50: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Post exploitationEnable HECEnable LAN

Attack LAN services if necEnable higher speed exfil etc

Wake-Over-CECBeachhead for attacking other devicesHiding

Page 51: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

Future WorkExplore Attack Surface of

HDMI: 3D, Audio Return Channel, more w/HECFeature adds to CEC

Moar devicesEmulationUndo bad Python

Page 52: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

ConclusionBecoming more and more pervasive and invasiveOld vuln types are new againHard, sometimes impossible, to upgrade, maintain,configureRisk = Vulnerabilty x Exposure x Impact

The vulns are thereExposure is growingImpact is probably highest for your privacy

What next? How do we fix or mitigate this?

Page 53: EXPLOITATION OVER HDMI-CEC - paper.seebug.org Conf... · Samsung Blu-ray Player (MIPS) Targeted because already have shell (Thx Ricky Lawshae) Local shell to get on & study device

References

Simplified Wrapper & Interface Generator Reveal.js

blackhat.com/bh-eu-12-Davis-HDMIgithub.com/Pulse-Eight/libcechdmi.orgcec-o-matic.com/p8-USB-HDMI-adapter

swig.orggithub.com/hakimel/reveal.js