1 00:00:00,000 --> 00:00:06,720 I'd like to welcome you on our talk, Nano Enigma, Uncovering the Secrets Within EFUSE Memories. 2 00:00:06,960 --> 00:00:09,040 First of all, allow me a brief introduction. 3 00:00:09,140 --> 00:00:12,300 My name is Martin and I'm here together with my colleague Michal. 4 00:00:12,300 --> 00:00:20,180 We also have a third partner in crime named Hayan, however he couldn't come here with us so we just have a pre-recorded message from him. 5 00:00:20,500 --> 00:00:29,520 We all work in the embedded system security testing team that's based in Prague, Czech Republic, which is under Accenture Umbrella, and we all have different fields of focus. 6 00:00:29,520 --> 00:00:35,020 So for me that's reverse engineering, so I'm usually that person that wants that firmware image unencrypted. 7 00:00:35,200 --> 00:00:38,740 So making me shut up was partial motivation of this talk. 8 00:00:39,540 --> 00:00:46,660 I'm pretty sure the other guys will tell you briefly about themselves when their time comes, so I'm just going to jump straight ahead into the overview. 9 00:00:47,120 --> 00:01:02,960 We have it in the title, we will be talking about EFUSEs, and EFUSE is an electronic component which is just two points interconnected with a connection that has a property that it burns or terminates when the current flowing through it exceeds certain threshold. 10 00:01:03,200 --> 00:01:12,580 This is really useful when you want to protect your home appliances from overcurrent, but it's also really useful when you want to create something called one-time programmable memory. 11 00:01:12,840 --> 00:01:22,160 Because if you represent bits with EFUSEs, once you change state of a bit from zero to one, you cannot ever unchange it back to zero. 12 00:01:22,160 --> 00:01:28,060 This basically means that you can change the state of the device permanently. 13 00:01:28,060 --> 00:01:39,620 This is really useful for security because now you can use these types of memories to, for example, disable debugging interfaces or enable secure boot or put there public keys for secure boot. 14 00:01:39,720 --> 00:01:49,640 However, some manufacturers took it one step further and they actually used these EFUSE based memories for storing information that requires confidentiality protection. 15 00:01:49,680 --> 00:01:56,760 Meaning that you can find there also flash memory encryption keys or passwords for debugging interfaces. 16 00:01:56,880 --> 00:02:03,560 But since I mentioned that that connection burns or terminates, there's actual physical change inside that component. 17 00:02:03,580 --> 00:02:09,220 So how do you protect confidentiality of something that could be observed through microscope? 18 00:02:09,220 --> 00:02:15,840 Because, for example, if I Google EFUSE microscope, you're going to get all the images like burned and unburned examples. 19 00:02:16,060 --> 00:02:22,300 So the protection measure you mainly used in some of the chips we looked at was layering. 20 00:02:22,300 --> 00:02:27,760 So layering is normal way of making chips where you stack components on top of each other. 21 00:02:27,800 --> 00:02:35,620 However, if you put that EFUSE based memory in the very bottom layer, you can then consider it protection because you can't directly observe it. 22 00:02:35,840 --> 00:02:48,620 This is based mainly on an assumption that performing the layering process, so removing carefully the layers from the chip so that you can extract information from it, is very complex and expensive process. 23 00:02:48,620 --> 00:02:53,000 But we are here at DEF CON because we have proved this assumption wrong. 24 00:02:53,060 --> 00:02:59,080 And we will demonstrate you all these techniques on an ESP32 chip from Espressif. 25 00:02:59,080 --> 00:03:08,200 However, keep in mind that all of what we will be presenting here is also generally applicable to just about any chip that is using an EFUSE based memory. 26 00:03:08,500 --> 00:03:14,620 And with that, I'd like to pass my word to Michal, who's going to walk you through the details of the attack. 27 00:03:17,740 --> 00:03:27,500 Hello, my name is Michal Grigarek and I'm also a part of Accenture Prague. 28 00:03:27,580 --> 00:03:35,640 At first, I must say I'm really proud to be here on this stage to present you results of our work. 29 00:03:37,880 --> 00:03:42,760 So my colleague Martin just explained what EFUSE is for. 30 00:03:42,760 --> 00:03:53,180 And now let's take a look more closely how we can observe these structures in much more detail and what technologies and skills we will need. 31 00:03:57,440 --> 00:04:01,920 First, we must decapsulate the chip. 32 00:04:01,920 --> 00:04:08,460 Decapsulation is the process when we extract the silicon plate from the epoxy housing. 33 00:04:08,820 --> 00:04:20,360 Of course, there exists some other material for housings, but for purposes of this presentation, we only consider only epoxy materials. 34 00:04:20,680 --> 00:04:27,760 There we see four basic techniques for decapsulation. 35 00:04:27,760 --> 00:04:31,260 Thermal, chemical, laser and plasma. 36 00:04:31,880 --> 00:04:51,080 Thermal method, this method uses only a blowtorch or a heat gun, simply to heat up the epoxy housing and then slowly and carefully break it and obtain the epoxy silicon plate. 37 00:04:51,080 --> 00:04:59,680 Chemical decapsulation uses concentrated chemicals, concentrated acid to dissolve the epoxy housings. 38 00:04:59,680 --> 00:05:07,700 Laser etching uses a strong laser beam to vaporize the epoxy material. 39 00:05:07,700 --> 00:05:16,260 But this method is quite risky because it is very easy to burn the silicon plate. 40 00:05:16,260 --> 00:05:24,080 And my problem lies in the heat deposition to the sample. 41 00:05:24,100 --> 00:05:26,420 And the last, plasma one. 42 00:05:26,420 --> 00:05:33,220 This process involves ionized gas or plasma to selective etching of materials. 43 00:05:36,790 --> 00:05:44,910 So, due to its availability and good traceability, we decided to use a chemical method of decapsulation. 44 00:05:45,010 --> 00:05:48,630 Especially, we used concentrated acid. 45 00:05:48,630 --> 00:06:04,690 In our case, concentrated acid means 96% of concentration, which must be heated to approximately 250 degrees Fahrenheit. 46 00:06:05,250 --> 00:06:09,810 The chemical methods can be effectively combined with laser ablation. 47 00:06:10,310 --> 00:06:18,710 At first, laser removes a large part of the housing and then the remaining can be dissolved in the acid. 48 00:06:19,190 --> 00:06:29,010 This shortens the process during the GPS exposure to the acid which is needed. 49 00:06:32,390 --> 00:06:42,290 The acid will dissolve the housing residue, leaving only the dye. 50 00:06:43,290 --> 00:06:48,390 Of course, we must use appropriate protective equipment. 51 00:06:49,530 --> 00:06:59,230 After this process, we obtain a beautiful etched chip suitable for other investigations. 52 00:07:04,190 --> 00:07:17,820 Because the chip has typically metallization on its top layers, we do not see any internal layers at the first. 53 00:07:19,080 --> 00:07:27,080 So, we must etch the surface to obtain these structures. 54 00:07:27,080 --> 00:07:29,900 And this process is called the layering. 55 00:07:30,300 --> 00:07:37,400 Again, we have seen on this slide four types of basic methods of the layering. 56 00:07:37,900 --> 00:07:43,680 Mechanical is the cheapest and starting at about $100. 57 00:07:43,900 --> 00:07:50,540 Chemical, when we consider only chemical, it is also not expensive. 58 00:07:51,200 --> 00:08:07,580 Laser ablation uses very short, precise femtoseconds pulses of laser beam to ablate the surface, but it is quite costly, starting at 50k USD. 59 00:08:08,400 --> 00:08:27,490 And the last, the plasma, this is simply the nanomachining using an ion beam, offers maximum precision, but comes, of course, with maximum price tag as well. 60 00:08:27,490 --> 00:08:34,110 Due to the cost-effectiveness, we choose to do mechanical etching with a wet stone. 61 00:08:34,850 --> 00:08:40,910 I just slide a piece of silicon with my finger over the stone. 62 00:08:41,410 --> 00:08:46,510 Of course, we must use a grinding stone with the highest possible grit size. 63 00:08:46,510 --> 00:08:49,350 In our case, it is 8000 grit. 64 00:08:50,850 --> 00:08:59,310 Of course, it requires some skill, and I personally mastered it around 10 samples. 65 00:08:59,570 --> 00:09:04,690 Too much pressure quickly obtains the background, and it means we must start again. 66 00:09:05,250 --> 00:09:15,770 But with patience and systematic polishing, we can obtain a beautiful etched chip within 30 minutes or one hour. 67 00:09:18,370 --> 00:09:24,870 Unfortunately, wet stone etching alone isn't enough. 68 00:09:25,250 --> 00:09:42,810 Our stone head grain size is about 2 microns, but for the final stage, it is necessary to use a diamond lapping foil, which grain size is less than 0.5 microns. 69 00:09:42,810 --> 00:09:51,970 These foils make a significant difference, providing a much smoother surface and, of course, reducing the number of scratches. 70 00:09:54,110 --> 00:10:04,270 I tried to prepare the sample on the industrial machine, costing around 60-65 TSD. 71 00:10:04,910 --> 00:10:20,610 And as we see on these pictures, mostly the same results can be achieved when I use wet knife etching stone and the lapping foils purchased on Aliexpress for 100 bucks. 72 00:10:25,740 --> 00:10:31,440 Another important task is to locate the eFuse memory bank itself. 73 00:10:32,000 --> 00:10:39,240 The largest part of the chip is taken up by logical circuits. 74 00:10:39,240 --> 00:10:44,660 It is easily identified and can be skipped. 75 00:10:45,000 --> 00:10:47,740 The other radio frequency part is 76 00:10:50,880 --> 00:10:54,980 good visible, too, and can be skipped. 77 00:10:54,980 --> 00:11:05,380 And the rest will have the rectangular purple areas, and these are memory types such as RAM, flash, and our eFuses. 78 00:11:06,920 --> 00:11:16,680 The eFuse memory cell is essentially a fuse, which is a conductive structure with a weak point. 79 00:11:17,020 --> 00:11:23,480 In our case, it's looking like some triangle with a line going through it. 80 00:11:24,500 --> 00:11:27,480 It's looking like a flag, maybe. 81 00:11:28,100 --> 00:11:37,180 And at approximately 500 times magnification, clear, repeating, isolated structures of our eFuses become visible. 82 00:11:37,180 --> 00:11:45,960 They are relatively small, and each eFuse represents one bit smaller than one micron. 83 00:11:47,240 --> 00:11:56,780 We have successfully located these eFuse banks on ESP32 version S2, S3, and C6. 84 00:11:56,780 --> 00:12:07,160 It is positioned slightly differently on the C6, but the construction is the same. 85 00:12:09,410 --> 00:12:13,870 And now optical microscopy. 86 00:12:13,870 --> 00:12:17,850 Observation with optical microscopy has its limits. 87 00:12:18,410 --> 00:12:29,530 Maximum resolution of optical microscopy is around 400 nanometers, which corresponds with 2000 times magnification. 88 00:12:29,530 --> 00:12:32,630 That is nearly physical limits. 89 00:12:32,850 --> 00:12:40,950 This magnification is suitable for locating our structures, our eFuse bank. 90 00:12:41,190 --> 00:12:51,590 And on well-prepared sample, we can even see if the eFuse is burned or not, or programmed or not. 91 00:12:51,590 --> 00:13:09,890 The term burned is fitting, because when we program data into the eFuse memory bits, during programmation, current flows through the eFuse and physically change its structures. 92 00:13:09,890 --> 00:13:18,410 And these changes are observable by optical or scanning electron microscopy technology. 93 00:13:19,290 --> 00:13:26,350 For the size comparison, a human hair is 100 times bigger than our eFuses. 94 00:13:29,960 --> 00:13:38,740 In order to read their states correctly and repeatedly, we of course need some much more advanced imaging technique. 95 00:13:38,920 --> 00:13:44,620 And it is scanning electron microscopy, which provides much higher resolution. 96 00:13:45,900 --> 00:13:52,200 Scanning electron microscopy provides approximately 100 times better resolution. 97 00:13:52,480 --> 00:14:08,040 As I said, since optical microscopy has a resolution around 300 nanometers, scanning electron microscopy has a resolution approximately 5 nanometers, which corresponds to magnification 100,000 times. 98 00:14:08,040 --> 00:14:14,060 Of course, these parameters can apply specifically to our scanning electron microscope. 99 00:14:14,060 --> 00:14:16,440 It is Hitachi FlexSAM. 100 00:14:17,240 --> 00:14:22,680 The image compares the level of detail we can achieve with these methods. 101 00:14:22,680 --> 00:14:25,080 And the difference is significant. 102 00:14:27,180 --> 00:14:33,820 This is what the eFuse looks like at even higher magnification using a large electron microscope. 103 00:14:34,240 --> 00:14:40,720 And this image shows their 3D structures, which essentially looks like a printed circuit board. 104 00:14:40,760 --> 00:14:43,400 Everything is visible at the nanoscale. 105 00:14:43,540 --> 00:14:52,700 On the right image, right bottom, we see detail of unburned eFuse, clear eFuse, representing logical zero. 106 00:14:52,700 --> 00:14:59,800 And on the left image, we see burned eFuse, representing logical one. 107 00:15:03,040 --> 00:15:11,500 Once we obtain higher resolution images of our eFuses, we can read the data stored in them. 108 00:15:11,500 --> 00:15:24,830 In my initial experiments, I manually transcript the data to the Excel bit-by-bit, fuse-by-fuse, which was extremely time-consuming. 109 00:15:25,960 --> 00:15:33,290 And it requires intense focus to avoid error because bits look very similar. 110 00:15:34,440 --> 00:15:42,540 It takes about 10 hours to read one bit of 4,096 bits. 111 00:15:42,720 --> 00:15:50,300 And additionally, mapping the logical memory address to a specific cell on the silicon die was also very, very challenging. 112 00:15:52,360 --> 00:16:00,720 I had to carefully read and transcript about 20 kilobytes of data before we had enough for our analysis. 113 00:16:00,920 --> 00:16:04,780 It truly feels like a forensic investigation. 114 00:16:05,560 --> 00:16:12,400 And now my colleague demonstrates how to assign a logical address to a physical location of a given memory. 115 00:16:12,400 --> 00:16:13,500 Please, Martina. 116 00:16:16,160 --> 00:16:20,540 Thank you, Michal, for extracting all this data during your vacation. 117 00:16:21,740 --> 00:16:27,980 Now that we have the raw data, we have to somewhat put meaning to it so that we have some useful information out of it. 118 00:16:27,980 --> 00:16:36,220 The best place to start with is documentation because it actually mentions a lot of information about both logical and physical alignment of the memory. 119 00:16:36,480 --> 00:16:44,280 From the logical perspective, it will tell us that there are 11 of eFuse blocks and that 0, 1, and 2 are used for system purposes. 120 00:16:44,280 --> 00:16:49,360 These basically store MAC address, chip ID, and chip configuration that you can set. 121 00:16:49,740 --> 00:16:54,160 The rest of the blocks are user programmable, meaning you could put whatever you want there. 122 00:16:54,160 --> 00:17:00,520 However, their primary purpose is actually to store the secure boot keys or the flash memory encryption keys. 123 00:17:01,040 --> 00:17:14,460 From the physical perspective, the information is a little scarce, but it will tell us that there are four backups of block 0, meaning that any single eFuse burned in block 0 will actually result in four actual fuses burned. 124 00:17:14,800 --> 00:17:19,620 And blocks 1 to 10 are using Reed-Solomon coding scheme for automatic error correction. 125 00:17:19,620 --> 00:17:29,860 This is just 12 bytes added to each of the blocks, but it could prove useful in case we cause some damage during the layering process, so we'll talk about that briefly later. 126 00:17:30,140 --> 00:17:32,640 So with that, let's summarize what we want to know. 127 00:17:32,640 --> 00:17:34,240 We have a lot of bits. 128 00:17:34,240 --> 00:17:36,220 We now need to assign them to the bytes. 129 00:17:36,220 --> 00:17:46,200 Then we want to take those bytes, put them in the correct order, and have them assigned in the blocks, and then voila, we will have our flash memory encryption key. 130 00:17:46,800 --> 00:17:52,880 To do that, we performed several experiments, and the first one was a really stupid one, and I came up with it. 131 00:17:53,000 --> 00:17:59,080 And it was like, let's burn values FF into the first block of an eFuses so that we can locate where it is. 132 00:17:59,100 --> 00:18:03,300 However, at that time, we didn't really know how painful it is to actually read them. 133 00:18:03,460 --> 00:18:22,520 So we kind of wasted this experiment, because if you burn only FF values, you can very well detect where the first block is, but you really can't detect how the bit assignment works inside these bytes and how the byte order works in the blocks, because that information just doesn't exist in such a memory. 134 00:18:22,620 --> 00:18:25,180 So we quickly transitioned to the second experiment. 135 00:18:25,200 --> 00:18:41,820 In this case, we were a bit smarter, so we burned in unique patterns into the eFuse blocks, and these unique patterns had something in common, and that is that the most significant bits of all of the bytes in these patterns were set to one, either three or four of them. 136 00:18:42,380 --> 00:18:54,480 This was because, just from an overview of the memory, if you look at the middle picture, the big one, you can see a lot of red color in the upper portion, those are the ones, and that the lower portion has a lot of variety in it. 137 00:18:54,480 --> 00:18:59,580 You may think there's an ASCII text written at the bottom line, at the bottom of the picture. 138 00:18:59,580 --> 00:19:02,960 There are no hidden messages, this is purely coincidence. 139 00:19:03,620 --> 00:19:15,260 But if we take the only useful information from the very first experiment and filter out in those Excel files the rows that were associated with the first block, we can clearly see our pattern. 140 00:19:15,260 --> 00:19:25,520 So in this case, we now know that the bits are organized in columns with the most significant bits in the upper portion of the memory, and we also know the byte-endianess inside the blocks. 141 00:19:25,520 --> 00:19:30,660 This is enough for us to just extract any information we want from these memories. 142 00:19:31,300 --> 00:19:42,020 We did several other experiments, mainly to confirm that the memory is working the same way also on the other lines of the chip, so we did on S2, S3, C6, as Michael was saying. 143 00:19:42,400 --> 00:19:51,720 And the third one I'm showing you here isn't really interesting from the memory layout evaluation, but it's rather interesting because of those white fields there. 144 00:19:52,120 --> 00:20:09,760 Again, I am to blame for that, because when you do the layering on the whetstone and you don't clean the whetstone, you have a debris that's left there, and when you keep scratching with your finger, you create these gigantic canyons in that memory, where the e-fuses are just completely gone. 145 00:20:09,760 --> 00:20:16,660 In this case, that Reed-Solomon automatic error correction could actually prove useful to recover the information. 146 00:20:16,660 --> 00:20:29,880 However, for future-proofing these methods, we rather spend the time on improving the layering method, because, for example, block 0 here doesn't have any automatic error correction, and the other chips don't have that as well. 147 00:20:29,880 --> 00:20:37,580 It was just that in the case of ESP32, if you do some damage to the chip, you can actually recover for it using this automatic error correction. 148 00:20:38,320 --> 00:20:55,980 So now, this image will show you the layout of the memory, so the full green row at the top and the bottom of the picture, and six others, full green rows in between, that's block 0, so that's where those four times duplicated values actually go to. 149 00:20:56,220 --> 00:21:01,080 For example, if you disable JTAG, that's where four e-fuses will be burned. 150 00:21:01,780 --> 00:21:07,360 And the rest of the colorful blocks, and I'm sorry for using too many shades of green, but I'm bad with colors. 151 00:21:07,500 --> 00:21:12,100 Anyway, the rest of the blocks here are the user-writable blocks. 152 00:21:12,100 --> 00:21:27,020 Most tutorials on the internet will just tell you, please put your encryption key into the purple one here, so that's where we will be focusing the most, but once you know the alignment of the blocks, it doesn't really matter which blocks you extract, 153 00:21:27,020 --> 00:21:30,380 you just get the coordinates from the extracted data. 154 00:21:30,800 --> 00:21:44,120 The biggest problem at this point was that Michael refused to read that manually anymore, after whatever amount of bits he read, so we had to turn to our machine learning guru to help us automate the process. 155 00:21:44,260 --> 00:21:54,180 His name is Hayan and he unfortunately couldn't be here with us, but he pre-recorded the message, pre-recorded his part of the presentation, which I'll try to play now. 156 00:21:54,180 --> 00:21:57,220 There's about a 50% chance it's going to play. 157 00:21:57,880 --> 00:22:03,440 If it does not, I will still play it and I'll try to comment it, so you will not learn anything useful. 158 00:22:03,440 --> 00:22:04,420 So, let's see. 159 00:22:05,520 --> 00:22:13,120 Hello, I'm Hayan Ali, security delivery senior analyst in Accenture, and also I'm doing a PhD in using machine learning for violin clubs. 160 00:22:13,120 --> 00:22:18,560 I will go through the automation process and show you finally a demo about it. 161 00:22:18,560 --> 00:22:19,460 Let's go. 162 00:22:20,320 --> 00:22:26,600 Instead of a visual reading of the effuses from the images, we automated the process. 163 00:22:26,600 --> 00:22:32,700 We started from the output of microscope, where there are around 200 images for each one. 164 00:22:33,020 --> 00:22:49,360 First, we stitched these images to get only one image per bank, then pre-processing before applying the machine learning, then applying the machine learning object detection model, then extracting the effuses values into the arrays. 165 00:22:49,860 --> 00:22:54,780 The microscope provides high-resolution images when working in zigzag mode. 166 00:22:54,780 --> 00:23:04,620 In zigzag mode, the microscope scans the bank in zigzag line, as we see here in the figure, generating around 200 images for each bank. 167 00:23:04,620 --> 00:23:08,740 Each image is 2,560 by 1,920. 168 00:23:09,020 --> 00:23:21,620 We can see this image is high-resolution image, as we can distinguish between the off effuse, which is the default state, and the one which is the on case. 169 00:23:22,500 --> 00:23:28,980 We keep margin by 35% between images to avoid wasting any pixels. 170 00:23:30,300 --> 00:23:36,160 Then we stitch these images to get one image per bank. 171 00:23:36,160 --> 00:23:43,740 But when using the embedded stitching tool in the microscope, we get bad stitching. 172 00:23:43,920 --> 00:23:51,200 For example, there is misalignment between zero and 1, or 2-1, 2-2, or between first row and second row. 173 00:23:51,620 --> 00:23:58,860 The reason behind this misalignment is that the margin is theoretically 35%. 174 00:23:58,860 --> 00:24:04,240 But practically speaking, it's something random around this value. 175 00:24:05,920 --> 00:24:09,600 That's why we suggested a new stitching method. 176 00:24:10,160 --> 00:24:22,460 In this method, to stitch two images, one and two, we define a comparison step in the first image and look for the similar step in a stitching area in the second image. 177 00:24:22,460 --> 00:24:27,600 A stitching area is plus-minus 200 pixels around the margin line. 178 00:24:28,740 --> 00:24:36,080 When defining the similar step, we determine the margin accurately, and also there is a vertical shift between images. 179 00:24:36,080 --> 00:24:39,580 Here we can see the result of stitching image one and two. 180 00:24:40,050 --> 00:24:47,320 The advantage of this method is to accurate, but downside is the long time it takes. 181 00:24:47,320 --> 00:24:54,000 For example, to stitch 200 images to constitute one bank image, it will take around five hours. 182 00:24:54,620 --> 00:24:58,920 Here we can see the result of stitching for one bank image. 183 00:24:58,920 --> 00:25:06,430 Its high resolution image is 34000 by 12000 image. 184 00:25:06,470 --> 00:25:13,590 To effectively use AI to extract the fuses, we use Jetson SGX Orion from NVIDIA. 185 00:25:13,590 --> 00:25:27,310 It has 64 gigabyte RAM and 2048 CUDA cores and 64 tensor cores, which makes it good for the image-based AI projects like object detection projects. 186 00:25:27,310 --> 00:25:34,630 We use also MobileNet SSD model, which provides a balance between speed and accuracy. 187 00:25:35,170 --> 00:25:47,150 This model is trained to detect effuses in the images in terms of the coordinates of the effuses in the images, and also it's a class whether it is on or off. 188 00:25:47,230 --> 00:25:56,310 Here we see the example of on effuse, and this is off effuse, which is the default state of the effuse. 189 00:25:58,770 --> 00:26:01,980 What is the optimal input of the model? 190 00:26:03,330 --> 00:26:12,850 We read from the MobileNet SSD model documents, the optimal size for training and also for inference is 300 by 300. 191 00:26:13,390 --> 00:26:25,490 Also, we should meet another condition, which is the object, which is effuse size to the image size, should be bigger than predefined ratio. 192 00:26:25,490 --> 00:26:29,830 This ratio, in our case, is defined using practical experience. 193 00:26:29,830 --> 00:26:32,030 It is 0.04. 194 00:26:32,610 --> 00:26:41,430 Here we can see the example of the optimal image, and we can see also the size of the effuse regarding to the image size. 195 00:26:42,030 --> 00:26:46,330 We meet these two conditions using resizing and tiling. 196 00:26:46,850 --> 00:26:58,990 When tiling the stitched image, we keep 100 pixels overlapping between tiles to be sure that the whole size of effuse is exist, at least in one tile. 197 00:27:00,870 --> 00:27:08,110 When training the model, we used 3,500 training tiles with balanced number between on and off effuses. 198 00:27:08,170 --> 00:27:15,370 We used CVAT tool, which is a web-based AI free tool to annotate effuses. 199 00:27:15,370 --> 00:27:18,190 Here we can see an example of annotation. 200 00:27:18,190 --> 00:27:23,180 We use different colors when drawing boxes about the on and off effuses. 201 00:27:24,590 --> 00:27:44,880 The training results are detection accuracy 99%, classification accuracy 97%, and also we get fake detection where none effuse objects are predicted as effuses, but these fake detections will be resolved during the post-processing after prediction. 202 00:27:46,570 --> 00:27:48,930 Now, we have a stitched image. 203 00:27:48,930 --> 00:27:52,890 What do we do to extract the effuses? 204 00:27:53,330 --> 00:28:07,490 First, we tile this stitched image to 2,500 tiles, then we apply the inference using the trained machine learning model that inference results for each tile have three things. 205 00:28:07,490 --> 00:28:23,230 First, the convenience of effuses in the tile and also the classification of the effuses, whether they are on or off, and also the confidence score, which corresponds to how the machine learning model is confident about the classification. 206 00:28:24,070 --> 00:28:31,910 These three things, results from all the tiles will be re-aggregated again in the stitched image. 207 00:28:31,910 --> 00:28:41,290 Then, the duplicates will be removed with keeping only the highest confidence score. 208 00:28:41,350 --> 00:28:50,970 Finally, any effuse with a confidence score less than 95% will be visually checked. 209 00:28:51,910 --> 00:29:01,790 Finally, we will use dbScan clustering method to define outliers out of the columns and remove them. 210 00:29:01,790 --> 00:29:13,470 Then, we use another clustering method to group the effuses in columns and exporting their values into the arrays 1s and 0s. 211 00:29:13,470 --> 00:29:16,450 We repeat the same process for the another bank. 212 00:29:16,450 --> 00:29:20,230 As we know, there are lower bank and upper bank. 213 00:29:20,530 --> 00:29:28,650 Finally, we will get 64 by 64 array and then we'll go through the next steps as my colleagues explained. 214 00:29:30,530 --> 00:29:39,590 We will extract the encryption key from the array and use this key to decrypt the encrypted firmware. 215 00:29:39,590 --> 00:29:43,150 We will see these steps in the demo. 216 00:29:43,850 --> 00:29:45,190 Let's go. 217 00:29:51,310 --> 00:30:01,010 We have a firmware image where the main program prints periodically the sentence Hello Las Vegas. 218 00:30:01,090 --> 00:30:03,010 This firmware is encrypted. 219 00:30:03,010 --> 00:30:06,710 That's why when we look for Hello World, we can find nothing. 220 00:30:10,890 --> 00:30:19,530 Here, we will see the images of lower bank and upper bank of the chip holding the encrypted firmware. 221 00:30:21,910 --> 00:30:28,090 Here are the images of lower bank before stitching. 222 00:30:28,250 --> 00:30:35,370 Here, the image of stitched lower bank. 223 00:30:35,570 --> 00:30:40,150 You can see the high resolution of the stitched image. 224 00:30:40,150 --> 00:30:46,030 Now, we will apply the diffuse detection script. 225 00:30:46,310 --> 00:31:01,790 This script will go through the stitched lower bank and upper bank, do pre-processing, tiling of the images, and prepare the images to be optimal input for the model. 226 00:31:02,990 --> 00:31:12,290 These tiles will be stored in the folder for inference, this folder. 227 00:31:12,510 --> 00:31:21,470 Now, the script will run the machine learning model, which is trained. 228 00:31:21,470 --> 00:31:35,230 This model will do the inference and detect the diffuses, coordinates, diffuses classes on and off, and also the confidence scores of the classifications. 229 00:31:35,230 --> 00:31:42,810 Starting from the upper bank, then the lower bank 230 00:31:48,020 --> 00:31:57,040 , the script will store all of these inferences also in folder inference results. 231 00:31:57,660 --> 00:32:08,780 Now, the script will ask for visually checking the diffuses where there are different classifications due to tiles overlapping. 232 00:32:09,100 --> 00:32:14,400 For the lower bank, we have 11 diffuses should be checked. 233 00:32:15,940 --> 00:32:27,420 The checking should be whether the diffuse unbound means off or bound means on or not diffuse. 234 00:32:32,140 --> 00:32:36,820 For the upper bank, we have zero diffuses to be checked. 235 00:32:50,430 --> 00:32:57,150 Check visually if the diffuse with confidence score is than 95%. 236 00:32:57,150 --> 00:33:05,530 We have eight diffuses to be checked in the lower bank, and 13 in the upper bank. 237 00:33:28,320 --> 00:33:33,520 After that, the script will show us the distribution of the diffuses in the image. 238 00:33:33,660 --> 00:33:41,160 We can note that no all players, and also in the upper bank. 239 00:33:41,380 --> 00:33:50,100 As everything is okay, the script will export the values of diffuses as zeros at once. 240 00:33:53,310 --> 00:34:07,550 The script also will extract the flush key file which contains the encryption keys from the firmware, and here the 64 by 64 array of ones and zeros. 241 00:34:10,230 --> 00:34:24,290 We will use the flush key file to decrypt the encrypted firmware and get the decrypt.bin file which is the decrypted firmware. 242 00:34:29,450 --> 00:34:31,850 Here is the decrypted.bin file. 243 00:34:32,050 --> 00:34:39,830 We should look for hello world in this file, and we should find something. 244 00:34:43,440 --> 00:34:44,740 And here we are. 245 00:34:44,860 --> 00:34:45,980 Thanks. 246 00:34:46,460 --> 00:34:51,240 I will go back to my colleagues to conclude the presentation. 247 00:34:53,060 --> 00:34:58,060 Okay, I know it's 3 a.m in Prague, but Hayan, if you're watching, thanks for the video. 248 00:34:58,980 --> 00:35:01,500 Now to conclude real quick. 249 00:35:01,660 --> 00:35:17,140 If you have any information that you would like to store if you have an information that you would like to keep secret and you need to store it in a chip and you have a choice to do so, please do not put it in any fuse-based memory. 250 00:35:17,160 --> 00:35:24,920 In the case of ESP32 chip, if you want to encrypt the flash memory, and you really should if you want to, you have no other choices. 251 00:35:24,920 --> 00:35:34,400 So in this case, you should use countermeasures such as using a unique key per each chip, not just use the same key for every device. 252 00:35:35,090 --> 00:35:55,580 If you have a choice to store it in some HSM module, physical unclonable functional protected memory, or anti-fuses, whatever you have, it would be a better way, because an eFuse-based memory is just readable based on its physical properties, and the readability protection methods such as layering, 253 00:35:55,580 --> 00:36:02,540 they do increase the effort by putting obstacles in between the malicious actor and the information that you're trying to protect. 254 00:36:02,540 --> 00:36:04,120 They don't prevent reading. 255 00:36:04,400 --> 00:36:18,800 In this case, we had to destroy the chip in process of recovering this information, but since our goal was to recover an unencrypted firmware image, we didn't really care about that, because we don't need it to run, we just want to read the firmware. 256 00:36:19,840 --> 00:36:44,580 The assumption about the delayering being expensive, complex, and whatnot has basically been destroyed, because if you have a sink, a wet stone, and at least two fingers, you could do that in your home conditions, and if you also can rent a microscope on your local university for a couple hours to just scan some location on chip, 257 00:36:44,580 --> 00:36:47,900 then you can do the recovery of the information at home. 258 00:36:47,900 --> 00:36:54,320 So it's rather easy and cheap if you're willing to sacrifice a bit of your fingers. 259 00:36:55,100 --> 00:36:58,280 Are there two things I'd like to point out still? 260 00:36:58,280 --> 00:37:07,140 The first one is to thank to Espressif, because they allowed us to have this talk, and the communication with them was really smooth, so thanks for that. 261 00:37:07,160 --> 00:37:18,180 And finally, I'd like to admit to a lie, because at the very beginning, I told you that if you burn an eFuse from state 0 to 1, you cannot unburn it. 262 00:37:18,420 --> 00:37:20,420 I lied, because you can. 263 00:37:20,880 --> 00:37:37,640 But the processes around this are really complex and really expensive, so I'd like to keep this as a separate topic for perhaps next time, and we can transition into the Q&A session, which, as I've heard, we will be doing as we will be going. 264 00:37:37,640 --> 00:37:39,960 But wait, we also have a giveaway. 265 00:37:39,960 --> 00:37:48,820 We have 20 decapsulated ESP32 chips in a vials that look like that they hold some bacteria, but we promise that they did not. 266 00:37:49,380 --> 00:37:56,200 And you could just take them and try the layering process at home if you want to, or just as a souvenir. 267 00:37:56,580 --> 00:38:00,420 So thank you for your attention, and we will be answering questions as we go.