WEBVTT

00:00.960 --> 00:03.840
Hello, DEF CON.

00:03.840 --> 00:06.160
Thank you for coming to our presentation.

00:06.160 --> 00:13.540
We are excited to share our talk titled, Watchers Being Watched Exploiting the Surveillance System and Its Supply Chain.

00:13.540 --> 00:18.100
We'll talk about our vulnerability research on surveillance system devices.

00:18.100 --> 00:19.460
Please enjoy.

00:19.680 --> 00:22.700
First, let us introduce our research group.

00:22.700 --> 00:27.460
I'm Chanhee Kim, and I'm currently working as an offensive researcher at S2W.

00:27.460 --> 00:34.980
And he's Myungwoo Park, and he's a student attending a university in Korea enjoying offensive research.

00:36.760 --> 00:39.780
And this is what we'll show you in this talk.

00:39.780 --> 00:46.400
We'll be talking about a $30,000 bounty and a four-month journey to become a DEF CON speaker.

00:46.400 --> 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.

00:59.420 --> 01:03.200
In the last, the impact of our research on the supply chain.

01:03.200 --> 01:04.160
That's it.

01:04.160 --> 01:05.720
Please look forward to it.

01:07.040 --> 01:11.400
This video will be the final goal, which happened in the real world.

01:11.400 --> 01:14.660
We wanted to see why we're doing this research.

01:14.660 --> 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.

01:24.180 --> 01:25.680
Let's watch the video.

01:44.510 --> 01:47.490
That's like a hacker from a movie, isn't it?

01:48.870 --> 01:53.710
Next, why is making our surveillance device more securely important?

01:53.710 --> 01:57.510
We can see surveillance devices everywhere in our lives.

01:57.510 --> 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.

02:10.850 --> 02:16.510
Thus, the global surveillance device market is currently worth $4.1 billion.

02:16.630 --> 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.

02:28.490 --> 02:30.530
Next is our target.

02:30.530 --> 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.

02:41.490 --> 02:44.870
Therefore, we selected MVR as our target.

02:46.730 --> 02:48.650
So, what is an MVR?

02:48.650 --> 02:58.690
A network video recorder called MVR stores recorded video from CCTVs and eye cameras and monitors or manages real-time video.

02:58.750 --> 03:03.930
Due to the nature of managing these videos, many devices can access them over the Internet.

03:04.390 --> 03:07.710
And the screen you see below is the MVR screen.

03:09.830 --> 03:13.270
This is our detailed research motivation.

03:13.270 --> 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.

03:22.910 --> 03:31.150
And as a result of showdown search, we found that more than 30,000 devices are exposed to the Internet.

03:31.550 --> 03:37.090
However, there are cases where critical vulnerability have been discovered previously.

03:37.090 --> 03:42.370
There was a case when the Mirai Bonnet became popular in 2021.

03:42.370 --> 03:48.350
Hikvision's pre-auth RCE vulnerability was maliciously used for a DDoS attack.

03:48.870 --> 03:54.410
So, we are motivated by such examples which are serious vulnerabilities.

03:56.210 --> 03:58.270
Next is vendor choice.

03:58.270 --> 04:06.430
We chose four vendors, Hikvision and Tawa, because they have the highest market share in the virtual surveillance system.

04:06.430 --> 04:11.330
And we chose vendor A, which has the highest market share in Korea.

04:11.590 --> 04:19.870
Lastly, regardless of market share, we also selected Shinology's surveillance station package as a target vendor.

04:19.870 --> 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.

04:33.750 --> 04:38.070
Next, let us tell you about our firmware extraction methodology.

04:38.070 --> 04:45.090
We tried a variety of methods to extract the firmware, and this picture is a list of what we tried.

04:46.850 --> 04:54.090
Since three of these products had UART ports available, we tried to extract the firmware through UART.

04:54.190 --> 05:00.030
And Shinology allows the root shell access via SSH, so no other method was needed.

05:01.810 --> 05:07.570
Before that, let us tell you why we didn't perform the extraction via remote access.

05:07.590 --> 05:13.230
Hikvision and Tawa supported remote access, but only limited shell access was possible.

05:13.230 --> 05:19.950
We tried many ways to bypass it, but they failed, so we had no choice but to use UART.

05:21.110 --> 05:28.750
We identified the UART port on the PC board and connected a cable to make it interactable with the UART shell.

05:28.750 --> 05:33.950
However, all three devices were not regular UART, but modified UART.

05:33.950 --> 05:38.270
So we couldn't use the UART shell, as shown in the picture on the right.

05:38.270 --> 05:41.390
We started looking for a way to bypass it.

05:42.970 --> 05:51.470
First, in the case of Hikvision, we couldn't bypass UART mitigation on the first NVR we purchased.

05:51.470 --> 05:58.650
So we used the downgrade method of repurchasing an older version of the Hikvision device.

05:58.730 --> 06:06.710
An older version device had lower UART versions, and there were differences from mitigation applied to the latest UART.

06:08.730 --> 06:17.410
We were able to access the UART shell using Hikvision's UART mitigation bypass technique we could find on the Internet.

06:18.630 --> 06:24.890
And last, we updated the older version of the product to the latest firmware.

06:26.190 --> 06:29.630
The bypass technique already known in the older version...

06:45.360 --> 06:52.920
On the latest version, there was no reaction even though we tried our best on giving command input.

06:52.920 --> 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.

07:00.940 --> 07:04.140
So we were able to insert the UART command.

07:05.740 --> 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.

07:17.320 --> 07:19.680
Next, the case of Dahua.

07:19.680 --> 07:27.640
In Dahua, several UART command disks were available, but the most important command disk, such as printenv, did not exist.

07:27.640 --> 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.

07:38.500 --> 07:41.420
However, bigger problem awaited us.

07:41.420 --> 07:47.120
We modified bootargs and booted the device, but we couldn't see the kernel output.

07:47.120 --> 07:51.600
In order to use the kernel shell, of course, there must be kernel output.

07:51.600 --> 07:55.280
So we looked for a way to check the kernel output.

07:56.860 --> 08:02.380
First, we knew that the environment section exists using the mtdpart command.

08:02.480 --> 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.

08:12.300 --> 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.

08:25.280 --> 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.

08:38.440 --> 08:40.380
Next is vendor A.

08:40.380 --> 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.

08:47.520 --> 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.

08:55.280 --> 09:02.040
Vendor A was calling the secure UART and we started doing a lot of research to bypass this.

09:03.420 --> 09:10.360
We learned about the glitching attack through a lot of research and led the u-boot code to perform this attack.

09:10.360 --> 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.

09:23.120 --> 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.

09:33.740 --> 09:36.540
Let us tell you how to perform this attack.

09:36.540 --> 09:41.860
First, we will explain the process of loading kernel during the normal boot sequence.

09:43.320 --> 09:46.900
First, load the kernel into RAM from flash memory.

09:47.520 --> 09:51.700
Second, the CPU rests the kernel loaded into RAM and decompresses it.

09:53.120 --> 09:59.400
If the decompression is successful, the CPU starts the kernel and terminates the execution of u-boot.

10:00.300 --> 10:06.860
Now, let us tell you the boot sequence's difference between performing the attack and vice versa.

10:08.100 --> 10:12.820
As with the normal process, load the kernel into RAM from flash memory.

10:13.160 --> 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.

10:21.140 --> 10:26.700
As the CPU tries to decompress the broken kernel in RAM, it naturally fails.

10:27.920 --> 10:33.240
When this happens, the CPU restarts the bootloader shell as I mentioned earlier.

10:34.360 --> 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.

10:43.040 --> 10:51.240
Therefore, we checked the datasheet of the flash memory available at vendor A and found out which chip should be connected.

10:51.240 --> 10:54.640
We are now all set, but how do we connect these two pads?

10:56.100 --> 11:05.460
We created a specialized tool for performing this particular attack by attaching the heads of jumper cables together.

11:05.460 --> 11:07.220
Looks very easy, right?

11:08.220 --> 11:10.800
Here is a demo of this attack.

11:10.800 --> 11:15.080
If we give it an electric shock,

11:18.560 --> 11:23.160
and boom, we can use the bootloader shell.

11:27.520 --> 11:33.340
Once we had the kernel shells for all devices, we needed to extract the file system.

11:33.340 --> 11:38.200
We ejected out the file system to our NAS using NFS and USB.

11:38.220 --> 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.

11:48.020 --> 11:54.420
As you can see, we were able to successfully transfer all devices' file systems to our NAS.

11:55.800 --> 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.

12:08.080 --> 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.

12:16.420 --> 12:26.300
We found out that only the root file and device directory were modifiable, so we decided to use bind-mount.

12:26.300 --> 12:34.180
We discovered that when we bind-mount an arbitrary file in a writeable directory, the file becomes editable.

12:34.180 --> 12:39.420
We immediately bind-mounted ETC password to a writeable location.

12:40.160 --> 12:43.180
Now, we can modify ETC password.

12:43.180 --> 12:51.380
However, the main binary ran an integrity check and rebooted the device when changes to file contents were detected.

12:52.780 --> 12:55.880
So we found a way to get around this.

12:55.900 --> 12:59.680
First, we cloned ETC password to a writeable directory.

12:59.720 --> 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.

13:08.700 --> 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.

13:20.500 --> 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.

13:31.460 --> 13:36.040
Finally, we have a restricted root shell accessed via SSH.

13:36.040 --> 13:40.000
Now, we can replicate the file system using NFS.

13:40.000 --> 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.

13:52.540 --> 14:00.280
Next, we will discuss the vulnerabilities we discovered and the MBR hacking scenarios we created by linking these vulnerabilities.

14:00.640 --> 14:04.700
Here, we will explain one scenario for each vendor we targeted.

14:06.840 --> 14:09.660
First, let's look at the scenario for vendor A.

14:09.660 --> 14:14.040
The code on the left is the query string parsing logic used in the web page.

14:14.040 --> 14:20.780
It calculates the start and end of the parameters based on the equal and ampersand characters.

14:21.920 --> 14:27.440
This parameter named length is used as the parameter for SDRN copy.

14:27.440 --> 14:33.740
Therefore, since the length is a controllable parameter by the attacker, it can cause a buffer overflow.

14:35.200 --> 14:40.820
So, let's insert a large number of characters into the query string parameter.

14:40.980 --> 14:48.860
As you can see, the return address is overwritten because there is no canary successfully manipulating the PC register.

14:50.480 --> 14:53.600
However, we encountered a few problems.

14:53.600 --> 14:58.220
First, Annex was enabled, so we needed to perform the ROP.

14:58.220 --> 15:06.100
Next, since the payload must be successfully delivered to the server, we could only insert printable characters.

15:06.680 --> 15:13.580
All gadgets in the binary start with 1, so we could not use gadgets within binary.

15:13.980 --> 15:17.600
For this reason, we also couldn't leak the libc address.

15:18.780 --> 15:21.480
So, how do we write the exploit code?

15:21.480 --> 15:23.480
We found several solutions.

15:23.480 --> 15:29.440
First, we discovered that the R0 register holds a stack address at a certain size.

15:29.440 --> 15:35.540
We confirmed that this stack address contains the string we inserted into the query string.

15:35.680 --> 15:41.840
Next, since the main binary has a 32-bit address space, it has low entropy.

15:42.600 --> 15:49.680
Lastly, the Lydie binary spawns a new child process whenever the child process dies.

15:50.440 --> 15:51.820
What do you think?

15:51.820 --> 15:54.800
Doesn't it seem like everything is set for fault-proof?

15:55.860 --> 15:57.320
Look here.

15:57.320 --> 16:03.080
As I mentioned, the R0 register holds a stack address containing the string we can manipulate.

16:03.080 --> 16:06.740
At that time, we can control the PC register.

16:07.420 --> 16:14.300
Now, we needed to reboot the binary until the PC register holds the libc system address.

16:15.100 --> 16:16.720
Here is the method.

16:16.720 --> 16:22.380
We send a request that makes the R0 register hold the libc command payload.

16:22.380 --> 16:26.980
Then, we send an arbitrary libc system address in the PC register.

16:27.820 --> 16:30.820
Now, let's start the boot machine.

16:30.820 --> 16:32.920
Before long, we obtained a share.

16:32.920 --> 16:40.480
Fortunately, we got the share within 600 tries, not the expected 2 to the power of 16 tries.

16:41.580 --> 16:43.940
Great, we got a root share.

16:43.940 --> 16:45.800
But what can we do with it?

16:45.980 --> 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.

16:58.840 --> 17:04.720
Unfortunately, since this vulnerability has not been patched yet, we cannot disclose it in here.

17:05.460 --> 17:11.080
All right, we can now access the device management page with admin privileges.

17:11.080 --> 17:13.060
Now, we can do anything.

17:14.380 --> 17:20.940
This is the real-time video manipulating scenario made by chaining the explained vulnerabilities.

17:21.000 --> 17:24.660
The attacker infiltrates the MVR through RCE.

17:27.760 --> 17:34.340
Then, using a vulnerability we cannot disclose here, the attacker gains access to the admin web page.

17:37.280 --> 17:41.320
Finally, the attacker manipulates the real-time video.

17:47.670 --> 17:52.090
Here is the demo video of this scenario.

17:53.090 --> 17:59.850
When we send a payload, the MVR screen is tampered.

18:04.610 --> 18:10.250
Next, let's discuss the machine authorization scenario for Synology.

18:10.250 --> 18:14.850
Synology performs a load of MVR through the surveillance station package.

18:14.850 --> 18:19.210
Let's look at the authorization code of this package's API handler.

18:19.210 --> 18:26.210
First, it verifies if the user sending the request is logged in through the isAuthorized function.

18:26.370 --> 18:31.790
Then, it checks if the user has permission to use the surveillance station package.

18:31.790 --> 18:34.250
Doesn't it seem like something is missing?

18:34.250 --> 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.

18:44.190 --> 18:51.170
So, we found that even with guest permissions, one could abuse all features of the Synology surveillance station.

18:51.170 --> 18:58.070
We discovered that surveillance station features include reboot, shutdown, and package installation.

18:58.970 --> 19:02.110
Additionally, we found something unusual.

19:02.110 --> 19:08.350
Some requests usable in surveillance station are forwarded to the NAS's core package.

19:08.350 --> 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.

19:24.470 --> 19:30.430
We received CVE with CVESS score 9.9 from Synology.

19:32.110 --> 19:35.910
Next, let's look at the scenario of hijacking real-time video.

19:35.910 --> 19:42.370
In a normal flow, guests do not have access to the camera, so they cannot view video on the front end.

19:43.690 --> 19:49.010
However, due to the vulnerability, even guests can obtain video information.

19:49.030 --> 19:58.250
Synology returns the RTSP server address and access credentials in the response, granting attackers unlimited access to the videos.

19:59.590 --> 20:01.230
Let's look at the scenario.

20:01.230 --> 20:04.910
Here, we included a request to terminate the layout.

20:04.910 --> 20:14.410
The attacker sends a request to terminate the layout, disconnecting all live video layouts connected to Synology on all computers.

20:18.560 --> 20:25.480
Then, the attacker sends GetLiveViewPass request to steal the video information.

20:29.240 --> 20:34.620
And requests the video from the RTSP server using the stolen information.

20:38.600 --> 20:42.720
Now, the attacker has hijacked the real-time video.

20:45.260 --> 20:46.960
Here is the demo.

20:47.800 --> 20:57.680
When we send the payload, the layout is terminated and we can watch the live video.

20:58.520 --> 20:59.820
Thank you.

21:11.140 --> 21:15.840
Next, we will introduce the vulnerabilities and scenarios of DAWA.

21:15.840 --> 21:21.800
The first vulnerability is called reachable assertion, and we will explain how we found it.

21:21.900 --> 21:27.020
While analyzing the login function, we discovered that there are many login options.

21:27.020 --> 21:32.240
As shown in the table below, there are six types of assert time and password type pairs.

21:33.240 --> 21:37.540
By default, the assert type and password type are set to default.

21:37.540 --> 21:44.760
The data sent in the request includes the username, hashed password, session, assert type, and password type.

21:44.760 --> 21:49.980
If the request is successful, a response containing true is received.

21:50.840 --> 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.

22:02.240 --> 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.

22:13.220 --> 22:15.470
Now, let me explain the vulnerability.

22:16.300 --> 22:22.900
First, before processing the login logic, the function's getPasswordType and its password value are called.

22:22.900 --> 22:33.640
The getPasswordType function extracts assert type and password type by parsing, and compares specific strings such as default and default, respectively.

22:34.020 --> 22:38.600
If the strings match, the function returns a type for their own.

22:38.600 --> 22:45.800
If the type is both default, it returns 4, and if it is OTP and SSC, it returns 7.

22:46.380 --> 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.

22:59.020 --> 23:04.200
The series of process enters when assert type and password type are set to default.

23:04.200 --> 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.

23:15.840 --> 23:21.520
Most of the branches have this null exception handling logic, but not all of them.

23:22.340 --> 23:28.100
The following code handles the case when the authentication type is OTP and WSSC.

23:28.100 --> 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.

23:39.780 --> 23:48.240
So, we remove the authority input parameter, set the authentication type to OTPWSSC, and send a request.

23:48.240 --> 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.

23:59.940 --> 24:05.340
When the main binary terminates, the watchdog causes the device to reboot.

24:05.360 --> 24:07.680
This is a pretty simple vulnerability.

24:08.160 --> 24:14.380
The following vulnerabilities are very important because they require the device to reboot.

24:15.380 --> 24:18.900
The second vulnerability is Elf Injection.

24:18.900 --> 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.

24:29.120 --> 24:36.140
This group information is stored in a file named groupsec and is encrypted using ASCBC.

24:36.220 --> 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.

24:44.380 --> 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.

25:02.200 --> 25:06.940
The structure of the decrypted groupsec file is as follows.

25:06.940 --> 25:10.660
The columns are ID, name, authority, and memo.

25:10.660 --> 25:16.520
Each column is separated by a column, and each line is separated by a line feed.

25:17.680 --> 25:26.940
When adding or modifying group information, the getline function is called as part of the process of saving the changed data.

25:26.940 --> 25:36.300
This function generates a line with the ID, name, authority, and memo, extracted from the login request separated by columns.

25:36.300 --> 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.

25:46.180 --> 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.

25:57.820 --> 26:04.880
As a result, the device entered the initialization routine and recreated the groupsec file.

26:04.880 --> 26:12.520
When entering the initialization routine, the user can change the add-in password on the web and perform any actions.

26:12.520 --> 26:18.380
We are curious if the initialization routine would still be entered if the file was deleted.

26:18.500 --> 26:25.320
After deleting the file and rebooting the device, we found that it still enters the initialization routine.

26:26.200 --> 26:32.440
Let me introduce the first scenario of DAWA using two vulnerabilities mentioned above.

26:32.440 --> 26:39.820
By using retrieval assertion and alpha injection, an attacker can take over the device and obtain add-in privileges.

26:40.060 --> 26:46.800
First, the attacker obtains an account with a user-managed privileges through credential stuffing.

26:47.480 --> 26:51.920
Next, the structure of the groupsec file is tampered through alpha injection.

26:51.920 --> 26:59.730
Then, the attacker reboots the device using retrieval assertion.

27:03.680 --> 27:14.400
When rebooted, the device enters the initialization routine, allowing the attacker to change the add-in password and perform malicious activities.

27:19.150 --> 27:21.970
Next is Stack Overflow.

27:21.970 --> 27:29.070
First, this vulnerability occurs not in the main binary but in a background service called AOL.

27:29.070 --> 27:37.130
This service is used to attempt online recovery when the device is abnormal, and it's open on port 8088.

27:37.650 --> 27:42.950
Since this port is not forwarded, it can only be accessed from the same network.

27:43.090 --> 27:47.930
It consists of 16 bytes of fixed size of headers and data.

27:47.930 --> 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.

27:58.110 --> 28:05.390
The data is then used as an argument for the input handler remitted by the data size defined in the header.

28:05.390 --> 28:10.010
However, the pinpoint is that the data size can be publicated.

28:10.190 --> 28:14.090
Now, let me explain the request processing procedure.

28:17.290 --> 28:20.090
The following function is called per-message.

28:20.090 --> 28:28.930
First, this function uses the structure with the VFT array, which consists of functions and variables related to each feature.

28:29.910 --> 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.

28:44.330 --> 28:46.770
There are about 20 such tables.

28:47.670 --> 28:49.890
Here is how it works internally.

28:49.890 --> 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.

28:58.930 --> 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.

29:11.250 --> 29:17.270
If the result is zero, it returns zero, or otherwise, it returns minus one.

29:17.270 --> 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.

29:29.650 --> 29:36.170
If the matching index is found, minus one is returned, and the request is not processed.

29:38.290 --> 29:41.230
Next, the dpStackParse function is called.

29:41.230 --> 29:47.090
This function retrieves the table corresponding to the index and calls the parseFarm function.

29:47.270 --> 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.

29:57.510 --> 30:07.390
Finally, once all preprocessing steps are complete, the dpHandleQuery function is called to register the input handler and then execute it.

30:08.510 --> 30:16.590
There are many different functions that could be called, including logWin, query, and update, but they all require the logWin.

30:17.270 --> 30:20.770
So, we started analyzing the logWin function first.

30:22.030 --> 30:26.170
The function is executed if the first byte is A0.

30:26.170 --> 30:33.350
The data consists of username, password, and a random value with a double ampersand used as a delimiter.

30:33.350 --> 30:38.530
The vulnerability occurs when parsing this data, which we'll explain in a moment.

30:39.850 --> 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.

30:54.490 --> 31:00.990
Next, a stringString function is called to find the positions of the double ampersands and null.

31:00.990 --> 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.

31:10.050 --> 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.

31:18.410 --> 31:21.750
As a result, a buffer overflow occurs.

31:21.750 --> 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.

31:33.510 --> 31:39.010
Since there was no stack canary, we couldn't manipulate the PC register.

31:39.010 --> 31:46.230
However, we encountered an issue where we couldn't include a null in the payload, making our pain possible.

31:46.270 --> 31:50.050
We didn't want to conclude with just a simple buffer overflow.

31:50.050 --> 31:53.410
So, we began analyzing the source code.

31:54.050 --> 31:57.410
Fortunately, we found some useful functions.

31:57.410 --> 32:06.350
There were functions for rebooting, starting SSH, removing inter-settings, performing a soft recovery, and killing all MBR-related binaries.

32:06.710 --> 32:10.670
Among these, the most interesting function was the soft recovery.

32:10.670 --> 32:16.150
This function deletes the config directory, resetting all configuration information.

32:16.150 --> 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.

32:28.610 --> 32:34.650
Therefore, we manipulated the PC register to call the soft recovery function.

32:34.650 --> 32:41.090
However, soft recovery deleted even the network files, making external access impossible.

32:41.090 --> 32:44.050
Unfortunately, we faced another challenge.

32:44.950 --> 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.

33:00.310 --> 33:03.630
So, we began analyzing the boot loads.

33:03.970 --> 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.

33:14.030 --> 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.

33:24.930 --> 33:30.130
The most fortunate point is that AOR is loaded before the main binary boots.

33:31.410 --> 33:37.110
First, we kill the main binary using the recover assertion, causing the device to reboot.

33:37.690 --> 33:41.730
Then, we wait until the network configuration file is loaded.

33:41.730 --> 33:46.690
In our case, it took approximately 20 seconds for the device.

33:47.530 --> 33:54.150
Next, we send the soft recovery failure to AOR, which deletes all configuration files.

33:54.290 --> 34:01.230
Then, the main binary can't access the account configuration file and enters the initialization routine.

34:01.870 --> 34:05.550
As a result, we are able to change admin account.

34:05.550 --> 34:12.750
Let me explain the admin takeover vulnerability using recover assertion and stack buffer overflow.

34:12.750 --> 34:16.710
First, we will reboot the device via recover assertion.

34:18.550 --> 34:23.970
After rebooting, we wait for the network configuration file to be loaded.

34:25.530 --> 34:32.570
And then, send the soft recovery failure to AOR to remove all configuration files.

34:34.800 --> 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.

34:46.840 --> 34:52.000
The attacker changes the admin password and gains access to the admin page.

34:53.240 --> 34:54.940
This is a demo.

35:08.390 --> 35:11.130
The last vulnerability is from Hikvision.

35:11.130 --> 35:17.250
Hikvision was much more solid compared to other devices, making it more challenging.

35:17.310 --> 35:21.750
However, we found an interesting vector, a local subs component.

35:21.750 --> 35:27.130
That is a plugin that must be installed for users to view video from the web.

35:27.130 --> 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.

35:38.170 --> 35:44.510
It was a very interesting plugin, so we started analyzing it and found the vulnerability.

35:44.510 --> 35:51.670
Due to an entity associated with a bounty for this vendor, we can't disclose detailed root codes.

35:51.670 --> 35:57.890
In short, it is a vulnerability that allows RCE by sending a crafted message.

35:58.330 --> 36:00.390
Instead, we will show you a demo.

36:00.390 --> 36:04.930
Through RCE, we can completely take control of Windows.

36:04.970 --> 36:08.530
With admin privileges, we can perform any actions.

36:16.320 --> 36:25.530
The next vulnerability is OS command injection, which allows a user with admin privileges to execute arbitrary commands.

36:26.330 --> 36:32.530
We create a scenario to take control of the internal network using these two vulnerabilities.

36:32.790 --> 36:37.350
First, we obtain admin privileges through credential stuffing.

36:38.890 --> 36:43.730
Next, we open a reversal through command injection to enter the MVR.

36:45.530 --> 36:53.530
Then we perform network scanning to find Windows computers using the application named local subs component.

36:54.550 --> 37:02.150
Finally, by exploiting the plugin RCE, we could take control of Windows and perform malicious activities.

37:03.530 --> 37:05.530
Here is the demo.

37:05.530 --> 37:17.120
By just pressing the button, we can automatically take control of Windows computer in the...

37:32.160 --> 37:39.820
One of the things we learned during the project is the Hikvision and our Huzy OEM supplier.

37:40.720 --> 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.

37:50.160 --> 37:56.640
This means that devices are being used all around us without realizing that they are made in China.

37:57.700 --> 38:02.020
First, OEM stands for Original Equipment Manufacturer.

38:02.140 --> 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.

38:12.840 --> 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.

38:24.320 --> 38:28.620
The images below show DAWA's MBR and OEM's MBR.

38:28.620 --> 38:31.280
They look very similar, don't they?

38:32.260 --> 38:36.000
This picture illustrates the OEM sales process.

38:36.000 --> 38:44.480
Products manufactured by OEM suppliers like Hikvision and DAWA are relabeled by OEM vendors and sold to users.

38:44.880 --> 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.

38:55.580 --> 39:00.480
This means that many devices can be impacted by the same vulnerability.

39:01.260 --> 39:07.900
So, we decided to check if the vulnerabilities were valid for OEMs using the same firmware.

39:07.960 --> 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.

39:15.960 --> 39:20.540
Hikvision also confirmed similar through deeping.

39:21.480 --> 39:29.140
After confirming that OEM vendors use similar firmware, we decided to fault-trace devices and test them.

39:29.140 --> 39:32.480
For Hikvision, we fault-traced Anki and Ampibis.

39:32.480 --> 39:35.460
Four out of six vulnerabilities each were valid.

39:35.840 --> 39:38.880
For DAWA, we fault-traced Zhiyuan and EGPS.

39:38.880 --> 39:43.020
Four and six of the seven vulnerabilities were valid, respectively.

39:43.120 --> 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%.

40:01.460 --> 40:06.860
Finally, we will show you a video of vulnerability testing on OEM vendors.

40:06.860 --> 40:10.640
The first video is the OEM vendor testing for DAWA.

40:10.640 --> 40:15.780
By sending DAWA's recover assertion payload, we could shut down all devices.

40:18.410 --> 40:22.910
The second video is OEM vendor testing for Hikvision.

40:22.910 --> 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.

40:33.310 --> 40:40.050
Also, we are curious about how many devices were affected by the vulnerabilities we found.

40:40.050 --> 40:42.850
So, we searched using Shoda.

40:43.870 --> 40:52.890
In the case of Hikvision, most model devices' name or firmware versions were not present in the banner data.

40:52.910 --> 40:58.350
So, we needed a different approach to identify as many as possible.

40:58.450 --> 41:05.970
We found that for MBR devices, when accessing the login page, a config.json file is requested.

41:05.970 --> 41:11.510
This file contains the configuration information related to MBR.

41:11.510 --> 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.

41:22.910 --> 41:28.870
As a result, we found that approximately 130,000 devices were vulnerable.

41:29.910 --> 41:35.690
For Delwa, since the device name was present in the banner, we simply searched for it.

41:35.710 --> 41:40.310
As a result, we found approximately 100,000 devices.

41:41.430 --> 41:44.330
Finally, we came to the conclusion part.

41:44.330 --> 41:50.870
First of all, this is what we would like to comment to offensive researchers in MBR field like us.

41:50.870 --> 41:55.330
The vulnerabilities were discovered during our research period include.

41:55.330 --> 42:01.210
Even when analyzing one-day cases, we found that these vulnerabilities were statically numerous.

42:01.410 --> 42:07.490
So, when you want to analyze your MBR, we recommend that you focus on these vulnerabilities.

42:08.490 --> 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.

42:21.350 --> 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.

42:40.090 --> 42:48.990
Therefore, we recommend that you do not focus solely on analyzing the HTTP process, but analyze various attack surfaces.

42:50.350 --> 42:55.050
The following is what we would like to recommend to users.

42:55.050 --> 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.

43:04.950 --> 43:15.490
Major MBR vendors provide solutions that allow external access using things like DDNS without exposing the device to an external network.

43:15.490 --> 43:21.050
You can take advantage of these solutions to keep your devices safe from these attacks.

43:23.880 --> 43:26.980
Thank you to people who helped us with the research.

43:26.980 --> 43:29.480
Especially, thank you to Dr.

43:29.480 --> 43:30.700
Junsang Yoo.

43:32.080 --> 43:34.620
Thank you for listening to our presentation.

43:34.620 --> 43:38.740
And if you have any questions, please contact us on Twitter below.

43:38.740 --> 43:42.580
More details of our research can be found via the QR code on the right.

43:42.580 --> 43:43.400
Thank you.

