start	end	text
0	6200	Hey everyone, welcome to my talk, Ace of the Sleeve, hacking into Apple's new USB-C controller.
6540	11840	First off, who am I? My name is Thomas Roth, aka Stacksmashing. I'm a security researcher for
11840	17240	hardware and firmware, and I'm also a co-founder at this online training platform called Hackstreet.io.
17240	24160	You can find me on Twitter, YouTube, and so on. Now, as always, like any research, it's built on
24160	29920	top of other people's work, right? And so I want to thank, for example, Sigusa, who built a kernel
29920	35800	module we will use, Oli for the Thunderbolt patcher, the Azahi Linux team, without whose
35800	41520	reverse engineering work I couldn't do anything, Carlo Maragni, who just always was there when I
41520	47640	talked and had to rant about fault injection, Biska, Fabian, and Caro, Mark Zingier for the
47640	54560	central scrutinizer, and also the TAD12 dev team, who did some awesome work. Now, a bit on the
54560	60800	backstory. Apple used to have this proprietary connector called Lightning, and it could do, you
60800	66640	know, fairly obvious things such as charging, USB, video, and audio. But it could also do some
66640	73900	really cool stuff, for example, JTAG, UART, SDQ, and so on. And you could buy cables for this on
73900	78720	the black market, and there was also the Bonobo cable, but we decided we want to build an open
78720	83560	source version of this, and we called it the Tamarink cable. And the Tamarink cable is essentially
83780	88820	a $20 Lightning debugging interface that we introduced two years ago at DEF CON,
89240	94920	so it's good to be back. However, Apple decided to throw all of my work away by switching from
94920	106860	Lightning to, you know, this thing here. There was supposed to be audio here, but she's talking
106860	111640	that we can do charging, data, audio, and video. But I think they made a mistake during the keynote
111640	116280	because they forgot, you know, all the cool stuff. Like, who cares about charging? I want JTAG on the
116280	123740	iPhone. And, you know, if you look at the USB-C connector, it has a ton of pins, and so surely we
123740	129580	can somehow get some of these to speak JTAG, UART, or, you know, anything interesting, not just
129580	135880	charging. And then I realized that the iPhone is not the first USB-C device that, you know, Apple
135880	141040	made. And I never looked at any of these, but luckily for me, other people did. And they figured
141040	148640	out that Apple, uh, essentially uses the USB power delivery negotiation to do some cool stuff. And
148640	154300	it turns out that this power delivery negotiation is happening in something called the USB-C port
154300	160660	controller. It's essentially a tiny microcontroller in the, in the MacBook, and that one handles all
160660	166860	of this. And essentially, the charger communicates with it through these two lines, the configuration
166860	174040	lines. And this is all handled by a microcontroller that sits close to the USB-C ports. And, you know,
174160	178760	a microcontroller will have some kind of firmware. And some smart people years ago figured out,
179300	185020	you can just dump that firmware. So you solder a couple of wires into your very expensive MacBook,
185020	189920	dump the firmware, and then they wrote an awesome blog post because they reverse engineered the
189920	195300	firmware. And they figured out that the Apple Type-C port controller, which we call Ace,
195300	201560	actually contains a lot of secret functionality. And they found that Apple uses something called
201560	207680	VDM, or Vendor Defined Messages, to let us change the configuration of certain pins on the USB-C
207680	216020	connector. And so, for example, we can change the SBU, the Sideband Use Pins, to be serial. And so
216020	223360	we can, you know, send the VDM action 306 to the Ace controller, and then we get a serial console
223360	229740	on the MacBook. And it turns out that to this Ace, there's much more connected than just serial. You
229740	237800	can also do JTAG, Thunderbolt, even I2C, or on the iPhone there's SPMI and so on. And so that's
237800	242760	kind of cool. But how can we actually send these Vendor Defined Messages? Because this is not just
242760	248820	like regular USB. Instead, we actually have to use special tooling to be able to send these
248820	254860	messages. And again, some very smart people from the Asahi Linux tool, uh, Linux team found out
254860	260700	that the back left port on the MacBook Pro is special, and can actually send those commands,
260700	264940	and they reverse-engineered all of that stuff. And so there's a nice tool that you can just use
264940	270640	to send these commands from a Mac to another Mac. Also, Marc Zenier built this thing called the
270640	275820	Central Scrutinizer, which is essentially a serial adapter that is able to send all of these things
275820	283160	and can give you, you know, a UART shell on a MacBook, and so on and so forth. Now, I saw this,
283160	288100	it's Pico-based, I love the Pico, and so I ordered a couple of PCBs and started experimenting with
288100	293840	this, um, and essentially all it contains is a small USB-C controller and a couple of level
293840	299900	shifters. Now, I wanted to try to get serial on the iPhone 15 that was freshly released,
299900	305240	because everyone was harassing me that my stuff doesn't work anymore, so, uh, I had to get with
305240	310620	the times. Now, unfortunately, it didn't work on the iPhone 15 out of the box. Uh, I had to
310620	315980	actually solder on a small USB switch and provide power to the iPhone and so on. Now, this might
315980	321100	just be my incompetence, because this is the first time I ever touched USB-C, and so I just tried
321100	327120	random stuff until it happened to work. And so, if you know USB-C better than me, feel free to
327120	334200	tell me what I'm doing right or wrong. Um, but after doing all of this, I essentially had the
334200	339840	central scrutinizer working on the iPhone, and so I can, you know, hit some keys, and suddenly I
339840	348200	get the serial console on the, uh, iPhone 15. That's pretty cool, um, but also pretty useless,
348200	353320	because, you know, like, what do we do with serial output? We want to get JTAG or SPMI or
353320	359220	something interesting, right? And again, the Asahi Linux people did a ton of cool reverse
359220	364440	engineering work on all of that USB PD stuff, and they have a gigantic document where they
364440	368980	document all the actions and so on and so forth, and if you keep scrolling and scrolling and
368980	375380	scrolling, you will find a small note that says, by the way, there's this action called 0206,
375380	381040	and there's a good chance this is SWD, but nobody ever seems to have, like, publicly tried this.
381240	387700	Um, so I took my central scrutinizer, hooked my oscilloscope debugger and so on up to this,
387700	396720	and tried to connect to it. And it didn't work. But, you know, turns out there are two cables,
396720	404080	and so I just reversed them, gave it another try, and suddenly we get a success message. We found
404080	414060	the debug port with the ID 4BA02477. We just got JTAG on the iPhone 15 by just sending 206.
414060	425200	Awesome. Unfortunately, this is a production device, and so JTAG is locked. So essentially,
425200	429660	we can't debug it because it's a production device. On the black market, you can probably
429660	435100	find an iPhone that is not locked, but it will run you like 100k or something, so I can't do that.
435960	443800	But we got JTAG. Useless JTAG. You know. But we can still explore some other buses, and so it
443800	449160	turns out that on the iPhone 15, there's actually more than just UART and so on on this connector,
449160	455920	but also SPMI and other things. And so in December last year, we released a PCB called the Tamron
455920	462080	C adapter, which is essentially a fork of the central scrutinizer with bidirectional level
462080	466520	shifters, a USB power switch so it can actually charge the iPhone if you want to let it run for
466600	471560	a long time for research. And we can use it to explore all the buses on the iPhone 15, including
471560	478480	SPMI, which I think we released the first public analyzer for. And it also runs a full JTAG probe,
478480	483740	and so you can experiment with this. It's fully open source. And if you use it, it looks like
483740	489860	this. Now, this is cool, but again, also kind of useless. However, what's interesting is that
489860	497540	all this stuff is implemented on the iPhone side in this chip called the ACE3. And the ACE3
497540	502240	essentially sits between the USB port and the system on a chip. And it makes for a very
502240	509400	interesting target, because on the iPhone 15, the ACE3 can actually run a full USB port, like it can
509400	514620	come up as a USB device. If you go into recovery and plug your iPhone in, you're actually
514620	519540	communicating with the ACE3. And that makes it an interesting target, because imagine if you
519540	525100	compromise this part of the device, you could do attacks on the system on a chip without
525100	529260	any way for anyone to know. Like there would be essentially zero traces.
530520	536960	So I was interested in this. But I wanted to first understand the predecessor, the ACE2,
536960	542120	because there's a lot of public work on the ACE2 already. And the ACE2 is essentially a Texas
542120	549340	Instruments, a custom Texas Instruments USB-C controller. It's an ARM chip. It's connected
549340	555840	to the SOC via I2C. And you can find it on all MacBooks, starting with the T2 Macs, up to the
555840	561920	M3 Macs. And so very recent Macs even still use this. It turns out that it's just essentially a
563860	573160	re-labeled TPS65986 with a custom, with a custom ROM essentially. Now, I open up my MacBook. I
573160	577240	recreated the work by the TAD12 dev team. I dumped this on an M1 MacBook, and so I got an
577240	582480	up-to-date firmware, started reverse engineering it, and found like the command handling, uh,
582480	586900	built like tooling to talk to it, and so on and so forth. And interestingly, the firmware even
586900	591860	contains like some privileged commands, such as memory, read, write, modify, and so on. It's like
591860	596680	peek and poke. But unfortunately, those are locked on production devices. But if you manage to
596680	604640	change a single bit, you can unlock them. And so, uh, yeah, that's kind of cool. Um, the communi-
604640	610260	the way we communicate from the system on a chip, like from macOS with the ACE, is using a bus
610260	616860	called Apple HPM bus, which stands for Host Port Microcontroller. And we communicate with it by
616860	622840	sending these four-byte commands. They're called 4CC. It's essentially a four-byte integer, but it
622840	628720	happens to be ASCII. And so they're like commands such as, you know, GAID, or, you know, reset,
628720	633320	and so on and so forth. And we built a small tool called ACE tool to communicate with that. And so
633320	639520	we have the full list of commands online. We have a tool online to try them out. So it makes for
639520	645000	fun. But the reason I'm telling you this is that we can do one very important thing. We can read
645000	649680	the status of the chip. We can determine whether it's in application mode or whether it's in boot
649680	654840	mode. And we can also determine whether it's in DFU mode and so on. And so if the chip fails to
654840	659600	boot, we can measure it. If the chip successfully boots, we can also measure this. This will become
659600	666840	important later. So yeah. The ACE2 also has an external flash connected. And this spy flash
666840	673340	does not actually contain the full firmware, but it actually just contains patches for the ROM.
673340	679740	And so essentially you can patch every single function in the ROM using this flash. This makes
679740	683740	reverse engineering terribly annoying. Because when you start reversing the firmware, you have
683740	688800	like a function call. That function call goes to another Segway function, which does like stupid
688800	696880	stuff with the registers. Then it dereferences a pointer list, which will be loaded from the flash.
697800	701900	And then it actually jumps to the function. And so everything has like three layers of
701900	706960	indirection, which breaks all your tooling for cross-referencing and so on and so forth. And so
706960	711220	we built some scripts to make this easier. Um, but there are thousands of these functions and
711220	716820	so it's terribly annoying to reverse without additional tooling. But, because it has an
716820	722340	external flash, this chip is getting updates. And so on macOS, there's a tool called USB-C
722340	727880	firmware flasher. And with this, it gets regular updates and so on. And these updates are
727880	735620	unfortunately protected using RSA 3072. But that signature is only checked during updates. So
735620	741800	there's no secure boot on the chip whatsoever. So if you find code execution and can modify the
741800	746300	external flash contents, you get persistence for free. Like you have, you don't have to do anything.
747020	753960	And so I found a vulnerability in the ACE2. Uh, as you do. Well, it's not actually, you will see.
753960	760920	It's complicated. Um, and I got told it would be fixed in fall. So in the submission report, I can
760920	768360	see fall 2024. However, uh, after I said that at Black Hat, uh, I got told by Apple, oh yeah,
768360	774920	that's a mistake. We are not going to fix it. And so I learned two days ago that I can actually
774920	785480	drop a vulnerability here. So, uh, I'm doing. Thank you. So, uh, so I spent the last two hours
785480	791080	writing slides. So this is going to be a bit of PowerPoint karaoke. Um, but essentially it turns
791080	797460	out that not only does the ACE have SWD to the system on a chip, but the system on a chip also
797460	806260	has SWD to the ACE2. And so the SOC can debug the ACE2. And the way this works is that there are
806260	814940	the two lines that you need for SWD. SWDIO and SWDCLK are general purpose IOs on the, on the SOC.
814980	821500	And GPIO on Apple SOC is basically just a memory range. And if you write to it, you can fiddle
821500	826760	with the IOs. You can put them into read mode, output mode, high, low, and so on and so forth.
826760	832420	And thanks to the Asahi Linux team, we know how to talk to them. And thanks to Sigusa's, Sigusa's
832420	837880	IO kernel read write module, we can actually do writes to those pages using a kernel module,
837880	845120	which requires disabling SIP and so on. And so we can control the pins that talk to the debug port
845120	854720	of the ACE through the kernel. And so let's bitbang SWD through the macOS kernel. Cause, you know,
854720	860560	I don't have enough stuff to debug or something. I don't know. Anyway. And so basically we have our
860560	867020	user space application. That user space application talks to the IO kernel read write module that I
867020	872900	loaded into the macOS kernel, which talks to the memory mapped IO peripherals, which toggles the
872900	880140	physical pins, which then talk to the ACE2. And I implemented a debug probe over this that lets us
880140	889020	dump and modify the ACE2 from user space and looks like this. So you can just essentially call
889020	893340	dot slash ACE2 dump. Assuming you have this kernel module loaded, it will dump the firmware of the
893340	899580	ACE2. Now the problem with this is I wanted to, you know, build some payloads and I want to debug
899580	905980	those payloads and I don't always want to have my MacBook open to debug the payload. And so I want
905980	914380	to debug. So I ported this entire thing into OpenOCD. And so introducing Tamarin Kernel, which
914380	921440	is essentially an OpenOCD driver that bitbanks SWD on Apple SOCs through the IO kernel read write
921440	927680	module. And so you can actually debug more than just the, than just the ACE2. There are other
927680	934880	peripherals that have debug enabled. Thank you. And, and also I found a way to disable the
934880	939680	signature verification because it's, you know, patchable from external. Uh, I can just, if I get
939680	945800	code execution, it turns out that remember how all functions are patched, patchable. Also the
945800	950180	signature verification functions are patchable. And so you can just disable them from the external
950180	955340	flash. And afterwards, afterwards you can actually just load your own firmware through user space
955340	960820	and all modifications survive a full system restore. So even if you wipe your Mac, the ACE2
960820	966300	will still be compromised. And so we can back to the ACE2. Yeah. And I'm gonna like all these
966300	971120	things I have to release like today, as I learned, I can release this two days ago. So I don't have
971120	976880	this packaged nicely. And there's still a lot of swear words in the code, let's say. So I'll fix
976880	983800	that and publish it on GitHub. Um, but we had the ACE2, um, which is on the way out. It's an old
983800	989840	chip. It doesn't do a whole lot. Uh, the iPhone 15 pro uses the successor, which is far cooler.
990480	997740	And so we have checked the ACE3. Um, the ACE3 is actually a Texas Instruments SN25A12.
997740	1002740	And when I started this, there was zero public information on this, literally zero. In fact,
1002740	1008120	I started tweeting about the chip. And afterwards I got emails from like the gray market salespeople
1008120	1012400	who sell like the stolen chips online. And they were like, Hey, can we pay you to write a product
1012400	1018340	description for this chip? Because we can't find anyone else who ever talked about it. And so the
1018340	1025560	ACE3 is used in the iPhone 15 and on the MacBook pro M3 with pro and max processors. And the ACE3
1025560	1032140	is far more complex than the ACE2. It runs a full USB stack called port DFU. It has access to some
1032140	1037100	more internal buses. It has very interesting potential because it's so, it, because it can
1037100	1043200	run full USB. If we managed to, you know, find another checkmate style boot ROM issue, we could
1043200	1049000	in theory, uh, get persistence for a jailbreak by just putting it in the ACE3 instead of having to
1049000	1054600	gain persistence in the SOC itself. I haven't done any of that. It's just some of the motivation
1054600	1061880	that drove me to hack this chip. Um, so I started looking at how is this chip protected? Like what's
1061880	1066840	different? And it turns out that everything has changed. It doesn't use the USB-C from a flasher
1066840	1071740	anymore. It uses different upgrade mechanisms between the iPhone 15 and the MacBook.
1071740	1077460	In fact, I believe on the iPhone 15, it actually uses SWD to update the chip, which is kind of
1077460	1082820	cool. And the updates are fully personalized. So each chip will get their own firmware.
1083400	1087440	But you know, I still had this vulnerability that I think, you know, I can theoretically,
1087440	1092460	I now can debug the ACE3. So I wanted to try it on the ACE3. So I ordered a MacBook M3
1093140	1102500	and the trick didn't work. So easy select, uh, easy choice, send it back or, you know, I'm a
1102500	1109920	hardware hacker, open it up. So, uh, I open up the MacBook and remember I had to do this quickly
1109920	1117300	because the Amazon return window for this machine was just 30 days. And the first thing you will
1117300	1123860	notice is that there are again, the same debug ports that we already saw on the previous MacBooks
1123860	1129300	and on the previous MacBooks, we could dump the chip this way. And so just for labeling,
1129300	1134520	this is the ACE3. It's much bigger than the ACE2 and there's no Texas Instruments chip that looks
1134520	1139620	similar to this one. And so we really have zero idea what this chip does. There's again,
1139620	1145980	an external spy flash and these nice debug connectors. Now I started probing these and
1145980	1151320	in combination with the, uh, kernel, uh, with the Tamarink kernel, I can, I could essentially
1151320	1159760	see that yes, I'm talking SWD on the right lines, but it seems like the debug port is disabled. So
1159760	1166020	no, no luck. So instead I decided to dump the external flash. So again, like I couldn't solder
1166020	1170480	in this because again, Amazon return window. So I use these needle probes to just like probe the
1170480	1178300	flash lines. And eventually I got a full firmware dump. Reversing time. Turns out it's essentially
1178300	1183980	the same. Only patches get loaded from the external flash and, um, everything seems to be
1183980	1188320	different on the hardware side. So for example, the CRC peripheral is a different, at a different
1188320	1193460	address as far as I can tell. Um, it's just patches and there are some weird regions with
1193460	1197520	high entropy, which is always a bad sign because that means that there's some cryptography very
1197520	1204360	likely going on. And, uh, yeah, that will spoil our day if they implemented secret boot. However,
1204360	1208940	some successful things was that I was able to reverse engineer the firmware header. And so I
1208940	1215220	found a couple of CRCs and so on. And my naive hope was, okay, I just, you know, patch the firmware,
1215220	1221280	fix the CRCs and surely this chip will boot. And so let's flip a bit in a $3,000 MacBook.
1223040	1228780	Unfortunately, uh, I couldn't get it to boot a modified firmware, but at least I didn't fully
1228780	1234820	brick it. So in the end what I tried, I tried my software vulnerability, I tried physical SWD
1234820	1240040	access, I tried modifying and switching the flash contents, even like between the different ACE
1240040	1245540	chips, but they all seem to have a unique signature. Like even you can't take the, the left ACE and
1245540	1250900	put it on the right ACE and so on and so forth. I tried fuzzing and I actually found a timing
1250900	1256420	side channel that lets me enumerate the commands that the ACE 3, um, supports, but that doesn't
1256420	1263240	really give me anything. So yeah, essentially we have a completely undocumented, not documented,
1263240	1271540	apologies, chip. We have no firmware and only some simple commands. Time to give up or do we
1271540	1278360	try fault injection? Um, so fault injection is an awesome technique because essentially we can
1278360	1283640	introduce faults into a chip, which allows us to modify the behavior of the running software.
1283860	1288500	So for example, we might be able to flip, flip bits and registers and memory. We might be able
1288500	1292480	to skip instructions and so on. And there are a lot of different techniques for this. There's
1292480	1298440	voltage glitching, laser, BBI, electromagnetic and so on. Uh, they all have one thing in common,
1298440	1304660	which is that they very easily break chips. Um, the most common way to do glitching is using
1304660	1310360	voltage fault injection. And there you essentially drop the power to the chip for a very short
1310360	1316360	amount of time at just the right point in time. And the problem is this pretty much requires
1316360	1321740	soldering and removal of a ton of capacitors and so on. And it's best performed if you, if you like,
1321740	1325240	know what's going on. Like we don't even know the pinout. We don't know what is the core voltage,
1325240	1330120	what is the main voltage rail. We don't know what other chips are on there and so on and so forth.
1331080	1337560	But there's an alternative called EMFI, electromagnetic fault injection. The idea is we
1337560	1343460	create a high voltage pulse into a coil and this lets us inject current directly into precise
1343720	1349500	locations in the chip. And this again can let us skip instructions, change register values and so
1349500	1356520	on. And we don't really need target preparation for this. It's just we point our chip shouter at
1356520	1365060	the chip, we zap it and the chip is hacked. Wonderful in theory. The problem is we need to
1365060	1370500	know the very precise timing on when we need to glitch because otherwise, you know, we're just
1370500	1376440	gonna glitch something else. How do we figure out the timing on something that we know nothing
1376440	1383380	about, right? We just know it doesn't boot, period. Brute force, I thought about it, but it,
1383380	1389240	the boot is so slow that it would take forever to try. And the more we try to glitch at the
1389240	1394140	wrong point in time, the more likely we are to break the chip. So we really want to get this
1394140	1403540	right. But another idea, which are what if we find a side channel? What if we find a side channel to
1403540	1410980	get this precise timing on when to inject our glitch? Normally, now I decided to use an EM
1410980	1416860	side channel. So I use an EM probe to measure the chip. And normally you would use a very high
1416860	1421560	end oscilloscope for this, but I wanted to use a cheap, affordable hacker to make this more
1421560	1428280	accessible. And I just glued a random coil onto a PC by probe and just dropped it onto the chip.
1428280	1434060	So this is just held with gravity. And this way we can capture the magic chip waves. And we can
1434060	1440220	actually see this as we restart the chip, we can actually see that there's activity on the spectrum
1440220	1445960	at around 48 megahertz. Now this activity could be anything, right? Like this could be the power
1445960	1452880	rail, this could just be the spy flash line or so, but it's something. And so the idea is simple. We
1452880	1458760	start recording the spectrum on the hack RF, we reboot the ACE3 using the ACL I showed earlier,
1458760	1464760	we get the electromagnetic recording, and then we just do some very simple DSP,
1465680	1471920	which just took the better half of a week to generate, you know, a ton of different measurements
1471920	1476700	and so on and so forth, filtering this and that. But eventually I had a line that I thought, okay,
1476700	1481100	this looks like it might tell us something about the chip. And this is completely gut feeling,
1481100	1486560	like I didn't do any science here, I just tried to play with filters and eventually I got this line.
1487720	1492300	Now the problem with this recording is that you want to collect a lot of
1492300	1498540	traces and average them together. The problem is they will all be at different offsets in time
1498540	1504380	because we don't have a precise way on how to start the recording. And so we could align these
1504380	1510240	in software. However, the hack RF actually has a nice feature, which is it has hardware trigger
1510240	1515720	inputs. And so we can actually trigger the recording using a hardware signal. This doesn't
1515720	1520060	work in the latest hack RF firmware. So it was again like hours of trying different firmwares
1520060	1526580	until one would actually trigger correctly. And now we just need a trigger. Now remember that we
1526580	1532760	have access to the flash lines. And the flash lines have a line called chip select. And the
1532760	1540780	chip select line will go low just as our firmware is being loaded. And so this is perfect to offset
1541000	1545080	a glitch from if we want to bypass secure boot of what just got loaded from flash.
1545780	1554260	So, easy plan. We start recording on the chip, on the hack RF. We reboot the ACE3. The hack RF gets
1554260	1560220	triggered by the chip select line. And we get a perfectly aligned recording. And in theory if you,
1560220	1565480	you know, it should look like this if you take pictures for presentation. In reality your desk
1565480	1572380	will look like this and it will just be a gigantic mess. So in the end we have perfectly aligned
1572380	1577780	recordings and we can actually average them together to get a nice meaningful signal where
1577780	1583940	if anything else put in noise we can just filter it away essentially. But, you know, now we just
1583940	1590880	have a fancy line. How do we actually use this to time our glitch? Well, we can change the flash
1590880	1597720	contents to be invalid so that the boot fails. We reboot the ACE3 and record the EM emissions.
1597720	1603680	And then we compare the differences. Sounds easy but in reality this takes hours because you have
1603680	1608960	to set up these needle probes which takes like, you know, 20 minutes. You try to flash the chip
1608960	1615700	until it works. Then you do the capture and measure and so on. And then you do this again and again and
1615700	1620920	again to get everything right. And in the end you end up with a trace that might look like this where
1620920	1626820	you have the original firmware and the modified firmware. And we can see that this trace looks
1626820	1631040	super different, right? Like there's a clear point in time where they start to differ.
1631820	1638800	What's even better is we can test our hypothesis by modifying the CRCs. So remember that we have
1638800	1646260	these three CRCs and so in theory if we fix just some of them we should see a delay in our boot,
1646260	1651780	in our EM trace. Like we should see that our trace changes at a later point in time.
1652460	1659200	So I tried this. So I have the original firmware. Then I set one of three CRCs to be correct.
1659780	1665380	And you can see we have exactly the same signal as before. Then I tried two of three
1665380	1671080	CRCs to be correct and no change. So I was worried that this might not actually work.
1671080	1676860	But then when I set the third CRC to be correct we can see that the boot actually goes much further
1676860	1685420	and that the boot fails at a much later point in time. And so why not just glitch here, right?
1685420	1691320	So simple enough. We now have some timing. Now we just need to position our chip shoulder. Because
1691320	1698760	normally for EMFI it's very important where you are glitching. And so if you were doing this
1698760	1704640	professionally to give a talk at big security conferences you would use a big XY table to scan
1704640	1710200	the chip. Unfortunately, like literally the week before I did this I had a small accident with my
1710200	1716540	CNC and I got 230 volts onto the ground line and completely bricked my computer, my screen and my
1716540	1724100	CNC controller. That was fun. And so I couldn't do this. But I really wanted to try this attack.
1724120	1729160	So I just did the dumbest thing you probably could have done which is I chose the biggest
1729160	1737400	tip I had. I just placed it on the chip. So that way I was sure that I was at least hitting
1737400	1745660	something in there. And so I had this nice setup with the chip shoulder. Then the triggering was
1745660	1751620	done by a chip whisperer Husky. The trigger connection is just the chip select line using
1751840	1757920	a PC byte and a connection to ground. What's not shown is the days of debugging this took.
1757920	1763760	Again, this is a photo op. Reality looked like this. As soon as you bump the table everything
1763760	1772500	would just drop off. So yeah. So we are ready to glitch essentially. So my first attempt was
1772500	1777900	I would just change the version string. So from Mac OS I can read out the version of the firmware
1777900	1787600	that is running on the Ace. And so on my MacBook this was 2.45. So I decided in the flash I would
1787600	1795440	just change that single byte. Then I fixed all the other CRCs around it. And then I armed the
1795440	1802320	Husky and the chip shoulder. I reboot the Ace 3 via Ace tool. I wait for the glitch. And then
1802820	1808120	remember earlier I told you that we can check what the status of the chip is? I just checked
1808120	1814200	whether it successfully booted. And this worked wonderfully, right? So I just, I can just try
1814200	1819460	again and again and again. And in theory we should eventually get successful. And so I
1819460	1826780	built this tiny Jupyter notebook to do all of this. Um, and started it. And you can see we
1826780	1834760	got like 1.6 attempts per second. So each reboot takes like 1.6 seconds. That's when the trouble
1834760	1840080	started. The problem is sometimes the Ace completely starts, stops responding and I can't get
1840080	1846320	it to boot again. I don't get any output. So I need to reboot the machine. The problem is if I
1846320	1851960	reboot the machine while the charging controller doesn't have a firmware, the MacBook will stop
1851960	1858340	charging. And essentially I have eight hours of trying to glitch the chip and then the battery
1858340	1863460	runs out. Then I have to restore the flash which takes hours again with the probes. Restore the
1863460	1870400	firmware, charge it up and then do the whole thing opposite again. Um, so I did that for a couple of
1870400	1877460	days. And cause I, like it was like sunken cost fallacy. I started, then I thought like, hey, maybe
1877460	1882780	I should build a battery emulator and just like feed it externally. But I thought, ah no, I'm so
1882780	1888680	close. I'm sure it will happen any minute now. So, yeah. So I kept doing this but eventually I got
1888680	1902860	success. I managed to get into the app mode on the uh Ace 3. And by checking. Thank you. And by
1902860	1907560	checking, by checking the version number, I can actually see I was successful. I changed it to
1907560	1916940	version 42 and we glitched the Ace 3. But the problem is we only changed the external patches.
1916940	1921380	And we don't actually know what these patches patch because we don't know the actual ROM. And so
1921380	1926940	essentially we have this flash which is full of random functions. But we don't ever know what
1926940	1933180	they do. Like we don't know how can I trigger them? Will they actually be executed? And then even if
1933180	1937400	you manage to execute them, we don't have any input or output. Like we don't even have a driver
1937400	1942260	to wiggle a pin or something. So I was like considering, oh can I do maybe some, some looping
1942260	1947760	that I can measure via EM or so. Um but yeah, essentially we can replace functions. We don't
1947760	1954480	know what they do. And even if we execute them, even if we 100% know we get them to execute, we
1954480	1961080	have no way to get data out. However, I started looking around a lot through the Ace 3 flash and
1961080	1967920	you can see that there are a lot of 4CC strings here again. Like this, UFPF, DFUF, uh USBW and
1967920	1973820	this one and so forth. And I thought probably there's some similarities between the Ace 3
1973820	1978580	firmware and the Ace 2 firmware. And maybe I get lucky and they patched a function in both chips,
1978580	1984460	the old one and the new one. And so after hours of staring in Binary Ninja, I found a function
1984460	1992640	that is actually almost identical between the two. And this is the USBW command handler. And USBW
1992640	1998320	command handler, I have no idea what that does. But it's a command that I can send through the
1998320	2005260	Ace that will get executed. And remember, and so I can replace it. And remember how earlier I saw
2005260	2011340	the memory function? I essentially took that implementation from the Ace 2, modified it,
2011340	2017120	simplified it slightly and then had a function that was by Apple built to give me memory. And
2017120	2024280	essentially Apple built my exploit payload. So I'm very thankful for that. And so in the end,
2024280	2029120	I essentially had a very simple payload that is a trivial memory reader that takes in an address
2029120	2036280	and returns 4 bytes at that address. So again, attempt 2, we replace the USBW command handler
2037220	2041980	and we start glitching. And we again, you know, wait for the battery to run out,
2041980	2046300	start over and so on and so forth. The glitch was not very stable at this point in time.
2046300	2056040	And so, but eventually, I got a success and so I decided I will just send the USBW command with
2056040	2065100	the address 0 0 0 0. And I got this back. 0 0 0 6 2 0. And you know, this is a little endian
2065100	2069920	machine so you reverse it and if you do a lot of arm reversing you will immediately spot why
2069920	2076180	this indicates success. This is the stack pointer reset value. We just read address 0 of the
2076180	2084120	memory of the chip. And so we can read and also write arbitrary memory on the ACE3. So,
2089340	2096100	time to dump. Um, and again, like I, my payload was not the greatest and so I could dump 4 bytes
2096100	2106160	at a time. And so, it took hours and the battery ran out and I had to reflash, restore,
2106180	2113560	recharge, glitch again, and then dump it again. But eventually, I had the full firmware. A full
2113560	2119300	dump of the ACE3, ROM and RAM, and so on and so forth. So, awesome. We can actually start
2119300	2125220	reverse engineering this chip. And the main thing that I learned during this is dumping
2125220	2130340	unknown silicon is actually possible. Like, I knew almost nothing about this chip, right? And it's
2130340	2135860	not super difficult, it just takes a lot of persistence and, you know, dealing with annoyances.
2135860	2141340	And we can actually get code execution without having firmware, even on a microcontroller.
2141340	2146300	And I thought that was really cool. And now we can actually start researching the ACE3.
2147060	2152160	Now, the equipment I used with like the chip shoulder, husky, and so on, this is all very
2152160	2158180	expensive, right? Like, the toll is probably like 8k or something. And, you know, so let's make it
2158180	2164140	cheaper. So, I imported the entire attack onto the PicoMP, which is like a super low cost, uh,
2164140	2170780	electromagnetic fault injection tool. And I put a firmware on the chip shoulder that does all the
2170780	2175740	triggering on the chip select line and so on and so forth automatically. And so you can now attack
2175740	2187140	the ACE3 and dump it for $60, which I think is pretty fair. And so, yeah. With that said,
2187140	2192860	that's all I have for you today. I think we have a bit of time for Q&A, but thank you. And also,
2192860	2197060	if you're interested in actually trying some fault injection, we are running a glitching lab over at
2197060	2201980	the Embedded Systems Village. And so come by and you can actually bypass some protections on chips
2202540	2207260	by zapping them or fiddling with the voltage rails and so on. So, yeah. Thank you.
