[00:00.000 --> 00:04.540] Hi everyone. There are more people than I expected at 10am. [00:04.800 --> 00:07.280] Thank you very much for being here. [00:08.480 --> 00:13.380] You are the ones who survived until the last day in DEFCON. Awesome. [00:14.660 --> 00:22.800] Welcome to taking off the blindfold, detecting persistent threats on drytech edge devices. [00:23.600 --> 00:29.460] We are part of the Faraday research team. My partner here is Octavio Geno-Tiempo. [00:29.460 --> 00:36.080] I am Gaston Asnares. And we have some experience working with firmware. [00:36.080 --> 00:42.300] We have a foundation in computer science and we like to play CDF. [00:42.560 --> 00:46.860] As a resume, we like to break things and do research. [00:48.880 --> 00:54.660] So, what are we going to see today? First, we are going to see a motivation for this research [00:54.660 --> 01:00.060] and this talk. We are going to see some reverse engineering on drytech firmwares. [01:00.640 --> 01:04.940] We are going to talk about vulnerabilities and attack vectors. [01:05.560 --> 01:11.260] We are going to see mitigation strategies and at least we are going to see some conclusions [01:11.260 --> 01:22.100] and takeaways. Okay, how this started? We had a call of a client saying that it was compromised. [01:22.100 --> 01:31.220] And when we came to the scene, we saw a lot of outdated drytech equipment on the edge of the [01:31.220 --> 01:40.980] network. Most of them were SOHO models that run RTOS. And we started making some analysis. [01:40.980 --> 01:49.720] We found previous vulnerabilities with proven exploits on high-end models of the drytech [01:49.720 --> 01:57.800] routers that runs Linux. And we started making some questions about it. Like, are these [01:57.800 --> 02:06.020] vulnerabilities exploitable on the SOHO routers? There are other vulnerabilities that are known. [02:06.020 --> 02:10.940] And the principal question was, were these routers the entry point of the attackers? [02:12.620 --> 02:20.260] Okay, we know that there is an increasing threat of advanced attack targeting edge devices. We [02:20.260 --> 02:27.440] could name some examples, like the SOHO RAT, that was a socketical malware targeting SOHO routers. [02:27.620 --> 02:33.660] We also could name the HIATUS RAT, that was a malware targeting drytech routers, but [02:34.050 --> 02:44.100] the high-end models. And at least we could name Benin Sartain, that was an NSA tool [02:44.700 --> 02:51.060] targeting Cisco routers, that was leaked by the Shadow Brokers Group. [02:53.030 --> 03:03.530] Okay, so what is the attack surface of these routers? We found over 5,100 exposed devices. [03:04.540 --> 03:10.440] Mostly in the UK. And we found a lot of vulnerabilities. From an information [03:10.440 --> 03:16.780] disclosure to an authenticated remote code execution. So, there is a lot of stuff. [03:18.020 --> 03:27.500] Okay, so we had a Vigor 2925 in our office running MIPS 32 RTOS. [03:28.620 --> 03:34.640] And we wanted to start making some research on that, but we had a problem. [03:34.980 --> 03:42.120] The code is closed source. So, first we had to reverse engineer the firmware format. [03:42.360 --> 03:48.620] We had to extract the firmwares, understand previous vulnerabilities, and then look for [03:48.620 --> 03:59.250] new ones. And finally, determine if this was the attack vector or not. So, the first thing we did [03:59.250 --> 04:04.810] was trying to extract this firmware using MinWalk, but it failed. It produced no results. [04:04.830 --> 04:09.090] So, we tried to look for some specialized tools, and we found this one, DRYTOOLS. [04:09.150 --> 04:14.410] So, this didn't work with new firmwares. The last commit was 12 years ago, and that's why. [04:15.050 --> 04:22.370] So, luckily for us, we found a talk by Philippe Loret at Hexagon 2022, where he described that [04:22.370 --> 04:28.390] by emulating DRYTEXTBOOKLOADER, we can extract, we can make it extract the RTOS kernel. [04:28.390 --> 04:32.830] The disadvantage of this approach is that this is a manual process, and you have to [04:32.830 --> 04:39.170] tweak the addresses for each firmware version. And the other problem that it has is that these [04:39.170 --> 04:45.350] firmware images have other executable components, apart from the RTOS kernel, and file systems [04:45.350 --> 04:52.050] that you cannot extract this way. So, our approach was to reverse engineer the format, [04:52.050 --> 04:57.270] and to try to write a tool that can extract all firmware versions from different models, [04:57.270 --> 05:01.680] extracting all file systems, and extracting all the executable components. [05:03.150 --> 05:07.170] We named our tool DRYTEXT Arsenal. It's a collection of tools. [05:07.170 --> 05:13.270] We wrote this in Python. It's open source. You can check it out at that repository. [05:13.750 --> 05:18.250] And the idea is to support for all these new firmware versions. [05:18.650 --> 05:23.710] And we will be showing, along these presentations, all the features that we implemented. [05:25.590 --> 05:31.650] So, let's talk about the firmware format. It has two main sections. One is called the [05:31.650 --> 05:38.350] binary section, and the other one the web section. Both start with a header that contains the size [05:38.350 --> 05:43.330] and the pointer to the following section. But in the first one, we also have information about [05:43.330 --> 05:51.610] the firmware version, and some metadata. So, the web section has a file system that [05:51.610 --> 05:56.970] is compressed and contains all the static files that the router serves for the web UI. [05:57.690 --> 06:04.530] In the first section, the binary section, we have the bootloader that is raw MIPS32 code. [06:04.530 --> 06:11.930] This is the part that Philippe emulated. And then this is followed by the compressed RTOS kernel. [06:12.250 --> 06:16.930] And after that, we have a very interesting part of the firmware, that is the DLM code. [06:16.930 --> 06:23.430] This is also a file system, but it's compressed and encrypted. And we will talk a lot about it. [06:24.550 --> 06:31.690] So, to work with this, we made a specification of the structure of the firmware using KTI Structs. [06:31.690 --> 06:36.030] And the advantage of using this is that you can manipulate the firmware images with any [06:36.510 --> 06:40.750] language that you want from the list. We used Python, but you can find this in the repo and [06:40.750 --> 06:48.290] use the language that you prefer. And, well, by knowing all this, we started to tackle the [06:48.290 --> 06:55.350] reverse engineering of the compression algorithm. So, during boot, the RTOS is decompressed to the [06:55.350 --> 07:01.590] same memory space as the bootloader. And we did this following the steps described by Philippe [07:01.590 --> 07:09.030] in his talk. But when we started reverse engineering this, we mapped all this in memory, [07:09.030 --> 07:15.670] and then the RTOS after that. And that allowed us to discover that the decompression function [07:15.670 --> 07:20.350] is used during runtime to decompress other things, for example, the file systems. [07:20.830 --> 07:26.130] And we also discovered some interesting strings, like the one that you can see down to the right, [07:26.130 --> 07:32.970] that says LC4 decompression failed. But if it was LC4, the compression algorithm, why we couldn't [07:33.390 --> 07:43.530] work. And the reason for this is that while they use a standard LC4 compression block format, [07:43.530 --> 07:53.730] they have written a custom frame format. So, it's just a custom magic that is followed by a [07:53.730 --> 08:02.950] succession of block size and block data multiple times. So, we wrote a decompressor and a [08:02.950 --> 08:08.010] we moved on to the most interesting part, that is the DLM section. [08:08.570 --> 08:15.730] So, it turns out that the DLM stands for Dynamic Kernel Modules. So, this real-time operating [08:15.730 --> 08:25.090] system has the ability to load code modules during runtime dynamically. And this feature [08:25.090 --> 08:32.050] works independently from the firmware. So, during boot, we can see that some [08:32.950 --> 08:38.870] the modules that come with the firmware image are loaded. There are three modules, [08:38.870 --> 08:47.370] and they are called VR9 GeoIP, VR9 App-E, we will talk a lot about this one, and VR9 SSH. [08:47.370 --> 08:53.670] So, the first one contains information about the geolocation of IPs. The second one is used [08:53.670 --> 09:00.730] to block traffic from the users that are in the LAN. And the last one contains the implementation [09:00.730 --> 09:06.670] of SSH server. And this is really interesting because this implementation is separate from [09:06.670 --> 09:17.350] the firmware. So, these modules can be updated during runtime, and if you install a new version [09:17.350 --> 09:25.250] of App Enforcement Module or SSH, these are loaded first and prevent the modules that come [09:25.250 --> 09:31.710] with the firmware to be loaded. You can see down to the right that, for example, in this case, [09:31.710 --> 09:39.790] the VR9 App-E module was loaded first, and then when the router tries to load the version that [09:39.790 --> 09:47.130] comes in the firmware image, it will fail. So, doing some more reverse engineering, [09:47.130 --> 09:53.370] we found out that the modules are compressed using the same algorithm that is used for the RTOS, [09:54.250 --> 10:00.670] but they are also encrypted. So, we recognized that the algorithm used was a modified version [10:00.670 --> 10:06.610] of XTAA, and this is a symmetric encryption algorithm. And what this means is that the [10:06.610 --> 10:12.990] keys for decrypting these DLMs are present in the firmware. So, we looked for them, and we wrote a [10:12.990 --> 10:18.510] decryptor and encryptor for the modules. So, if you take a DLM, you decrypt it using this, and [10:18.510 --> 10:24.750] decompress it using the modified version of LC4, then what you get is a relocatable ELF. [10:25.010 --> 10:29.630] And this is very interesting because all the external functions that this ELF uses, [10:30.390 --> 10:34.850] they have to have their symbol names. So, they are really easy to reverse engineer. [10:37.030 --> 10:41.230] And this also means that the firmware must have an ELF loader. [10:41.230 --> 10:46.090] So, we looked for that code, and we found that there is also a symbol table. [10:46.090 --> 10:51.490] This symbol table was described before by Philippe Loret, but only as an aid for reverse [10:51.490 --> 10:57.210] engineering, because imagine that you have a table where you have function names followed by [10:57.210 --> 11:04.710] function pointers. But now we know that this table is actually used by the ELF loader to link these [11:04.710 --> 11:12.850] modules to the kernel. So, the advantage that this gives to us is that if we manage to write [11:12.850 --> 11:17.430] our own modules, we can use all these functions without knowing their actual addresses. [11:19.450 --> 11:28.590] So, we implemented all these in our tool. We have two functions, one called parse firmware [11:28.590 --> 11:33.090] that will print a lot of information about the firmware image, and the other one called extract [11:33.090 --> 11:39.790] that will extract all these pieces of the image. It will decrypt and decompress all the modules. [11:39.790 --> 11:47.730] It will extract all the file systems for the web server, and it will generate a binary image [11:47.730 --> 11:51.890] that contains the bootloader, followed by the RTOS kernel, but decompressed. [11:53.410 --> 11:58.910] So, if you want to start reverse engineering this, you must know the loading address. [11:59.210 --> 12:05.390] What we realized is that all dry type bootloaders start by calling the decompression function. [12:05.450 --> 12:08.790] So, this function is always located near the start of the image, [12:08.790 --> 12:16.710] and since all this has to be loaded aligned to the page, then we can search for the address of [12:16.710 --> 12:23.130] this compression function, and if we remove the last three numbers, what we get is the loading [12:23.130 --> 12:27.890] address of the whole image. So, with that, you can start your reverse engineering process. [12:28.990 --> 12:34.770] We also implemented this in a functionality called find loading address, [12:34.770 --> 12:41.170] and once we had all that, we moved on to try to find some vulnerabilities and attack vectors. [12:48.700 --> 12:55.060] Okay, so let's talk something about vulnerabilities. We are going to show some of them. [12:56.120 --> 13:02.480] Starting with the basics, we found that they had an insecure password storage. That means [13:02.480 --> 13:06.520] they stored the passwords and the credentials in plain text in memory. [13:07.070 --> 13:13.660] So, if someone had access to the memory, they could read the credentials or maybe [13:13.660 --> 13:21.360] chain another exploit to leak them. We also found a non-constant time comparison [13:21.910 --> 13:31.680] on the credential. So, they use a function that takes different amounts of time to compare [13:31.680 --> 13:38.880] different passwords, depending on how much correct characters are in the string. [13:39.380 --> 13:43.660] And that leads to a side attack channel, a timing attack. [13:45.640 --> 13:53.500] Okay, so, DirectX implements a second-step authentication. That's really nice, but that [13:53.500 --> 14:00.020] was predictable, because the code generation was done using a self-random function, [14:00.540 --> 14:10.680] but with the seed, they use the time elapsed science boot. So, if you know for how long the [14:10.680 --> 14:17.760] router is running, you could predict the second-factor authentication calls. [14:18.540 --> 14:25.480] We also found an older reference in the HCP server that leads to a [14:26.200 --> 14:32.500] denial-of-service attack, but the interesting thing about that is that it was exposed to one. [14:32.500 --> 14:38.940] So, if the router was exposed to the internet, you could trigger that another reference. [14:40.080 --> 14:47.320] And if we combine both vulnerabilities, we could predict the second-step authentication calls, [14:47.320 --> 14:55.160] because we could make the router crash, and then we know the time elapsed science boot, [14:55.160 --> 15:02.160] and we predict the calls. And that's what we are going to see in the next demo. [15:02.840 --> 15:06.520] We could see on the right, the serial communication with the router. [15:07.800 --> 15:14.320] Um, on the... no, that's on the left. On the right top is the script that we run. [15:14.540 --> 15:23.380] It triggers the known reference, and the router is rebooting. It will take [15:23.940 --> 15:27.960] like two or three reboots, because it crashed hard. [15:29.440 --> 15:37.200] And on the right bottom, we have the web UI, where we are going to try to log in. [15:40.460 --> 15:47.780] So, now it boots. We are going to wait until the router initializes itself. [15:49.180 --> 15:53.380] Okay, and now we are trying some different calls. [15:59.970 --> 16:04.750] And we were able to predict the call, and we are logged in. [16:08.390 --> 16:16.790] Okay, so Octavio talked something about the APP Enforcement Signature feature. It's really great. [16:16.790 --> 16:25.110] If you have an enterprise and you want to block your employees' web, or I don't know, [16:25.110 --> 16:30.310] you could update the signatures in order to block that traffic. [16:31.170 --> 16:38.130] And how this process is made, there are two ways. The first one is a manual. We will see [16:38.130 --> 16:45.130] on the right bottom that says import. If we click there, we could upload any file [16:45.910 --> 16:55.110] with some checks. And the second way is the automatic way, in which we have to select [16:55.110 --> 17:06.670] the update server or select the default one, and we have to schedule the updates. So, for example, [17:06.670 --> 17:13.710] every day at some point of the day, it will check if there is some update for the signatures. [17:16.170 --> 17:25.430] And how they implement these signatures, you could think in JSON formats or YAML or something [17:25.430 --> 17:34.110] like that. But Drytech has the idea to implement this as a module. So, to update the signatures, [17:34.110 --> 17:43.760] they upload an L file with code and everything. Okay, let's talk about some vulnerabilities [17:43.760 --> 17:54.040] related to the modules. The first one is they not also update certificates with code, but they [17:54.040 --> 18:01.500] don't check for certificates or have SSL enforcement. So, if someone manipulates the [18:01.500 --> 18:08.980] configuration of the router or the DNS, maybe DNS hijacking, they could upload a module to [18:08.980 --> 18:18.740] all the Drytech routers that has this feature. And we have found two post-authentication [18:18.740 --> 18:24.620] endpoints. The first one is the one that I told in the last slide. And the second one is [18:24.620 --> 18:32.840] that we found an endpoint to upload configurations files that doesn't have some checks, so they [18:32.840 --> 18:41.240] allow us to upload an arbitrary DLM. Now it's not only the APPA module, but we could upload any [18:41.240 --> 18:51.440] modules that we want. Maybe we could, I don't know, upload another SSH module. So, we have three [18:51.440 --> 18:56.060] ways for an attacker to install malicious modules. The first one is the post-authentication [18:56.060 --> 19:04.760] endpoints that we talked just in the last slide. We have the module upload process that is hijacking [19:04.760 --> 19:11.500] the configuration or the DNS. And the last one is the supply chain. Because the modules are very [19:11.500 --> 19:19.840] easy to craft, so if they are easily appended to to the firmware, and anyone with physical access [19:19.840 --> 19:28.880] or, I don't know, exploiting some vulnerability, they could upload the module before selling it. [19:31.910 --> 19:37.750] Okay, so knowing all of this, we could start making some modules. We implemented two commands. [19:37.750 --> 19:47.470] The first one is the MIPS compile that is going to make a compilation of source code into a [19:48.190 --> 19:58.290] ELF of the architecture of MIPS32. And we also have another command that is ELF to DLM. As the [19:58.290 --> 20:04.190] name says, it will convert an ELF to a DLM, compressing and encrypting with the provided [20:04.190 --> 20:13.190] keys. So, we could append some web headers so we could upload them through the web UI. [20:14.930 --> 20:24.470] So, we are going to see a demo. We could see on the left the version of the APPA module. [20:25.250 --> 20:31.710] On the right, in the middle, we are going to run a server, a custom server, [20:31.710 --> 20:34.850] that is pointing the configuration of the auto-updates. [20:42.430 --> 20:49.450] So, on the top right, we could see the serial interface with the router. [20:50.750 --> 20:57.890] Okay, so once the server is up, we are going to trigger a new DLM. [20:59.350 --> 21:05.390] So, it's triggered. We could see the router has fetched the new module in our server. [21:05.390 --> 21:10.930] We could see the Faraday logo because it's our module. And if we log in again, [21:11.710 --> 21:16.610] we could see that the version of the module has changed and we have some logs that said [21:17.390 --> 21:27.750] that it doesn't allow this shit. Okay, let's make something more funnier. [21:28.570 --> 21:35.330] We are going to make a SSH backdoor. Why not? Because we have the module. [21:35.330 --> 21:43.030] So, the original behavior of the SSH module is the top one. When we have a new connection, [21:43.310 --> 21:49.070] it's going to call the authentication function and the authentication function will say that [21:49.070 --> 21:57.530] it fails or it authenticates. But what we are going to do is when a new connection enters, [21:58.310 --> 22:04.810] when a new connection is open, that is going to call our hook and it's going to check our [22:04.810 --> 22:11.410] credentials. So, if they are right, it authenticates. If not, it's going to call [22:11.410 --> 22:16.830] the original function because we don't want to change all the behavior of the SSH module. [22:19.230 --> 22:24.350] How is the roadmap for this? First, we have to do a reverse engineer of the SSH module [22:24.350 --> 22:28.790] to find that function that makes the authentication. We are going to skip that [22:28.790 --> 22:33.110] part and we are going to say that the target function is the SSH account and LDAP auth [22:33.110 --> 22:43.150] function. After that, we have to write and compile the hook. We have to merge the hook [22:43.150 --> 22:50.590] with the original module and we have to modify all the relocations in the entry table. [22:51.590 --> 22:54.850] And last, we have to upload the DLM. [22:56.750 --> 23:04.690] On the right, we can see the source code of our hook function that takes the same arguments as [23:04.690 --> 23:13.870] the target function, an SSH instance, and a packet. And it will check for our credentials. [23:14.170 --> 23:20.970] If they are right, it will return one that says it authenticates. If not, it will call the target [23:20.970 --> 23:29.970] function. In order to compile this, we use our command MIPS compile. [23:32.510 --> 23:38.410] And then, we have to merge both binaries, both relocatable ELFs. [23:38.950 --> 23:46.350] So, there is a relocatable ELF. It has all the symbols with no fixed address. [23:46.350 --> 23:56.270] So, they had a relocation table that will say everything that uses a symbol has to be modified [23:57.810 --> 24:06.710] to point to that symbol after linking. So, we have all the symbols there. And once we merge it, [24:06.710 --> 24:19.190] we have the symbols of both modules. We wrote a command to do this with the name of MIPS merge [24:19.190 --> 24:26.290] that takes two ELF files and as an output has one file. [24:28.600 --> 24:36.880] Okay. Now, we have to modify the relocation table. So, first, we find all the relocation that [24:37.840 --> 24:44.820] talks about the target function. We can see on the top right the two examples. We are going to [24:44.820 --> 24:55.840] use the first one. If we print the code that is on that address on the bottom left, we can see [24:55.840 --> 25:04.220] that the jump is a jump instruction, but the jump instruction only has his opcode but doesn't have [25:04.220 --> 25:10.480] an address where to jump. That is because the relocation entry will set which one is going to [25:10.480 --> 25:16.780] be that address on link in time. And we can see there that is the target function. So, we modify [25:16.780 --> 25:31.080] that entry to give us a result the right that points to the hack function. So, time to hack. [25:31.080 --> 25:39.160] Yeah. Okay. So, on the top right, we have we are trying to log in with our credentials, [25:39.160 --> 25:46.180] but we could see that it fails. So, on the bottom left, we upload our backdoor module. [25:49.100 --> 25:53.900] And once it's uploaded, we could see that the file was written successfully, [25:54.460 --> 26:04.210] but we have to reboot the router. And once it reboots, we are going to try again [26:04.210 --> 26:19.440] with our credentials. We could see that the module was loaded. Okay. So, we tried to log in, [26:19.440 --> 26:26.560] and we could see that we were in. And we could see some loss in the serial communication. [26:33.980 --> 26:40.280] So, this attack that Gaston showed is really dangerous. Imagine that an attacker can craft [26:40.680 --> 26:49.240] a modified SSH module, upload it to your router, and you have no way of detecting this. Moreover, [26:49.240 --> 26:55.660] if you update the firmware, the module will be still there. It will persist. And even will persist [26:55.660 --> 26:59.780] if you reset the configuration of the router, because it's stored in a separate file system [26:59.780 --> 27:06.920] in the flash. So, we started to think about some mitigation strategies. The first one, [27:06.920 --> 27:12.260] the obvious that we thought about was just to remove the feature, because who wants to have [27:12.260 --> 27:19.820] dynamic modules on their router? But there might be some users that use this feature. So, [27:19.820 --> 27:26.060] well, instead of nubbing all the calls to module loading during boot and during the [27:26.440 --> 27:35.640] update process, we decided to think for a better solution. And we devised a mechanism [27:36.080 --> 27:42.420] for checking in-memory integrity of the other modules that are loaded. This mechanism should [27:42.420 --> 27:46.820] fetch signatures from a server, because the modules will get updates, so you have to update [27:46.820 --> 27:54.860] the signatures. But this time, you have to check the certificates. So, once you got those [27:54.860 --> 28:01.260] signatures, you have to find the loaded modules in memory, calculate the actual signatures, [28:01.260 --> 28:07.340] and compare them. And if there is a mismatch, then you have to notify the user somehow, [28:07.340 --> 28:10.960] and all this functionality should be included with the firmware. [28:12.060 --> 28:20.280] So, what we did, as a proof of concept, was to use the open source module to introduce this code [28:20.280 --> 28:25.060] to the router, because it's much easier to write a module than to patch the firmware, [28:25.060 --> 28:30.240] because you have all these functions from the symbol table that you can use. [28:30.800 --> 28:38.200] So, there are two things that we have to solve. The first one is how to calculate a [28:38.200 --> 28:45.780] signature for a valid DLM, and the second one is to find the actual DLMs in memory and do the [28:45.780 --> 28:53.380] comparison. So, we focused on that, and we accepted some limitations. We will not check [28:53.380 --> 28:58.780] the signatures every time a module is loaded, as it should be. We will only check signatures [28:58.780 --> 29:04.960] when our defensive module is loaded, and we will not try to notify users for now. [29:06.420 --> 29:12.340] So, the first problem that we have to solve is how to calculate a hash or a signature for a DLM. [29:12.340 --> 29:19.680] We will hash each signature with MD5, because MD5 was available on this table, [29:19.680 --> 29:24.900] on this symbol table, and we will hash only the static sections, because the dynamic sections [29:24.900 --> 29:31.020] will change once loaded. If the static section contains data, we will hash it right away, [29:31.020 --> 29:37.140] but if it contains code, then, as Gaston explained during the module installation, [29:37.140 --> 29:43.860] when it's linked, all the jams and the function calls will get the actual addresses of the [29:43.860 --> 29:49.760] functions written to them. So, we will hash only the opcodes for these sections, and the opcodes [29:49.760 --> 29:59.060] are the first six bits. So, once we got that, we have to find all the modules that are loaded. [29:59.380 --> 30:06.380] When the ELF loader installs a module, it creates an object to represent the module, [30:06.380 --> 30:11.280] and the space for this module is allocated using the linear allocator of the router. [30:11.620 --> 30:18.100] So, this allocator maintains a list of all the chunks that it has assigned, [30:18.100 --> 30:25.080] and if we manage to find this object that represents the DLM, we'll get the DLM name, [30:25.280 --> 30:30.780] a pointer to the text section of that module, and a pointer to the main section that will get [30:30.780 --> 30:39.760] executed after the module is loaded. So, the loader copies all the sections in a predefined [30:39.760 --> 30:45.580] order, one after the other, after the text section. This order is usually defined by the compiler, [30:45.580 --> 30:53.380] and we will assume that this order doesn't change. So, on the bottom, you can see a little [30:53.380 --> 30:59.800] bit of the code of this defensive module, the part where we traverse the list of chunks from [30:59.800 --> 31:07.200] this allocator, and we will check if each chunk corresponds to the module object. If the chunk [31:07.200 --> 31:12.020] corresponds to the module object, we will print some information, and if this module happens to [31:12.020 --> 31:19.580] be the SSH one, then we will calculate the hashes and compare them. So, here's the demonstration. [31:19.580 --> 31:26.320] This router is the one that has been backdoored and has a modified version of the SSH. Then we [31:26.320 --> 31:33.960] upload our defensive module using the UI on the left, and you can see right there that once it's [31:33.960 --> 31:39.540] uploaded, it will try to find all the modules, printing their information, and when it reaches [31:39.540 --> 31:45.280] the SSH module, it will start comparing the hashes for each section, and it will find that [31:45.280 --> 31:49.600] there is a mismatch between the hashes on the second section. [31:51.920 --> 31:59.240] So, to wrap this up, some conclusions and takeaways. All these vulnerabilities were found [31:59.240 --> 32:05.760] by us analyzing only the bigger 2925 router, but they are present in several models because [32:05.760 --> 32:12.000] all the SOHO routers use this real-time operating system, and even some of the [32:12.980 --> 32:20.220] higher-end routers that run Linux emulate the same real-time operating system. So, we found [32:20.220 --> 32:24.860] all these vulnerabilities and some more that we didn't show, and they are all patched by now, [32:24.860 --> 32:34.180] but we don't have CEIDs yet. And, well, some conclusions on the offensive side. The code for [32:34.180 --> 32:40.460] this real-time operating system is huge, it's really complex, and we only analyzed a little [32:40.460 --> 32:46.840] bit of it. Imagine that the functions that are present in the symbol table are maybe not up to [32:46.840 --> 32:52.040] five percent of all the functions in this firmware, so there are probably more vulnerabilities here [32:52.040 --> 32:58.680] to be found. And that is why we are open-sourcing our tool, and we would love for you to try it, [32:58.680 --> 33:04.020] and we would love to know if it's useful and if you find something. So, there's the repository [33:04.020 --> 33:10.680] if you want to check it out. And now, some conclusions on the defensive side. We show [33:10.680 --> 33:15.620] that it's possible to create a defensive module to check the integrity of other modules in memory, [33:15.620 --> 33:20.760] but in an ideal situation, this feature should be implemented by the vendor. It should fetch [33:20.760 --> 33:27.500] these updated signatures from a trusted server, verifying the certificates, and for all this to [33:27.500 --> 33:34.260] work, if this feature is included in the firmware, also we must have a secure blockchain to trust [33:34.260 --> 33:42.380] that this is working right. And to close, some takeaways. We think that closed-source firmware, [33:42.380 --> 33:48.100] as this example, is just another case of security by security. All these vulnerabilities that we [33:48.100 --> 33:56.360] have found are really simple, and they would have been reported sooner by the community if it were [33:56.360 --> 34:03.540] easier to reverse-engineer these routers. So, some things such as plaintext password storage, [34:03.540 --> 34:09.940] the use of insecure functions to compare sensitive data, predictable random number generation, [34:09.940 --> 34:17.320] and even the lack of SSL certificate validation. So, given all the increase in attacks that we are [34:17.320 --> 34:22.620] seeing to edge devices, it would be really important for vendors to include features [34:22.620 --> 34:27.220] that facilitate observability, vulnerability research by the community, and to implement [34:27.220 --> 34:34.000] threat detection solutions. So, this is it. Thank you for your time, first for coming so early, [34:34.000 --> 34:40.380] and if you have any questions, please ask us. There's a mic here, if you want to ask. [34:42.600 --> 34:44.940] The first question gets shared. [34:49.300 --> 34:50.860] Well, thank you, guys. [35:11.810 --> 35:15.710] Okay, the question was if there is memory protection between the modules and the [35:15.710 --> 35:20.170] RTOS, and there's not. All these runs on the same memory space, so from a module, [35:20.170 --> 35:36.840] you could modify the RTOS code and vice versa. Yeah. Well, thank you again for coming.