start	end	text
0	6600	Hello, I'm Hyejin and thank you for coming here. The topic I will talk about today is
6600	18720	HackDMI, Pwning, HDMI for fun and profit. Yes. First of all, my name is Hyejin and I am a
18720	24240	vulnerability assessment training mentee of B.O.B. which is the next generation cyber
24240	32500	security leader training program in Korea. And his name, his name is Jung Eunjin and who is
32500	41660	sitting down there. And he is working as a researcher at a company named Theory and he is
41660	51540	mentor at B.O.B. We are both members of the team Shin Ki-ha-jin and actually I was a mentee
51540	58960	and he was a mentor. We worked on the topic of vulnerability assessment for HDMI based
58960	70700	embedded device at B.O.B. Our team is made up of two mentors, one PL and five mentees. The
70700	77900	table of contents is as follows. First, I'd like to give you a quick introduction about previous
77900	86260	talk and one day vulnerabilities about HDMI. And after that, I'm going to talk about the CEC and
86260	93660	DDC protocols that we regard as attack vectors. Finally, I'd like to introduce you to each
93660	103110	protocol folder that we've made and tell you about the result. This is the previous talk about
103110	111810	HDMI. Hacking display made interesting at Bracket Europe and what the ATC at 44con and high
112010	122430	def fuzzing at Defcon. This is the one day of the HDMI and it was the vulnerabilities of memory
122430	133280	corruption type that occurred at CEC and DDC protocols. Now, let's talk about the HDMI
133280	140940	protocols. Here, I will give you a brief description of the each protocol and the knowledge
140940	149180	required to transmit the message or command that each protocol use. If you listen to this part,
149180	160350	you will probably be able to send the message to your device that support HDMI. HDMI is
160350	166970	provided for transmitting digital television audio-visual signals from DVD players,
166970	175090	set-top box, and other audio-visual source to the television sets and projectors or other
175090	184170	video displays. Maybe even without this explanation, you already used HDMI to connect your
184170	195450	laptop to a TV or a beam projector. And also I connected my laptop with HDMI today. And HDMI
195450	208350	has four separate channels. It is TMDS, DDC, CEC, and HEAC. At first, looking at the TMDS part of
208350	217070	the figure, you can see the video and the audio data on both the input and the output part. TMDS
217070	227230	is used to carry audio and video data. The DDC channel is used by an HDMI source to determine the
227230	237210	capabilities or characteristics of the sink by the- by reading the EEDID data structure. HDMI
237210	244930	source are expected to read the sink EEDID and to deliver the audio and video formats that are
244930	253570	supported by the sink. In addition, HDMI sink are expected to detect info frames and to process
253570	263190	the received audio and video data appropriately. The next one is CEC. CEC channel is
263190	270610	optionally used for a higher level user functions such as automatic setup task or task
270610	280410	associated with the infrared remote control users. The last one is the HEAC, which is the
280410	288190	optionally used as a high-speed bidirectional data channel and stands for HDMI Ethernet and
288190	300440	Audio Return Channel. The four protocols mentioned above are mapped from the actual HDMI pins as
300440	312140	follows. TMDS is from 1 to 12, which is marked yellow. And pin 13 is the CEC and pin 14 is the
312140	324500	utility line used by the HEAC. 15 and 16 are SCL, SDA, and 17, 18, and 19 are internal ground,
324500	334480	VCC, and HPD. Here we were interested in functions such as carry controls, status, and data
334480	341760	information, rather than the video data transmission. In addition, the protocol supports the
341760	352460	both directions. So today we are going to talk about the CEC and DDC protocols. The first one is
352460	361600	CEC. CEC stands for Consumer Electronics Control. You can connect your laptop or smartphone to
361600	369280	your TV using HDMI. Of course it's possible to connect multiple devices as shown in the picture
369680	379640	if you have multiple HDMI cables. And you may want to control each devices. For example, you can
379640	388340	adjust the volume of the home theater or changing the TV channel. The CEC protocol allows you to
388340	402130	control each devices with a single remote control. CEC is a protocol that provides high level
402130	409850	control functions between all of the various audio visual products in a user's environment. It
409850	416590	provides a number of features designed to enhance the functionality of devices within an HDMI
416590	425770	system. Because CEC provides functions in the user's environment, each manufacturer has a
425770	433770	different brand name. So maybe any net plus or easy link, easy sync, rather than the CEC can be
433770	443880	more familiar. And in HDMI, there are two types of the address. Physical address and logical
443880	455060	address. And the address used by the CEC message is the logical address. However, CEC is a
455060	462340	protocol based on a bus system, so therefore it cannot learn a certain physical connectivity of
462340	472620	the network. So it uses the DDC protocol to locate physical addresses to device in the network.
473880	481900	All CEC devices therefore have both physical and logical address, whereas non-CEC devices only
481900	491880	has the physical address. The physical address is four digit long. It seems like the IPv4
491880	501160	address. And it has a five device deep hierarchy. For example, the root device TB has 0 0 0 0
501160	511340	and the connected device on TB have 1 0 0 0 and 2 0 0 0. In addition, the DVD and STB connected
511340	521760	to the amplifier become 2 1 0 0 and 2 2 0 0. When a physical address is allocated like this, then
521760	533360	it allocates a logical address. Logical address defines the device type. For example, TB is
533360	543360	0, a recording device is 1 2 or 9, depending on the device type. Logical address is allocated
543360	553380	through the polling message. First, text the first address and send the polling message. If it is a
553380	561580	recording device, it sends a polling message to the first of 1 2 and 9. Actually, it will be 1.
561580	569880	And if polling is acknowledged, it takes the next address. And if not, it stops the
569880	580860	procedure and retains that address. That is, it's logical address becomes 1. The CEC message
580860	588880	frame has this structure. The first is the start bit, which is followed by the header block and
588880	598120	the data blocks. And it is a special bit indicating the start. The header block and the data
598120	606560	blocks are each composed of 10 bits, which is consists of 8 bits of information bits and 2 bits of
606560	615100	the control bits. And the data block is optional block. Information bits and control bits are
615100	626310	described in detail in the next slide. First is the header block. The information bits in the
626310	634050	header block contain the logical address. The addresses of the initiator and destination are each
634050	643490	4 bits. And the control bit has the same format for both the header block and the data blocks. The
643490	654050	control bit includes the EOM bit and the ACK bit. The EOM bit stands for end of message. If the
654050	661290	current block is followed by one or more blocks, it becomes 0. And if the current block is the
661290	669470	last one, it becomes 1. The ACK bit stands for acknowledge, which contains the value of the
669470	678350	acknowledge of the data or header blocks. The data block also consists of information bits and
678350	686990	control bits. The header block is essential but the data block is an optional block. The data
686990	693370	block has data block 1 and data block 2, where data block 1 contains the OP code in the
693370	702630	information bits and data block 2 contains the operand. The operand has a dependency on OP
702630	712470	code. If the OP code is 32, which corresponds to the set menu language, the operand will contain
712470	719270	the language what you want to set. Data block 1 is one block and data block 2 can be the
719270	728710	multiple blocks depending on the OP code value. However, the maximum message size is 16 blocks.
729030	735270	That is the message with the maximum length is one block of header and one block of the data
735270	747860	block 1 and 14 blocks of the data block 2. The second protocol is TDC. TDC stands for display
747860	756660	data channel. And it is used by the HDMI source to read the sync EEDID in order to discover the
756660	764760	sync configuration and capabilities. More easily illustrated, when you connect the TV and the
764760	776600	laptop with the HDMI, the sync TV sends the EEDID data to the source laptop. So what data does
776600	786160	TDC send? It's called EEDID, extended display identification data. The EEDID is a metadata
786160	792720	format for display devices to describe their capabilities to a video source such as
792720	804860	graphics card or set up box. This format is defined by a standard published by the VESA. However,
804860	814360	EEDID is for PC monitors. An EEDID is an extension of the EEDID used to illustrate more advanced
814360	824040	features. For example, PC monitors generally does not support audio, so a traditional EEDID
824040	833400	structure would not account for this, whereas an EEDID would. Therefore, it sends the EEDID data.
833580	845140	The EEDID data consists of the EEDID 1.3 and CA extension. And they have the following
845140	853440	structures. Because data sent by the fuzzer is also this EEDID data, so we need to know a little
853440	861720	bit about the data structure. EEDID 1.3 includes information such as horizontal size, vertical
861720	868860	size, and color characteristics. And there is also an extension flag, which means that extension
868860	879960	data follows the EEDID structure. And if you- if you are not sure what the EEDID is yet, turn on
879960	888620	your laptop. If your laptop is now connected to a TV or a monitor with HDMI, you can probably
888620	898160	find EEDID data in your laptop. On Windows, it is stored in the registry, and on Ubuntu, it can
898160	910160	be found in the path sys class DRM, and on Mac OS, you can check it through the IO registry. The
910160	921000	HDMI transmits EEDID data over the I2C bus. As you know, I2C is a serial computer bus. And it is
921000	928080	widely used for attaching lower speed peripheral ICs to processors and microcontrollers in
928080	936120	short distance in troubled communication. I2C uses only two bidirectional open collector lines,
936120	946240	SDA and SDL, put up with registers. Typical voltages used are 5 or 3.3, although systems with
946240	957640	other voltages are permitted. We use Arduino to transmit the EEDID data directly. You can use
957640	965260	other things, but you can easily use I2C slave mode with Arduino compared to the Raspberry Pi.
965960	972080	You can connect the register and the wire to each pin as shown in the picture. The wires
972080	982180	connected to the breadboard is in turn are SDL, SDA, ground, VCC, and HPD. And each line
982180	989600	is connected to the pin that is mapped in the HDMI. With this connection, the hardware
989600	1000830	preparation is finished. So far, we have looked at a brief description of the CEC and the DDC
1000830	1013130	protocols and its message. Now, I will use them to create a further. The first is CEC. Any
1013130	1020710	device that supports CEC can be the target device. For example, smart TV, beam projector,
1020710	1028430	set-top box, blu-ray, smart phone, and game controllers, and so on. In the case of a
1028430	1034710	smart phone, it is highly likely to purchase an additional adapter. Make sure that the adapter
1034710	1043630	also supports the CEC. And for CEC protocol, whether to support CEC rather than the type of
1043630	1054980	the device is a more important factor to determining the target. For the CEC further, all you need
1054980	1067960	is a USB CEC adapter and a HDMI cable. We will use the Pi serial for serial communication. Now,
1067960	1074640	it's time to send the CEC message directly to the device. There is a USB CEC adapter
1074640	1083760	communication library which is called LibCEC. It can be found in the GitHub. And if you have a
1083760	1091260	USB CEC adapter created by Persec, you can send the CEC message. Of course, other adapters
1091260	1097660	are also supported and if you are having trouble to buy a new adapter, you can use the Raspberry
1097660	1109710	Pi. With LibCEC, you can send the CEC message as above. But this library is so well made that it
1109710	1117150	can be drop our faulting data. So, we will not use this library when faulting. Since the
1117150	1123610	adapter shown above is the USB CEC adapter, data can be transferred via the serial
1123610	1132990	communication. Of course, you can use Pi serial. You can send a message with just three lines of
1132990	1144140	the code as above. This is a command to power off the setup box. Let's first look at the code that
1144140	1152300	sends messages to the CEC adapter without using the LibCEC library. Before that, you've probably
1152300	1161460	seen this picture. When data is transferred using the adapter, one block is represented by four
1161460	1170260	bytes. More precisely, the information bits in a block. This works for both the header block and
1170260	1178980	the data blocks. The four bytes consists of messages typed, message code, message value, and
1178980	1186880	message end. The actual data value contained in the information bits are stored in message
1186880	1194580	value. Message start and message end are the bytes representing the beginning and end of a
1194580	1207930	block. Respectively, FF and FE. Message code can be thought of as a control bit. Here, the
1207930	1214310	message to be transmitted has a structure of message start, message code, message value, and
1214310	1222050	message end. At this point, you can see that the message code is different, which can be found in
1222050	1230090	the LibCEC code in CEC adapter message code. For basic message transmission, you need to
1230090	1238570	know about four message codes in your code. In particular, OB and OC are message codes related to
1238570	1245970	message transmit. And I said that the message code is similar to the control bit. For the E1
1245970	1258030	bit of the control bit, that is represented by OB and OC. And the AC bit is also similar. We
1258030	1267550	create a fuzzer for the three parts of the CEC message frame. First is an OP code. 3-6 was
1267550	1276290	excluded because it is the OP code to power of the device. And the second is the operand. And we
1276290	1284010	randomly selected a value from zero to FF to transmit the operand of 14 blocks. And the
1284010	1292330	header block is fixed to the logical address of the target device. In the case of an OP code, to
1292330	1298170	increase the probability of a crash, we use the list of OP code that are likely to cause
1298170	1306650	vulnerabilities. And finally, the message length. In the case of the CEC protocol, the maximum
1306650	1317710	message size is fixed to 16 blocks. That is 160 bits. In addition, each block is recognized as
1317710	1326330	one block of header block and an OP code and operands in order. Therefore, data of various
1326330	1335850	message sizes were transmitted including messages that exceeded the maximum size. Now it is
1335850	1344310	the DDC protocol. The target device is an HDMI source device. Maybe you can probably guess the
1344310	1351990	reason. Because the DDC protocol allows the sync device to send the EEDID data to the source
1351990	1359270	device. Therefore, the source device, which is the device that received the data, was targeted.
1359990	1371010	Source device includes desktops, laptops, set-top box, and smartphones. And we used the Arduino
1371010	1380370	Mega 2560 and transmitted the data via the wire library provided by Arduino. Also, we cut and
1380370	1390950	soldered the HDMI cable for more reliable data transmission. If you cut the HDMI cable, you can
1390950	1401520	get 19 pins and a wire connected to each pin. And we connected the appropriate registers and
1401520	1411600	wires to the required SCL, SDA, ground, VCC, and HPD locations and soldered them to make the same
1411600	1423770	cable as the last picture and then connect each of the five jumper wires to the Arduino. Now, we
1423770	1430450	can transfer the actual data through the wire library supported by Arduino for communication
1430450	1440650	with I2C devices. The main functions for data transfer are begin on request, on receive, read,
1440650	1451750	and write. Note that it uses a 32 byte buffer. Therefore, any communication should be within
1451750	1462810	this limit. Exceeding bytes will be just dropped. But we will send the EDID value of 128 bytes. So,
1462810	1475270	I modified buffer length in the header file to 128 as follows. As a result, EDID data can be
1475270	1482090	transmitted as shown in the picture. On the left is a code written using Arduino IDE and on the
1482090	1492780	right is the result of sending EDID data to the laptop via Arduino. And it will now send the
1492780	1503120	EEDID data. It consists of EDID 1.3 and CA extension. It's the CA861D. At this time, if the
1503120	1510100	value of the thread such as header, padding, and checksum, which are marked in red, are
1510100	1520460	used well, the fuzzing effect can be enhanced. We created the data in the above three ways when
1520460	1527740	mutating. First, it's a structure of EDID, and second, random among the structure that are
1527740	1539410	likely to cause vulnerabilities, and finally, a random value for all data. And one more thing to
1539410	1547070	note here. To fuzz through the HDMI cable, the process of connecting and disconnecting HDMI
1547070	1555510	should be repeated. However, if you have to plug in and out every time you send data, it's very
1555510	1564570	inefficient and it will not be called a fuzzer. This is confirmed by the HPD signal. When the
1564570	1572810	5 volts is applied to the sync TV, the sync sends the HPD high to the source. And then the
1572810	1581650	source sends an EDID request to the sync, and as a result, the sync sends the EDID to the source.
1584080	1591580	So, we repeatedly send low and high to HPD pin, giving the same effect as connecting and
1591580	1602030	disconnecting HDMI. Now, let me tell you about the result we have obtained through our fuzzer.
1604630	1611070	First, if you look at the CEC protocol, in the memcpy function, you can see a one byte stack
1611070	1623990	overflow resulting in a memory leak. In closer look, the top part of the write function is the
1623990	1632110	onTransact function in libHDMI CEC contains the header and data blocks we sent. And the
1632110	1640990	read int32 and read C string functions are just that part. If you look at the onEventUpdate
1640990	1650930	function in libHDMI CEC JNI, copy it to V8 using the way you received above. At this time, a
1650930	1659710	one byte overflow occurs. And the following is the DDC, and you can see that the kernel panics
1659710	1666930	and fails to reboot when you send the EDID data. Also, we can see that the value is modified to
1666930	1678410	61 that we sent. In fact, we want more influential data- influential results. But fuzzing
1678410	1687110	with a real HDMI cable creates a problem of stability and speed. At the time, we thought that
1687110	1693530	the graphics driver vulnerability is highly influential. So, we made a graphics driver
1693530	1706730	fuzzer of HDMI on Ubuntu. So, I'd like to briefly introduce the Ubuntu DDC fuzzer that we- that
1706730	1713710	The process of creating this fuzzer can be summarized in four main steps. First, with source code
1713710	1722730	auditing, I found a part that has HDMI EDID data. We confirmed that the EDID data is stored in
1722730	1730210	the second parameter of the DRM to prove DDC EDID function, which named buff, after calling
1730210	1740820	this function. The second is hooking with KProofs. The KProofs is debugging mechanism for the
1740820	1748400	Linux kernel. It enables you to dynamically hook into the kernel and allows you to do various
1748400	1758500	actions through the callback function. The following source code is basic example. In ADDR field of
1758500	1765220	KProof struct, you can set the address of function to break. And you can start with the symbol
1765220	1773940	using the symbol name and offset field instead of the ADDR field. When the break point, what you
1773940	1780560	set in the address field is hit, KProof called pre-handler and after that instruction is
1780560	1790680	executed, it calls the post-handler. And it's handler's second parameter, which names Lex, it's
1790680	1798860	pointing to the structure containing the registers saved when the break point was hit. So you can
1798860	1809900	counter the register value with it. Actually, we want break when a function returns, so we use
1809900	1818920	return proofs. It's the other type of proofs and also called KReproofs. And maybe K or Sims
1818920	1828740	could be helpful for you to get all kernel symbols. Anyway, the code is similar to the KProofs. In
1828740	1836580	the entry handler, we have saved the address of the buffer where the EDID data is stored. And
1836580	1843820	before returning, that is after the EDID data is stored, we modified its value by accessing that
1843820	1852020	address. In fact, we did not read or write the return value at RET handler, but instead changed
1852020	1862700	the EDID value at the point of return. Now we can mutate the EDID data. But there is one more
1862700	1870240	problem to be solved here. That is, calling this function interactively as if we had
1870240	1881820	repeatedly sent HPD signal at the Arduino fuzzer part. I thought that using XRender would solve
1881820	1889140	this problem easily. XRender is used to set the size, orientation, and reflection of the
1889140	1897920	outputs for a screen. So we thought that EDID-related functions would be triggered. However,
1897920	1906960	when I used XRender to create a fuzzer, I got too much noise. So we did it another way. And we
1906960	1917760	checked the call stack. There are various tools to trace the call stack, and we used FTrace. FTrace
1917760	1924860	is an internal tracer designed to help our developers and designers of systems to find what is
1924860	1933680	going on inside the kernel. The files for using FTrace are in the past, syskernel debug tracing,
1933680	1939440	and there are several types of the tracers. There are types that are defined in the file
1939440	1946520	available tracers, and the traceable function list is in the file available filter functions.
1947300	1956800	Trace results are stored in the file trace. First, we set the options to check the call stack of
1956800	1964640	DRM do proof DDC EDID as shown in the multiple echo commands. And this will give you the result
1964640	1972220	shown in the picture. The result shows that this function is called from the IOC tier, and I
1972220	1979420	checked the source code for DRM IOC tier would get connected. Now, the final step is to call
1979420	1990830	this one. And this is the lib DRM user space library for accessing the DRM on Linux that
1990830	1998010	supports the IOC tier interface. And you can see the code for DRM would get connected in this
1998010	2007350	library. So, we used it to call this function. As a result, we were able to complete the
2007350	2016900	fuzzle. The presentation so far can be summarized in these pictures of two protocols and the
2016900	2028280	each protocol fuzzles. And it is our future work. And source and images are as follows. Thank
2028280	2035460	you for listening so far. And if you have any questions, please send me an email. Thank you so
2035460	2036240	much.
