1 00:00:00,960 --> 00:00:03,840 Hello, DEF CON. 2 00:00:03,840 --> 00:00:06,160 Thank you for coming to our presentation. 3 00:00:06,160 --> 00:00:13,540 We are excited to share our talk titled, Watchers Being Watched Exploiting the Surveillance System and Its Supply Chain. 4 00:00:13,540 --> 00:00:18,100 We'll talk about our vulnerability research on surveillance system devices. 5 00:00:18,100 --> 00:00:19,460 Please enjoy. 6 00:00:19,680 --> 00:00:22,700 First, let us introduce our research group. 7 00:00:22,700 --> 00:00:27,460 I'm Chanhee Kim, and I'm currently working as an offensive researcher at S2W. 8 00:00:27,460 --> 00:00:34,980 And he's Myungwoo Park, and he's a student attending a university in Korea enjoying offensive research. 9 00:00:36,760 --> 00:00:39,780 And this is what we'll show you in this talk. 10 00:00:39,780 --> 00:00:46,400 We'll be talking about a $30,000 bounty and a four-month journey to become a DEF CON speaker. 11 00:00:46,400 --> 00:00:59,300 In our talk, we'll cover how we extract the firmware, then the steps we took to analyze the vulnerabilities, and after that, the various vulnerabilities that could be exploited in the world and their scenarios. 12 00:00:59,420 --> 00:01:03,200 In the last, the impact of our research on the supply chain. 13 00:01:03,200 --> 00:01:04,160 That's it. 14 00:01:04,160 --> 00:01:05,720 Please look forward to it. 15 00:01:07,040 --> 00:01:11,400 This video will be the final goal, which happened in the real world. 16 00:01:11,400 --> 00:01:14,660 We wanted to see why we're doing this research. 17 00:01:14,660 --> 00:01:24,180 This was posted by an Iranian hacker, and we would like to show that we have successfully demonstrated what the video is showing. 18 00:01:24,180 --> 00:01:25,680 Let's watch the video. 19 00:01:44,510 --> 00:01:47,490 That's like a hacker from a movie, isn't it? 20 00:01:48,870 --> 00:01:53,710 Next, why is making our surveillance device more securely important? 21 00:01:53,710 --> 00:01:57,510 We can see surveillance devices everywhere in our lives. 22 00:01:57,510 --> 00:02:10,510 Because of the COVID-19 pandemic outbreak, the demand of the surveillance devices has been surging for various purposes, such as a men's store, smart cities, and for those access control. 23 00:02:10,850 --> 00:02:16,510 Thus, the global surveillance device market is currently worth $4.1 billion. 24 00:02:16,630 --> 00:02:26,970 So, in these circumstances, surrounding by such devices, MVRs are taking on a more essential role in our lives and those users. 25 00:02:28,490 --> 00:02:30,530 Next is our target. 26 00:02:30,530 --> 00:02:41,470 Many people don't know much about MVR, but as we just highlighted, MVR is more than just important since it plays a brand-like role in all the surveillance systems. 27 00:02:41,490 --> 00:02:44,870 Therefore, we selected MVR as our target. 28 00:02:46,730 --> 00:02:48,650 So, what is an MVR? 29 00:02:48,650 --> 00:02:58,690 A network video recorder called MVR stores recorded video from CCTVs and eye cameras and monitors or manages real-time video. 30 00:02:58,750 --> 00:03:03,930 Due to the nature of managing these videos, many devices can access them over the Internet. 31 00:03:04,390 --> 00:03:07,710 And the screen you see below is the MVR screen. 32 00:03:09,830 --> 00:03:13,270 This is our detailed research motivation. 33 00:03:13,270 --> 00:03:22,710 First, as we investigated enough online, there was not as much as studies on it compared to CCTV or IP camera system. 34 00:03:22,910 --> 00:03:31,150 And as a result of showdown search, we found that more than 30,000 devices are exposed to the Internet. 35 00:03:31,550 --> 00:03:37,090 However, there are cases where critical vulnerability have been discovered previously. 36 00:03:37,090 --> 00:03:42,370 There was a case when the Mirai Bonnet became popular in 2021. 37 00:03:42,370 --> 00:03:48,350 Hikvision's pre-auth RCE vulnerability was maliciously used for a DDoS attack. 38 00:03:48,870 --> 00:03:54,410 So, we are motivated by such examples which are serious vulnerabilities. 39 00:03:56,210 --> 00:03:58,270 Next is vendor choice. 40 00:03:58,270 --> 00:04:06,430 We chose four vendors, Hikvision and Tawa, because they have the highest market share in the virtual surveillance system. 41 00:04:06,430 --> 00:04:11,330 And we chose vendor A, which has the highest market share in Korea. 42 00:04:11,590 --> 00:04:19,870 Lastly, regardless of market share, we also selected Shinology's surveillance station package as a target vendor. 43 00:04:19,870 --> 00:04:31,810 This is because Shinology is famous for security and has an image of being safe, so we wanted to check whether surveillance-related packages were also the same. 44 00:04:33,750 --> 00:04:38,070 Next, let us tell you about our firmware extraction methodology. 45 00:04:38,070 --> 00:04:45,090 We tried a variety of methods to extract the firmware, and this picture is a list of what we tried. 46 00:04:46,850 --> 00:04:54,090 Since three of these products had UART ports available, we tried to extract the firmware through UART. 47 00:04:54,190 --> 00:05:00,030 And Shinology allows the root shell access via SSH, so no other method was needed. 48 00:05:01,810 --> 00:05:07,570 Before that, let us tell you why we didn't perform the extraction via remote access. 49 00:05:07,590 --> 00:05:13,230 Hikvision and Tawa supported remote access, but only limited shell access was possible. 50 00:05:13,230 --> 00:05:19,950 We tried many ways to bypass it, but they failed, so we had no choice but to use UART. 51 00:05:21,110 --> 00:05:28,750 We identified the UART port on the PC board and connected a cable to make it interactable with the UART shell. 52 00:05:28,750 --> 00:05:33,950 However, all three devices were not regular UART, but modified UART. 53 00:05:33,950 --> 00:05:38,270 So we couldn't use the UART shell, as shown in the picture on the right. 54 00:05:38,270 --> 00:05:41,390 We started looking for a way to bypass it. 55 00:05:42,970 --> 00:05:51,470 First, in the case of Hikvision, we couldn't bypass UART mitigation on the first NVR we purchased. 56 00:05:51,470 --> 00:05:58,650 So we used the downgrade method of repurchasing an older version of the Hikvision device. 57 00:05:58,730 --> 00:06:06,710 An older version device had lower UART versions, and there were differences from mitigation applied to the latest UART. 58 00:06:08,730 --> 00:06:17,410 We were able to access the UART shell using Hikvision's UART mitigation bypass technique we could find on the Internet. 59 00:06:18,630 --> 00:06:24,890 And last, we updated the older version of the product to the latest firmware. 60 00:06:26,190 --> 00:06:29,630 The bypass technique already known in the older version... 61 00:06:45,360 --> 00:06:52,920 On the latest version, there was no reaction even though we tried our best on giving command input. 62 00:06:52,920 --> 00:07:00,940 But as shown in the picture on the right, which is the older version, using setenv and semicolons caused the command injection. 63 00:07:00,940 --> 00:07:04,140 So we were able to insert the UART command. 64 00:07:05,740 --> 00:07:15,540 Since we could use the UART command disk, we were able to obtain a kernel shell for the device by adding the shell to the RDNID argument in bootargs. 65 00:07:17,320 --> 00:07:19,680 Next, the case of Dahua. 66 00:07:19,680 --> 00:07:27,640 In Dahua, several UART command disks were available, but the most important command disk, such as printenv, did not exist. 67 00:07:27,640 --> 00:07:36,840 So we used setenv to print the changed argument once again to check the value of the environment variable with the keys we know. 68 00:07:38,500 --> 00:07:41,420 However, bigger problem awaited us. 69 00:07:41,420 --> 00:07:47,120 We modified bootargs and booted the device, but we couldn't see the kernel output. 70 00:07:47,120 --> 00:07:51,600 In order to use the kernel shell, of course, there must be kernel output. 71 00:07:51,600 --> 00:07:55,280 So we looked for a way to check the kernel output. 72 00:07:56,860 --> 00:08:02,380 First, we knew that the environment section exists using the mtdpart command. 73 00:08:02,480 --> 00:08:10,600 And to print the contents of this environment section, we used the ntdump command to print the contents of the environment variable. 74 00:08:12,300 --> 00:08:25,260 Now that we were able to check the key values of the environment variable, we changed the value of each environment variable one by one to see if we could grab the kernel output. 75 00:08:25,280 --> 00:08:36,500 We found out that there was an environment variable called dhkeyboard that specifies the kernel output mode, so we could change it to 0 to get kernel output. 76 00:08:38,440 --> 00:08:40,380 Next is vendor A. 77 00:08:40,380 --> 00:08:47,520 In the case of vendor A, unlike the previous two cases, it was not possible to even use the u-boot shell. 78 00:08:47,520 --> 00:08:55,140 As you can see, as soon as we booted the device, type password has appeared and we couldn't use any u-boot commands. 79 00:08:55,280 --> 00:09:02,040 Vendor A was calling the secure UART and we started doing a lot of research to bypass this. 80 00:09:03,420 --> 00:09:10,360 We learned about the glitching attack through a lot of research and led the u-boot code to perform this attack. 81 00:09:10,360 --> 00:09:23,120 By reading the code, the booting algorithm in the u-boot system says that if the initialization process was successful, all those launched the kernel, and if it fails, it restarts the bootloader shell. 82 00:09:23,120 --> 00:09:32,080 We assumed that vendor A wouldn't have exception handling for this method, and we found a way to make the initialization process fail. 83 00:09:33,740 --> 00:09:36,540 Let us tell you how to perform this attack. 84 00:09:36,540 --> 00:09:41,860 First, we will explain the process of loading kernel during the normal boot sequence. 85 00:09:43,320 --> 00:09:46,900 First, load the kernel into RAM from flash memory. 86 00:09:47,520 --> 00:09:51,700 Second, the CPU rests the kernel loaded into RAM and decompresses it. 87 00:09:53,120 --> 00:09:59,400 If the decompression is successful, the CPU starts the kernel and terminates the execution of u-boot. 88 00:10:00,300 --> 00:10:06,860 Now, let us tell you the boot sequence's difference between performing the attack and vice versa. 89 00:10:08,100 --> 00:10:12,820 As with the normal process, load the kernel into RAM from flash memory. 90 00:10:13,160 --> 00:10:20,420 At this time, we gave it an electric shock, which caused the kernel to be broken and to be loaded into RAM. 91 00:10:21,140 --> 00:10:26,700 As the CPU tries to decompress the broken kernel in RAM, it naturally fails. 92 00:10:27,920 --> 00:10:33,240 When this happens, the CPU restarts the bootloader shell as I mentioned earlier. 93 00:10:34,360 --> 00:10:43,040 Through previous research, we learned that the attack is carried out by connecting the chip select and data out on the pad of flash memory. 94 00:10:43,040 --> 00:10:51,240 Therefore, we checked the datasheet of the flash memory available at vendor A and found out which chip should be connected. 95 00:10:51,240 --> 00:10:54,640 We are now all set, but how do we connect these two pads? 96 00:10:56,100 --> 00:11:05,460 We created a specialized tool for performing this particular attack by attaching the heads of jumper cables together. 97 00:11:05,460 --> 00:11:07,220 Looks very easy, right? 98 00:11:08,220 --> 00:11:10,800 Here is a demo of this attack. 99 00:11:10,800 --> 00:11:15,080 If we give it an electric shock, 100 00:11:18,560 --> 00:11:23,160 and boom, we can use the bootloader shell. 101 00:11:27,520 --> 00:11:33,340 Once we had the kernel shells for all devices, we needed to extract the file system. 102 00:11:33,340 --> 00:11:38,200 We ejected out the file system to our NAS using NFS and USB. 103 00:11:38,220 --> 00:11:46,220 One thing we didn't know was that the USB had to be formatted as XFS for the device to recognize it. 104 00:11:48,020 --> 00:11:54,420 As you can see, we were able to successfully transfer all devices' file systems to our NAS. 105 00:11:55,800 --> 00:12:07,940 However, we encountered a big variable while configuring the AWS analysis environment, because most file systems were read-only, so no files could be modified or written. 106 00:12:08,080 --> 00:12:15,560 Now, even though we had a root shell, the shell becomes unusable once the device boots up, so we had to bypass it. 107 00:12:16,420 --> 00:12:26,300 We found out that only the root file and device directory were modifiable, so we decided to use bind-mount. 108 00:12:26,300 --> 00:12:34,180 We discovered that when we bind-mount an arbitrary file in a writeable directory, the file becomes editable. 109 00:12:34,180 --> 00:12:39,420 We immediately bind-mounted ETC password to a writeable location. 110 00:12:40,160 --> 00:12:43,180 Now, we can modify ETC password. 111 00:12:43,180 --> 00:12:51,380 However, the main binary ran an integrity check and rebooted the device when changes to file contents were detected. 112 00:12:52,780 --> 00:12:55,880 So we found a way to get around this. 113 00:12:55,900 --> 00:12:59,680 First, we cloned ETC password to a writeable directory. 114 00:12:59,720 --> 00:13:06,940 If you look at the picture on the right, you can see that the root shell is set to DSH, a restricted shell. 115 00:13:08,700 --> 00:13:18,800 Second, bind-mount is performed in the RCS script after the initialization process is completed and immediately before starting the main binary. 116 00:13:20,500 --> 00:13:30,200 Next, we ran the main binary, and when the web service becomes available, we changed the contents of the bind-mounted file. 117 00:13:31,460 --> 00:13:36,040 Finally, we have a restricted root shell accessed via SSH. 118 00:13:36,040 --> 00:13:40,000 Now, we can replicate the file system using NFS. 119 00:13:40,000 --> 00:13:51,200 Additionally, this bind-mounting replaces the original file contents when the device is rebooted, so we created the previous process as a shell script and used it. 120 00:13:52,540 --> 00:14:00,280 Next, we will discuss the vulnerabilities we discovered and the MBR hacking scenarios we created by linking these vulnerabilities. 121 00:14:00,640 --> 00:14:04,700 Here, we will explain one scenario for each vendor we targeted. 122 00:14:06,840 --> 00:14:09,660 First, let's look at the scenario for vendor A. 123 00:14:09,660 --> 00:14:14,040 The code on the left is the query string parsing logic used in the web page. 124 00:14:14,040 --> 00:14:20,780 It calculates the start and end of the parameters based on the equal and ampersand characters. 125 00:14:21,920 --> 00:14:27,440 This parameter named length is used as the parameter for SDRN copy. 126 00:14:27,440 --> 00:14:33,740 Therefore, since the length is a controllable parameter by the attacker, it can cause a buffer overflow. 127 00:14:35,200 --> 00:14:40,820 So, let's insert a large number of characters into the query string parameter. 128 00:14:40,980 --> 00:14:48,860 As you can see, the return address is overwritten because there is no canary successfully manipulating the PC register. 129 00:14:50,480 --> 00:14:53,600 However, we encountered a few problems. 130 00:14:53,600 --> 00:14:58,220 First, Annex was enabled, so we needed to perform the ROP. 131 00:14:58,220 --> 00:15:06,100 Next, since the payload must be successfully delivered to the server, we could only insert printable characters. 132 00:15:06,680 --> 00:15:13,580 All gadgets in the binary start with 1, so we could not use gadgets within binary. 133 00:15:13,980 --> 00:15:17,600 For this reason, we also couldn't leak the libc address. 134 00:15:18,780 --> 00:15:21,480 So, how do we write the exploit code? 135 00:15:21,480 --> 00:15:23,480 We found several solutions. 136 00:15:23,480 --> 00:15:29,440 First, we discovered that the R0 register holds a stack address at a certain size. 137 00:15:29,440 --> 00:15:35,540 We confirmed that this stack address contains the string we inserted into the query string. 138 00:15:35,680 --> 00:15:41,840 Next, since the main binary has a 32-bit address space, it has low entropy. 139 00:15:42,600 --> 00:15:49,680 Lastly, the Lydie binary spawns a new child process whenever the child process dies. 140 00:15:50,440 --> 00:15:51,820 What do you think? 141 00:15:51,820 --> 00:15:54,800 Doesn't it seem like everything is set for fault-proof? 142 00:15:55,860 --> 00:15:57,320 Look here. 143 00:15:57,320 --> 00:16:03,080 As I mentioned, the R0 register holds a stack address containing the string we can manipulate. 144 00:16:03,080 --> 00:16:06,740 At that time, we can control the PC register. 145 00:16:07,420 --> 00:16:14,300 Now, we needed to reboot the binary until the PC register holds the libc system address. 146 00:16:15,100 --> 00:16:16,720 Here is the method. 147 00:16:16,720 --> 00:16:22,380 We send a request that makes the R0 register hold the libc command payload. 148 00:16:22,380 --> 00:16:26,980 Then, we send an arbitrary libc system address in the PC register. 149 00:16:27,820 --> 00:16:30,820 Now, let's start the boot machine. 150 00:16:30,820 --> 00:16:32,920 Before long, we obtained a share. 151 00:16:32,920 --> 00:16:40,480 Fortunately, we got the share within 600 tries, not the expected 2 to the power of 16 tries. 152 00:16:41,580 --> 00:16:43,940 Great, we got a root share. 153 00:16:43,940 --> 00:16:45,800 But what can we do with it? 154 00:16:45,980 --> 00:16:57,840 All critical files like video, account, user password were encrypted, so we found additional vulnerabilities in the device so we can take over the admin web page. 155 00:16:58,840 --> 00:17:04,720 Unfortunately, since this vulnerability has not been patched yet, we cannot disclose it in here. 156 00:17:05,460 --> 00:17:11,080 All right, we can now access the device management page with admin privileges. 157 00:17:11,080 --> 00:17:13,060 Now, we can do anything. 158 00:17:14,380 --> 00:17:20,940 This is the real-time video manipulating scenario made by chaining the explained vulnerabilities. 159 00:17:21,000 --> 00:17:24,660 The attacker infiltrates the MVR through RCE. 160 00:17:27,760 --> 00:17:34,340 Then, using a vulnerability we cannot disclose here, the attacker gains access to the admin web page. 161 00:17:37,280 --> 00:17:41,320 Finally, the attacker manipulates the real-time video. 162 00:17:47,670 --> 00:17:52,090 Here is the demo video of this scenario. 163 00:17:53,090 --> 00:17:59,850 When we send a payload, the MVR screen is tampered. 164 00:18:04,610 --> 00:18:10,250 Next, let's discuss the machine authorization scenario for Synology. 165 00:18:10,250 --> 00:18:14,850 Synology performs a load of MVR through the surveillance station package. 166 00:18:14,850 --> 00:18:19,210 Let's look at the authorization code of this package's API handler. 167 00:18:19,210 --> 00:18:26,210 First, it verifies if the user sending the request is logged in through the isAuthorized function. 168 00:18:26,370 --> 00:18:31,790 Then, it checks if the user has permission to use the surveillance station package. 169 00:18:31,790 --> 00:18:34,250 Doesn't it seem like something is missing? 170 00:18:34,250 --> 00:18:43,090 It doesn't check if the user has necessary permissions to use specific features, whether the user is an admin or a guest. 171 00:18:44,190 --> 00:18:51,170 So, we found that even with guest permissions, one could abuse all features of the Synology surveillance station. 172 00:18:51,170 --> 00:18:58,070 We discovered that surveillance station features include reboot, shutdown, and package installation. 173 00:18:58,970 --> 00:19:02,110 Additionally, we found something unusual. 174 00:19:02,110 --> 00:19:08,350 Some requests usable in surveillance station are forwarded to the NAS's core package. 175 00:19:08,350 --> 00:19:23,410 Regardless of how the requesters identify, these requests are forwarded to the core package as admin, allowing a guest using surveillance station to request to the Synology NAS with admin privileges. 176 00:19:24,470 --> 00:19:30,430 We received CVE with CVESS score 9.9 from Synology. 177 00:19:32,110 --> 00:19:35,910 Next, let's look at the scenario of hijacking real-time video. 178 00:19:35,910 --> 00:19:42,370 In a normal flow, guests do not have access to the camera, so they cannot view video on the front end. 179 00:19:43,690 --> 00:19:49,010 However, due to the vulnerability, even guests can obtain video information. 180 00:19:49,030 --> 00:19:58,250 Synology returns the RTSP server address and access credentials in the response, granting attackers unlimited access to the videos. 181 00:19:59,590 --> 00:20:01,230 Let's look at the scenario. 182 00:20:01,230 --> 00:20:04,910 Here, we included a request to terminate the layout. 183 00:20:04,910 --> 00:20:14,410 The attacker sends a request to terminate the layout, disconnecting all live video layouts connected to Synology on all computers. 184 00:20:18,560 --> 00:20:25,480 Then, the attacker sends GetLiveViewPass request to steal the video information. 185 00:20:29,240 --> 00:20:34,620 And requests the video from the RTSP server using the stolen information. 186 00:20:38,600 --> 00:20:42,720 Now, the attacker has hijacked the real-time video. 187 00:20:45,260 --> 00:20:46,960 Here is the demo. 188 00:20:47,800 --> 00:20:57,680 When we send the payload, the layout is terminated and we can watch the live video. 189 00:20:58,520 --> 00:20:59,820 Thank you. 190 00:21:11,140 --> 00:21:15,840 Next, we will introduce the vulnerabilities and scenarios of DAWA. 191 00:21:15,840 --> 00:21:21,800 The first vulnerability is called reachable assertion, and we will explain how we found it. 192 00:21:21,900 --> 00:21:27,020 While analyzing the login function, we discovered that there are many login options. 193 00:21:27,020 --> 00:21:32,240 As shown in the table below, there are six types of assert time and password type pairs. 194 00:21:33,240 --> 00:21:37,540 By default, the assert type and password type are set to default. 195 00:21:37,540 --> 00:21:44,760 The data sent in the request includes the username, hashed password, session, assert type, and password type. 196 00:21:44,760 --> 00:21:49,980 If the request is successful, a response containing true is received. 197 00:21:50,840 --> 00:22:02,100 We are curious about what will happen when an attempt to log in with different authentication types will lead us to unable to analyze the login options. 198 00:22:02,240 --> 00:22:13,220 During the analysis, we found a developer's mistake in the processing of the login request data, and were able to shut down the device with a reachable assertion as a result. 199 00:22:13,220 --> 00:22:15,470 Now, let me explain the vulnerability. 200 00:22:16,300 --> 00:22:22,900 First, before processing the login logic, the function's getPasswordType and its password value are called. 201 00:22:22,900 --> 00:22:33,640 The getPasswordType function extracts assert type and password type by parsing, and compares specific strings such as default and default, respectively. 202 00:22:34,020 --> 00:22:38,600 If the strings match, the function returns a type for their own. 203 00:22:38,600 --> 00:22:45,800 If the type is both default, it returns 4, and if it is OTP and SSC, it returns 7. 204 00:22:46,380 --> 00:22:58,960 Next function is called, isPasswordValid, and parses the login parameters based on the type value returned by the previous function, getPasswordType, and creates a string object. 205 00:22:59,020 --> 00:23:04,200 The series of process enters when assert type and password type are set to default. 206 00:23:04,200 --> 00:23:15,640 You can see that there is an exception handling logic that checks to see if those parameters are null before generating a string object for both parameters. 207 00:23:15,840 --> 00:23:21,520 Most of the branches have this null exception handling logic, but not all of them. 208 00:23:22,340 --> 00:23:28,100 The following code handles the case when the authentication type is OTP and WSSC. 209 00:23:28,100 --> 00:23:39,340 As seen in the code below, string objects for authority input and password type variables are created, but there is no exception handling logic for these objects. 210 00:23:39,780 --> 00:23:48,240 So, we remove the authority input parameter, set the authentication type to OTPWSSC, and send a request. 211 00:23:48,240 --> 00:23:59,500 As a result, the authority input is set to null, which causes a retrieval assertion to be drawn when creating a string object for that parameter, causing the main binary to exit. 212 00:23:59,940 --> 00:24:05,340 When the main binary terminates, the watchdog causes the device to reboot. 213 00:24:05,360 --> 00:24:07,680 This is a pretty simple vulnerability. 214 00:24:08,160 --> 00:24:14,380 The following vulnerabilities are very important because they require the device to reboot. 215 00:24:15,380 --> 00:24:18,900 The second vulnerability is Elf Injection. 216 00:24:18,900 --> 00:24:29,120 First, that will set permissions by group, and once creating an account, it can only perform tasks included in the permissions of the assigned group. 217 00:24:29,120 --> 00:24:36,140 This group information is stored in a file named groupsec and is encrypted using ASCBC. 218 00:24:36,220 --> 00:24:43,520 We tried analyzing the source code to find the key in Ivy, but it was quite complicated and eventually failed to find it. 219 00:24:44,380 --> 00:25:00,600 However, since the configuration information must be decrypted and loaded into memory during the main binary boot process, so we performed a dynamic analysis of the boot process, and unfortunately we were able to find the decrypted data. 220 00:25:02,200 --> 00:25:06,940 The structure of the decrypted groupsec file is as follows. 221 00:25:06,940 --> 00:25:10,660 The columns are ID, name, authority, and memo. 222 00:25:10,660 --> 00:25:16,520 Each column is separated by a column, and each line is separated by a line feed. 223 00:25:17,680 --> 00:25:26,940 When adding or modifying group information, the getline function is called as part of the process of saving the changed data. 224 00:25:26,940 --> 00:25:36,300 This function generates a line with the ID, name, authority, and memo, extracted from the login request separated by columns. 225 00:25:36,300 --> 00:25:44,640 We found out that there was no validation checking procedure of the input value until generating a line with the getline function. 226 00:25:46,180 --> 00:25:57,260 So, we added a line feed to the memo to tamper the structure and restarted the device to see what would happen during the parsing process of the groupsec file. 227 00:25:57,820 --> 00:26:04,880 As a result, the device entered the initialization routine and recreated the groupsec file. 228 00:26:04,880 --> 00:26:12,520 When entering the initialization routine, the user can change the add-in password on the web and perform any actions. 229 00:26:12,520 --> 00:26:18,380 We are curious if the initialization routine would still be entered if the file was deleted. 230 00:26:18,500 --> 00:26:25,320 After deleting the file and rebooting the device, we found that it still enters the initialization routine. 231 00:26:26,200 --> 00:26:32,440 Let me introduce the first scenario of DAWA using two vulnerabilities mentioned above. 232 00:26:32,440 --> 00:26:39,820 By using retrieval assertion and alpha injection, an attacker can take over the device and obtain add-in privileges. 233 00:26:40,060 --> 00:26:46,800 First, the attacker obtains an account with a user-managed privileges through credential stuffing. 234 00:26:47,480 --> 00:26:51,920 Next, the structure of the groupsec file is tampered through alpha injection. 235 00:26:51,920 --> 00:26:59,730 Then, the attacker reboots the device using retrieval assertion. 236 00:27:03,680 --> 00:27:14,400 When rebooted, the device enters the initialization routine, allowing the attacker to change the add-in password and perform malicious activities. 237 00:27:19,150 --> 00:27:21,970 Next is Stack Overflow. 238 00:27:21,970 --> 00:27:29,070 First, this vulnerability occurs not in the main binary but in a background service called AOL. 239 00:27:29,070 --> 00:27:37,130 This service is used to attempt online recovery when the device is abnormal, and it's open on port 8088. 240 00:27:37,650 --> 00:27:42,950 Since this port is not forwarded, it can only be accessed from the same network. 241 00:27:43,090 --> 00:27:47,930 It consists of 16 bytes of fixed size of headers and data. 242 00:27:47,930 --> 00:27:58,110 And for header, the constitutional data byte index 0 indicates the function index, and the byte chat indexes 4 to 7 indicate the data size. 243 00:27:58,110 --> 00:28:05,390 The data is then used as an argument for the input handler remitted by the data size defined in the header. 244 00:28:05,390 --> 00:28:10,010 However, the pinpoint is that the data size can be publicated. 245 00:28:10,190 --> 00:28:14,090 Now, let me explain the request processing procedure. 246 00:28:17,290 --> 00:28:20,090 The following function is called per-message. 247 00:28:20,090 --> 00:28:28,930 First, this function uses the structure with the VFT array, which consists of functions and variables related to each feature. 248 00:28:29,910 --> 00:28:44,330 As shown in the table on the left, each structure includes the permission level, index verification function, parameter parsing function, handler function, parameter allocation free function, and next table pointer. 249 00:28:44,330 --> 00:28:46,770 There are about 20 such tables. 250 00:28:47,670 --> 00:28:49,890 Here is how it works internally. 251 00:28:49,890 --> 00:28:58,910 The function iterates through a loop, calling the index verification function of each structure with the first byte of the header as an argument. 252 00:28:58,930 --> 00:29:11,150 The index verification function, as seen in the code on the bottom right, checks if the value obtained by subtracting a specific constant number from the argument is not zero. 253 00:29:11,250 --> 00:29:17,270 If the result is zero, it returns zero, or otherwise, it returns minus one. 254 00:29:17,270 --> 00:29:29,650 Referring back to the code on the left, if the return value is greater than zero, or meaning a matching index is found, the count table pointer is told in the eight variable, and zero is returned. 255 00:29:29,650 --> 00:29:36,170 If the matching index is found, minus one is returned, and the request is not processed. 256 00:29:38,290 --> 00:29:41,230 Next, the dpStackParse function is called. 257 00:29:41,230 --> 00:29:47,090 This function retrieves the table corresponding to the index and calls the parseFarm function. 258 00:29:47,270 --> 00:29:56,730 As shown in the parseFarm function on the right, it appropriately processes the data according to the requested function, and then returns the result. 259 00:29:57,510 --> 00:30:07,390 Finally, once all preprocessing steps are complete, the dpHandleQuery function is called to register the input handler and then execute it. 260 00:30:08,510 --> 00:30:16,590 There are many different functions that could be called, including logWin, query, and update, but they all require the logWin. 261 00:30:17,270 --> 00:30:20,770 So, we started analyzing the logWin function first. 262 00:30:22,030 --> 00:30:26,170 The function is executed if the first byte is A0. 263 00:30:26,170 --> 00:30:33,350 The data consists of username, password, and a random value with a double ampersand used as a delimiter. 264 00:30:33,350 --> 00:30:38,530 The vulnerability occurs when parsing this data, which we'll explain in a moment. 265 00:30:39,850 --> 00:30:53,410 As you can see in the code on the right, the strings for the username and password are set to 128 and 160 bytes respectively, and the memory is initialized with a memset. 266 00:30:54,490 --> 00:31:00,990 Next, a stringString function is called to find the positions of the double ampersands and null. 267 00:31:00,990 --> 00:31:09,970 The data before the first double ampersand is copied to username, and the data before the next double ampersand is copied to password. 268 00:31:10,050 --> 00:31:18,410 The problem is that there is no length validation checking during the copying process, allowing us to input data of any size. 269 00:31:18,410 --> 00:31:21,750 As a result, a buffer overflow occurs. 270 00:31:21,750 --> 00:31:32,570 You can cover the return address by putting 156 bytes of random data, the desired value, and the password location, as shown below. 271 00:31:33,510 --> 00:31:39,010 Since there was no stack canary, we couldn't manipulate the PC register. 272 00:31:39,010 --> 00:31:46,230 However, we encountered an issue where we couldn't include a null in the payload, making our pain possible. 273 00:31:46,270 --> 00:31:50,050 We didn't want to conclude with just a simple buffer overflow. 274 00:31:50,050 --> 00:31:53,410 So, we began analyzing the source code. 275 00:31:54,050 --> 00:31:57,410 Fortunately, we found some useful functions. 276 00:31:57,410 --> 00:32:06,350 There were functions for rebooting, starting SSH, removing inter-settings, performing a soft recovery, and killing all MBR-related binaries. 277 00:32:06,710 --> 00:32:10,670 Among these, the most interesting function was the soft recovery. 278 00:32:10,670 --> 00:32:16,150 This function deletes the config directory, resetting all configuration information. 279 00:32:16,150 --> 00:32:28,610 As seen in the previous vulnerability, if the groupsec file is deleted or tampered, the initialization routine is entered upon reboot, allowing the admin password to be changed. 280 00:32:28,610 --> 00:32:34,650 Therefore, we manipulated the PC register to call the soft recovery function. 281 00:32:34,650 --> 00:32:41,090 However, soft recovery deleted even the network files, making external access impossible. 282 00:32:41,090 --> 00:32:44,050 Unfortunately, we faced another challenge. 283 00:32:44,950 --> 00:33:00,310 After several days of analysis and contemplation, it soon came to my head that during the boot, there is a process where configuration files in the config directory are decrypted and loaded into memory. 284 00:33:00,310 --> 00:33:03,630 So, we began analyzing the boot loads. 285 00:33:03,970 --> 00:33:12,890 As a result, we found that the network configuration file is loaded first, and then the account file is loaded around 5 seconds later. 286 00:33:14,030 --> 00:33:24,890 I was curious to see what would happen if the main binary center soft recovery failed within 5 seconds of loading the network configuration file. 287 00:33:24,930 --> 00:33:30,130 The most fortunate point is that AOR is loaded before the main binary boots. 288 00:33:31,410 --> 00:33:37,110 First, we kill the main binary using the recover assertion, causing the device to reboot. 289 00:33:37,690 --> 00:33:41,730 Then, we wait until the network configuration file is loaded. 290 00:33:41,730 --> 00:33:46,690 In our case, it took approximately 20 seconds for the device. 291 00:33:47,530 --> 00:33:54,150 Next, we send the soft recovery failure to AOR, which deletes all configuration files. 292 00:33:54,290 --> 00:34:01,230 Then, the main binary can't access the account configuration file and enters the initialization routine. 293 00:34:01,870 --> 00:34:05,550 As a result, we are able to change admin account. 294 00:34:05,550 --> 00:34:12,750 Let me explain the admin takeover vulnerability using recover assertion and stack buffer overflow. 295 00:34:12,750 --> 00:34:16,710 First, we will reboot the device via recover assertion. 296 00:34:18,550 --> 00:34:23,970 After rebooting, we wait for the network configuration file to be loaded. 297 00:34:25,530 --> 00:34:32,570 And then, send the soft recovery failure to AOR to remove all configuration files. 298 00:34:34,800 --> 00:34:45,040 In the process of loading account setting files such as groupsec, it enters an initialization routine because the files do not exist. 299 00:34:46,840 --> 00:34:52,000 The attacker changes the admin password and gains access to the admin page. 300 00:34:53,240 --> 00:34:54,940 This is a demo. 301 00:35:08,390 --> 00:35:11,130 The last vulnerability is from Hikvision. 302 00:35:11,130 --> 00:35:17,250 Hikvision was much more solid compared to other devices, making it more challenging. 303 00:35:17,310 --> 00:35:21,750 However, we found an interesting vector, a local subs component. 304 00:35:21,750 --> 00:35:27,130 That is a plugin that must be installed for users to view video from the web. 305 00:35:27,130 --> 00:35:38,170 This plugin runs with admin privileges on Windows and is accessible on port 33686, meaning anyone on the same network can access it. 306 00:35:38,170 --> 00:35:44,510 It was a very interesting plugin, so we started analyzing it and found the vulnerability. 307 00:35:44,510 --> 00:35:51,670 Due to an entity associated with a bounty for this vendor, we can't disclose detailed root codes. 308 00:35:51,670 --> 00:35:57,890 In short, it is a vulnerability that allows RCE by sending a crafted message. 309 00:35:58,330 --> 00:36:00,390 Instead, we will show you a demo. 310 00:36:00,390 --> 00:36:04,930 Through RCE, we can completely take control of Windows. 311 00:36:04,970 --> 00:36:08,530 With admin privileges, we can perform any actions. 312 00:36:16,320 --> 00:36:25,530 The next vulnerability is OS command injection, which allows a user with admin privileges to execute arbitrary commands. 313 00:36:26,330 --> 00:36:32,530 We create a scenario to take control of the internal network using these two vulnerabilities. 314 00:36:32,790 --> 00:36:37,350 First, we obtain admin privileges through credential stuffing. 315 00:36:38,890 --> 00:36:43,730 Next, we open a reversal through command injection to enter the MVR. 316 00:36:45,530 --> 00:36:53,530 Then we perform network scanning to find Windows computers using the application named local subs component. 317 00:36:54,550 --> 00:37:02,150 Finally, by exploiting the plugin RCE, we could take control of Windows and perform malicious activities. 318 00:37:03,530 --> 00:37:05,530 Here is the demo. 319 00:37:05,530 --> 00:37:17,120 By just pressing the button, we can automatically take control of Windows computer in the... 320 00:37:32,160 --> 00:37:39,820 One of the things we learned during the project is the Hikvision and our Huzy OEM supplier. 321 00:37:40,720 --> 00:37:50,160 Both companies also sell under their own brands, but they are relabeled and sell to various retailers in the U.S., such as Lorex and Luma. 322 00:37:50,160 --> 00:37:56,640 This means that devices are being used all around us without realizing that they are made in China. 323 00:37:57,700 --> 00:38:02,020 First, OEM stands for Original Equipment Manufacturer. 324 00:38:02,140 --> 00:38:12,840 It refers to the manufacturing method in which a company outsources the production of its products to another company and then sells them under its own brand. 325 00:38:12,840 --> 00:38:24,320 If a product is made by Company A and is sold under the brand name of Company B, Company A becomes the OEM supplier and Company B becomes the OEM vendor. 326 00:38:24,320 --> 00:38:28,620 The images below show DAWA's MBR and OEM's MBR. 327 00:38:28,620 --> 00:38:31,280 They look very similar, don't they? 328 00:38:32,260 --> 00:38:36,000 This picture illustrates the OEM sales process. 329 00:38:36,000 --> 00:38:44,480 Products manufactured by OEM suppliers like Hikvision and DAWA are relabeled by OEM vendors and sold to users. 330 00:38:44,880 --> 00:38:55,180 If a vulnerability occurs in a product produced by an OEM supplier, it can affect the products sold by the OEM vendor as well. 331 00:38:55,580 --> 00:39:00,480 This means that many devices can be impacted by the same vulnerability. 332 00:39:01,260 --> 00:39:07,900 So, we decided to check if the vulnerabilities were valid for OEMs using the same firmware. 333 00:39:07,960 --> 00:39:15,900 First, we ran bin-deep on the main binaries of DAWA and OEM vendor Bush and found that the logic was similar. 334 00:39:15,960 --> 00:39:20,540 Hikvision also confirmed similar through deeping. 335 00:39:21,480 --> 00:39:29,140 After confirming that OEM vendors use similar firmware, we decided to fault-trace devices and test them. 336 00:39:29,140 --> 00:39:32,480 For Hikvision, we fault-traced Anki and Ampibis. 337 00:39:32,480 --> 00:39:35,460 Four out of six vulnerabilities each were valid. 338 00:39:35,840 --> 00:39:38,880 For DAWA, we fault-traced Zhiyuan and EGPS. 339 00:39:38,880 --> 00:39:43,020 Four and six of the seven vulnerabilities were valid, respectively. 340 00:39:43,120 --> 00:40:00,320 We confirmed that the vulnerabilities were validly exploited and reported them to Mitre, KISA, which is the Korean CNA, to get CBIS and KBIS, which increased the number of recognized vulnerabilities by 61%. 341 00:40:01,460 --> 00:40:06,860 Finally, we will show you a video of vulnerability testing on OEM vendors. 342 00:40:06,860 --> 00:40:10,640 The first video is the OEM vendor testing for DAWA. 343 00:40:10,640 --> 00:40:15,780 By sending DAWA's recover assertion payload, we could shut down all devices. 344 00:40:18,410 --> 00:40:22,910 The second video is OEM vendor testing for Hikvision. 345 00:40:22,910 --> 00:40:32,110 After sending the voice command injection payload, we could connect a reverse shell and input the shutdown command to turn off all devices. 346 00:40:33,310 --> 00:40:40,050 Also, we are curious about how many devices were affected by the vulnerabilities we found. 347 00:40:40,050 --> 00:40:42,850 So, we searched using Shoda. 348 00:40:43,870 --> 00:40:52,890 In the case of Hikvision, most model devices' name or firmware versions were not present in the banner data. 349 00:40:52,910 --> 00:40:58,350 So, we needed a different approach to identify as many as possible. 350 00:40:58,450 --> 00:41:05,970 We found that for MBR devices, when accessing the login page, a config.json file is requested. 351 00:41:05,970 --> 00:41:11,510 This file contains the configuration information related to MBR. 352 00:41:11,510 --> 00:41:22,690 For version information, we used the web version and plug-in version coded in the C.js to search for devices with versions equal to or lower than the one we did our study. 353 00:41:22,910 --> 00:41:28,870 As a result, we found that approximately 130,000 devices were vulnerable. 354 00:41:29,910 --> 00:41:35,690 For Delwa, since the device name was present in the banner, we simply searched for it. 355 00:41:35,710 --> 00:41:40,310 As a result, we found approximately 100,000 devices. 356 00:41:41,430 --> 00:41:44,330 Finally, we came to the conclusion part. 357 00:41:44,330 --> 00:41:50,870 First of all, this is what we would like to comment to offensive researchers in MBR field like us. 358 00:41:50,870 --> 00:41:55,330 The vulnerabilities were discovered during our research period include. 359 00:41:55,330 --> 00:42:01,210 Even when analyzing one-day cases, we found that these vulnerabilities were statically numerous. 360 00:42:01,410 --> 00:42:07,490 So, when you want to analyze your MBR, we recommend that you focus on these vulnerabilities. 361 00:42:08,490 --> 00:42:21,350 We conducted an analysis focusing on HTTP communication process of domain binary in order to achieve good results as much as possible over the project of four months. 362 00:42:21,350 --> 00:42:39,610 However, MBRs have numerous attack surfaces, including private protocols with their cloud service, SDK communication with VMS, private protocols used to communicate with MBRs or IP cameras, and communication with other sensors. 363 00:42:40,090 --> 00:42:48,990 Therefore, we recommend that you do not focus solely on analyzing the HTTP process, but analyze various attack surfaces. 364 00:42:50,350 --> 00:42:55,050 The following is what we would like to recommend to users. 365 00:42:55,050 --> 00:43:04,750 What we felt while conducting a one-day case study is that as long as MBR is not exposed to the external network, it is safe from these attacks. 366 00:43:04,950 --> 00:43:15,490 Major MBR vendors provide solutions that allow external access using things like DDNS without exposing the device to an external network. 367 00:43:15,490 --> 00:43:21,050 You can take advantage of these solutions to keep your devices safe from these attacks. 368 00:43:23,880 --> 00:43:26,980 Thank you to people who helped us with the research. 369 00:43:26,980 --> 00:43:29,480 Especially, thank you to Dr. 370 00:43:29,480 --> 00:43:30,700 Junsang Yoo. 371 00:43:32,080 --> 00:43:34,620 Thank you for listening to our presentation. 372 00:43:34,620 --> 00:43:38,740 And if you have any questions, please contact us on Twitter below. 373 00:43:38,740 --> 00:43:42,580 More details of our research can be found via the QR code on the right. 374 00:43:42,580 --> 00:43:43,400 Thank you.