[00:00.640 --> 00:05.660] Hello everyone, welcome to VMware Device Visualization Backhunting. [00:06.020 --> 00:11.880] We are excited to share our talk with you and also feel a little disappointed for we cannot [00:11.880 --> 00:18.380] arrive DEF CON in person. And we do hope our talk will serve as a guide for anyone who's [00:18.380 --> 00:28.020] looking to start VMware security research. Firstly, allow me to introduce us to you. [00:28.020 --> 00:34.140] My name is Jiaxin Huang and Hao Zheng and me are both security researchers of Tenggong team [00:34.140 --> 00:41.260] at Xianxin Group. And we are both interested in reverse engineering and visualization security. [00:41.720 --> 00:47.640] Yueliu is our team leader. And our team consists of lots of people interested in [00:48.340 --> 00:54.900] viral security domain. And we have a website to post our blog on it. So if you are interested in [00:54.900 --> 01:02.900] it, make sure to follow us. And if you have any questions, feel free to DM or email us. [01:04.580 --> 01:09.420] Here is the short story. Let's describe our visualization backhunting journey. [01:09.420 --> 01:15.060] We actually started to research visualization security from the end of 2022. [01:15.800 --> 01:24.180] And in that time, we basically know nothing about visualization. So why are we interested in it? [01:24.900 --> 01:31.020] Because visualization is involved in lots of hacking contests. And it's a very hard, [01:31.020 --> 01:38.320] very challenging target. And for myself, I want to reverse engineer it and learn how it works. [01:38.520 --> 01:45.200] So what have we achieved in last year? We successfully escaped from the paralyzed desktop [01:45.200 --> 01:53.600] on GeekCon 2023. And we reported lots of workstation EXXI bugs to VMware. [01:55.180 --> 01:59.530] And we learned a lot, not just about visualization, [02:00.040 --> 02:03.290] but about the whole architecture of the entire computer. [02:05.380 --> 02:13.380] So what can we bring to you today? Firstly, we will introduce the VMware visualization architecture [02:13.380 --> 02:20.580] to you. Most people hunting bugs directly from debugging the visual device is code. [02:20.840 --> 02:26.820] But we choose to take a bigger view. We studied it from reverse engineering the whole VMware [02:26.820 --> 02:32.520] visualization architecture. And this helped us to figure out which code and how they can be [02:32.520 --> 02:41.840] influenced by the guest OS. And hopefully, it will bring some new idea to you. And later, [02:41.840 --> 02:48.080] we will use the bugs that we found in USB visualization and SCSI visualization to explain [02:48.080 --> 02:55.100] the possible source of 3D in visual device. And anyway, a visual device is still the most [02:55.900 --> 02:59.900] cost-effective choice in visualization bug hunting. [03:01.700 --> 03:07.280] Okay, let's start the first part. VMware Hypervisor Reverse Engineering. [03:09.400 --> 03:16.200] If you are new to VMware visualization, I do have some tips for you. The most important [03:16.200 --> 03:24.900] binary on VMware Workstation or EXXI is VMX. It is responsible for starting the visual machine [03:24.900 --> 03:33.260] and contains most of visual device code. And no matter it is EXXI or Workstation, [03:33.260 --> 03:40.780] VMX is identical and basically just use different system API. And in this part, [03:40.780 --> 03:47.940] we will use Workstation for example. And also debugging VMware Workstation on the Windows can [03:47.940 --> 03:58.620] be much easier. OpenVM tools shares a lot of code with VMX, like IO function, event loop, [03:58.620 --> 04:06.340] and this can really speed up your reverse engineering procedure. And also, as a beginner, [04:06.340 --> 04:14.240] you may need to collect CVs, papers, device documents, and even check the QEMU code. [04:14.240 --> 04:18.680] Just utilize every information you can find to reverse engineering. [04:20.340 --> 04:28.320] So, first question, where should we start? If you already learned something about Hypervisor, [04:28.320 --> 04:33.190] there's always a loop that handles switching in or switching out of the visual machine. [04:33.680 --> 04:41.660] So we will locate the loop code and start reverse engineering the Hypervisor from there. [04:42.100 --> 04:50.890] Also, we know that VMX is a user-mode process, so it should access the kernel for switching. [04:50.890 --> 04:59.650] So they should have a kernel module. And on Windows, it's VMX86. And if we are talking [04:59.650 --> 05:10.250] about the EXXI, it just directly communicates with the VM kernel. And tools such as API Monitor [05:10.250 --> 05:17.510] can help us analyze the communication process between the VMX and the host OS kernel. [05:19.710 --> 05:27.630] And so, of course, the OS lock screen can help us to figure out the meaning of the [05:27.630 --> 05:37.810] device IO control. So it won't be hard to locate the main loop code. You can see that VMX [05:37.810 --> 05:45.530] uses the IO control ROM VM switch into the visual machine and blocks it until the [05:45.530 --> 05:52.270] visual machine needs to force you to help. VMX will get the return code of the IO control ROM VM [05:52.270 --> 05:58.710] and call the corresponding user RPC handler to handle the visual machine request. [06:00.230 --> 06:09.690] So what is the user RPC? And it's a mechanism that VMware designed for VMM to interact with [06:09.690 --> 06:19.830] VMX on host. And very similar to hypercode, but on user space process VMX. And user RPC [06:19.830 --> 06:27.210] contains lots of code related to device emulation. And basically, it is the start of device emulation. [06:28.710 --> 06:37.090] And it will only take one argument, which is user RPC block pointer. And it's a shared area [06:37.090 --> 06:45.890] memory region. Shared area is another mechanism for shared data with VMX and VMM. You may not be [06:45.890 --> 06:53.490] able to see some data be changed in VMX because they may be modified in VMM. So if we want to [06:53.490 --> 06:59.950] know what is passed in user RPC block, we should figure out how the shared area works. [07:01.570 --> 07:08.330] The implementation of shared area is related to creation and loading of VMM. [07:08.830 --> 07:16.430] So we need to study it from the initialization process and pay attention to every memory [07:16.430 --> 07:24.710] location cost. And also remember to check the interaction between VMware VMX and VMX86. [07:26.570 --> 07:34.430] We will notice that there is a EOF object called a VMM block embedded into VMX binary. [07:34.850 --> 07:42.210] Also, there are lots of VMM extensions stored in VMM block section. And these are also EOF [07:42.210 --> 07:50.850] objects. VMX will link them with VMM block in memory to construct the actual VMM binary [07:51.690 --> 07:54.270] according to the user's configuration. [07:56.910 --> 08:07.610] Okay, let's take a look at the VMM block. We can see there are predefined export symbols such as [08:07.610 --> 08:14.450] user RPC block and their corresponding mapping address in the shared private CPU VMX section. [08:14.750 --> 08:21.230] And some virtual devices require the shared memory too. So VMX will define this export [08:21.230 --> 08:28.830] or symbol in it too. And after these symbols have been defined, VMX will calculate the total [08:28.830 --> 08:36.090] size of shared area memories and allocate the corresponding memory space. Now we have seen how [08:36.090 --> 08:41.170] shared memory were allocated, but how do VMM access them? [08:42.790 --> 08:49.290] You will notice that VMM block has two sections. One of them contains VMM's [08:49.290 --> 08:55.790] GDT information and the other contains the VMM's virtual address mapping information. [08:58.050 --> 09:05.950] And combining this information, we will see VMX is responsible for allocating memory. [09:06.090 --> 09:12.930] And building the page table structures based on VMM block's information. And the VMX86 [09:12.930 --> 09:20.310] will further populate the page table information and allow the VMM EO file, which is constructed [09:20.310 --> 09:29.830] by VMX. And VMX, VMM block, VMX86 work together to build the VMM's environment. [09:30.330 --> 09:34.030] And mapping the host allocated address to VMM's virtual address. [09:34.030 --> 09:39.670] So if you need to know how to manipulate data in shared area region, [09:39.670 --> 09:48.790] you will need to check the VMM's code. And VMX choose to run which user RPC code handler is [09:48.790 --> 09:56.050] depending on the return code of the IO control VM run. So it's time for us to check how VMware's [09:56.050 --> 10:07.110] switch works. And the most important structure is cross page. It's a one page size memory region [10:07.110 --> 10:16.370] allocated for each vCPU by VMX86. And it's responsible for storing the context between [10:16.370 --> 10:26.570] VMM and the host. Just like the VM says, VMCS in Intel VT. We can check the monitor [10:26.570 --> 10:35.930] loader section to see its virtual address on the VMM's environment. When VMX call the IO control [10:35.930 --> 10:45.130] run VM, it will cause the VMX86 cause the host to switch to VMM code. And saving the [10:45.640 --> 10:51.690] CPU state to cross page and restore the VMM's CPU state. [10:51.850 --> 10:57.330] And the operation to switch out is the opposite of this process. [10:58.830 --> 11:07.150] Now we can check the VMM's code to see user RPC is implemented through the platform user code. [11:07.210 --> 11:13.190] And save the user RPC opcode and the platform code invocation number 100 to the cross page. [11:15.130 --> 11:25.350] And the platform code 100 will cause the VMX86 to return the user RPC code to VMX. [11:25.350 --> 11:32.430] So when IO control run VM returns, VMX can call the corresponding user RPC code handler. [11:33.010 --> 11:38.340] Also, whenever VMM prepares to call user RPC, [11:38.750 --> 11:44.630] you will see VMM modify the user RPC block to transfer data to VMX process. [11:47.230 --> 11:55.910] So now we finally understand the whole user RPC implementation. And based on this knowledge, [11:55.910 --> 12:01.030] we are able to further reverse the engineering the device visualization. [12:01.730 --> 12:08.790] For port IO emulation, VMM will reserve the x86 IO instructions [12:08.790 --> 12:14.430] and may attempt to use the user RPC to call VMX to process. [12:16.450 --> 12:23.290] And not all of the port IO callback will be registered in VMX process. [12:23.330 --> 12:27.910] There are some devices implement their IO callback in VMM. [12:29.230 --> 12:41.170] For MAMIO, in most cases, VMX associates the memory region with an ID and implement the callback in VMM. [12:43.550 --> 12:52.650] And most MAMIO functions in VMM automatically will call user RPC to handle the device emulation. [12:52.810 --> 12:57.350] But they may access the shared area to transfer data to VMX. [12:57.350 --> 13:05.750] So you need to check the code in VMM to understand what happened when you access the MAMIO region in guest machine. [13:08.130 --> 13:13.580] Also, physical memory access is another important part we need to analyze. [13:14.310 --> 13:18.700] We will not discuss too much about the memory mapping structure. [13:19.270 --> 13:24.560] But you should know that on Windows, the main guest memory is mapped as a file. [13:25.130 --> 13:30.230] And on EXXI, it is mapped by VMKernel. [13:30.890 --> 13:37.610] When VMX gets the physical memory region object, it will first check the object's type. [13:37.610 --> 13:42.530] And in most cases, it will directly access the point field. [13:44.410 --> 13:52.370] And the last interesting thing is we also found that on EXXI's VMM, [13:52.370 --> 13:56.970] some visual devices MAMIO will not always call user RPC. [13:57.430 --> 14:02.610] They will call user RPC only when hosted emulation is enabled. [14:02.950 --> 14:07.630] Instead of using user RPC to interact with VMX, [14:07.630 --> 14:14.670] they use VMK code directly called VMKernel to handle device emulation. [14:15.410 --> 14:20.650] So although VMX are identical on EXXI and Workstation, [14:21.730 --> 14:25.550] visual device emulation code won't always be the same by default. [14:29.530 --> 14:36.350] And basically, this graph describes the result of our VMware hypervisor analysis. [14:41.700 --> 14:47.940] Anyway, it is important for you to check the VMM code when you reverse engineering the device [14:47.940 --> 14:56.980] visualization. If you are not sure where device's data comes from, you can go check the VMM's code. [14:57.120 --> 15:01.280] If you are not sure how to trigger the device's code, [15:01.280 --> 15:08.500] you can go check the VMM's code. And if you want to find some new device's code, [15:08.500 --> 15:12.260] go check the VMM's code. [15:15.590 --> 15:23.360] Okay, let's enter in the second part, VMware device visualization bug hunting. [15:23.360 --> 15:34.260] Okay, let's start from the USB part. Basically, we can divide the USB emulation into three parts. [15:34.260 --> 15:43.420] USB host controller emulation, like EHCI, EHCI, XHCI. [15:44.360 --> 15:52.360] The second part, VUSB emulation. These are objects described in the USB specification. [15:52.360 --> 15:59.880] For example, URB object, USB pipe object, and USB port object. [16:00.640 --> 16:08.160] And the third part, VUSB backend device emulation. And these are actual USB devices, [16:08.160 --> 16:20.100] such as Bluetooth, HID, and RNG, and so on. So, as you can see, [16:20.100 --> 16:28.000] when guests want to access the USB device, it will need to put data in memory and access the [16:28.000 --> 16:36.360] host controller MMIO space, which will trigger the VMM handler's MMIO access, causing the [16:36.360 --> 16:44.100] corresponding user RPC co-handler in VMX. Then it will convert the data into URB object, [16:44.100 --> 16:51.920] and eventually processed by the backend USB device. If it tries to access a USB device [16:51.920 --> 16:57.160] plugged in the host machine, it will also need another service to help. [16:57.600 --> 17:02.620] And we actually find bugs in all these three parts. [17:04.400 --> 17:12.560] The fourth bug is in the host controller part, and it's an uninitialized memory. [17:13.520 --> 17:21.360] Before we start it, let me just explain some concepts. In control transfer, a USB device [17:21.360 --> 17:29.020] accepts a type of request called a standard device request, which begins in the format of [17:29.020 --> 17:36.900] setup packet. So it will be 8 bytes at least, and it has a w-length field, [17:36.900 --> 17:46.340] the length of subsequent data. The USB device may use this type of data, but the host [17:46.340 --> 17:53.860] controller does not transfer data based on this unit. For example, in UHCI, data is transferred [17:53.860 --> 18:04.880] in units of transfer descriptors. So when VMX handles the UHCI emulation, it retrieves the [18:04.880 --> 18:12.260] first TD on QuickHead and extracts the w-length field from the setup packet, and uses this size [18:12.260 --> 18:20.680] to determine the size of data buffer for URBObject. After allocation is finished, it will copy the [18:20.680 --> 18:29.960] data into URBObject, and they do lots of checks to prevent buffer overflow. Let's go back to the [18:29.960 --> 18:37.960] allocation process. It's actually when we're depending on the target USB device you are [18:37.960 --> 18:45.240] transferring to. A different type of backend USB device will result in URBObject with different [18:45.240 --> 18:53.740] fields. For example, HID device will allocate URBObject with all the additional fields besides [18:53.740 --> 19:01.360] the data buffer of the URBObject. Also, HID device will use malloc for data location. [19:05.020 --> 19:11.220] So there are some problems here. Allocating w-length size URBObject doesn't mean you will [19:11.220 --> 19:17.120] get the w-length size data from guest-supplied TDs. And malloc allocation lets the memory [19:17.120 --> 19:23.720] un-initialized. Also, backend USB device will return data through the same URBObject buffer. [19:23.740 --> 19:28.280] So it will eventually let the HIP data leak to the guest OS. [19:30.720 --> 19:37.220] And the second bug is user-after-free appeared in the USB emulation code. [19:37.760 --> 19:46.500] Again, let's first explain some concepts. In XHCI, there is a structure called device context [19:46.500 --> 19:54.400] which stores the USB device status. It is constructed by device-slot-context and [19:54.400 --> 20:02.700] endpoint-context. Device-slot-context holds the USB device information. Endpoint-context [20:02.700 --> 20:09.800] holds the information for a single endpoint. Also, each endpoint has one or more transfer rings. [20:09.800 --> 20:17.200] The data transfer requires blocks on the transfer rings. And XHCI transfer data is based [20:17.200 --> 20:24.560] on these units. In order to explain this bug, we need to look back at an older bug. [20:24.780 --> 20:31.220] And the old bug's patch is very interesting. It only alters the sequence between the calls [20:31.220 --> 20:36.660] to release transfer ring and the code that assigns values to endpoint-context. [20:37.540 --> 20:42.360] Let's first figure out how transfer ring release works. [20:44.660 --> 20:53.040] Firstly, it will get the transfer ring object from the endpoint-context. Then, it will retrieve [20:53.040 --> 21:00.780] the USB device object based on the USB port number saved in the device-slot-context. [21:01.470 --> 21:10.030] Then, it will obtain the USB pipe object from the USB device object based on the endpoint ID. [21:10.680 --> 21:17.340] And after that, it will release all the URB objects on that USB pipe object. [21:17.500 --> 21:21.460] And finally, it will release the transfer ring object. [21:23.420 --> 21:31.860] Also, it will release the possible URB object on the back-end USB device in case there may be [21:32.080 --> 21:41.440] a dangling pointer on the back-end USB device. So, it seems no problems here. However, it's [21:41.440 --> 21:49.420] actually not the URB object that could become the dangling pointer. It is because the transfer [21:49.420 --> 21:57.140] object pointer is not only held by the endpoint-context. A URB object also holds a point [21:57.140 --> 22:04.220] that points to a field of transfer ring object. And this field is responsible for tracking the [22:04.220 --> 22:10.240] corresponding TRP when XHCI returns the USB device response to the guest. [22:11.940 --> 22:18.980] And before the patch, XHCI command-like config endpoint could modify the endpoint-context [22:18.980 --> 22:26.700] contents before releasing the transfer ring. So, it may lead the type stored in [22:26.700 --> 22:35.520] endpoint-context mismatch with the USB pipe object type. And this will cause the function [22:35.520 --> 22:44.900] written without a USB pipe object and left the URB object on that USB pipe object not be freed. [22:45.600 --> 22:54.140] And the previous pointer now becomes a dangling pointer and causing user after-free. So, [22:54.140 --> 23:02.840] now our question is, after this patch, is it possible to make the USB pipe object mismatch [23:02.840 --> 23:10.980] again? We know vmx will need to check the port number stored in slot-connect to find the [23:10.980 --> 23:19.200] USB device object. So, if we can modify the port number, it may lead vmx find a wrong USB [23:19.200 --> 23:25.540] device object. So, in that case, it will also find a wrong USB pipe object. [23:27.300 --> 23:33.560] So, we do have address-device command can make this possible. You can see the address-device [23:33.560 --> 23:39.060] command only modifies the slot-context and the control-endpoint-context. [23:40.000 --> 23:47.300] So, firstly, we finish the device configuration process and we create the transfer ring on [23:47.300 --> 23:55.520] non-control-endpoint. And then we transfer URB data on these transfer rings. In the end, [23:55.540 --> 24:01.660] we use the address-device command on that device to modify the device port number. Now, [24:01.660 --> 24:06.680] if we try to release the transfer ring on that endpoint, it will fail to find the right [24:06.680 --> 24:14.300] USB pipe object and causing UEF again. So, this is a bug that happens between host controller [24:14.300 --> 24:22.500] and the USB emulation. And the cause is it fails to manage the object lifetime in USB emulation. [24:24.660 --> 24:29.570] And the third bug is in the USB backend device emulation. [24:30.280 --> 24:35.610] And it is out-of-boundary will be triggered within the system API. [24:38.740 --> 24:45.800] Let's start with some concepts. The guest OS communicates with the smart card through the [24:45.800 --> 24:53.500] virtual smart card reader. And the guest OS uses CCID protocol to interact with the virtual [24:53.500 --> 25:02.840] smart card reader. The application data units, APD, serve as the payload for interaction between [25:02.840 --> 25:10.560] the smart card reader and the smart card. And you can see their relationship are very like the [25:10.560 --> 25:16.620] host controller and the USB device. And you may already seen that both of these data [25:18.040 --> 25:27.440] structure has the length field. And it is always need to be careful handling this length field. [25:28.280 --> 25:35.100] VMware do checks whether the message length field of CCID protocol matches the length field of [25:35.100 --> 25:41.920] command APD. But it fails to verify whether these two fields conform to the size of URP buffer. [25:43.520 --> 25:50.420] It directly uses this field as arguments to call the Windows sCAD transmits API. [25:50.820 --> 25:55.740] Clearly, sCAD transmits cannot check whether the length matches the data buffer. [25:56.540 --> 26:03.280] So it will out-of-bound access to the heap data and write it to the smart card on your host. [26:03.280 --> 26:09.500] Also, you may be able to read it back. So it's kind of interesting. [26:12.200 --> 26:19.320] Okay, in conclusion, it's very challenging to defend such complex system. [26:19.380 --> 26:26.260] VUSB emulation can be attacked. USB device emulation can be attacked. And host [26:26.260 --> 26:34.700] consoler emulation can be attacked too. Also, we still have cases cannot present. [26:34.700 --> 26:44.640] But you can defer the binary to found. And maybe more attack scenarios in the future. [26:44.760 --> 26:55.540] Maybe plugging evil USB device and leverage the VMX to execute the code. Or leverage local USB [26:55.540 --> 27:06.900] service to privilege escalation. And anyway, that's the USB part. And next part will be [27:07.460 --> 27:16.000] presented by my colleague. And we will show you that how SCSI works different on ESXi [27:16.000 --> 27:27.350] and the workstation by default. Hello, everyone. I'm Zhenghao. I'm the [27:27.350 --> 27:35.070] speaker on this topic. Now it's my turn to expose VMkernel, a whole new attack surface. [27:35.530 --> 27:43.410] But I will first talk about some differences between ESXi and the workstation. Because our [27:43.410 --> 27:51.570] new attack surface is hidden in these small differences. ESXi is a type 1 hypervisor [27:51.570 --> 28:00.950] that runs directly on the host's physical hardware. Well, workstation is a type 2 hypervisor [28:01.310 --> 28:10.190] that is installed on top of an existing host operating system. Workstation sports more [28:10.190 --> 28:19.490] configurations and devices than ESXi. Which means that in certain situations, workstation can be [28:19.490 --> 28:30.430] audited at more points than ESXi. In some specific device, the data flow direction of ESXi and [28:30.430 --> 28:41.150] workstation is different. Next, I will take SCSI device emulation as an example to demonstrate [28:41.150 --> 28:50.290] the vulnerabilities on different attack surface caused by different data flow orientations. [28:50.870 --> 28:59.850] This is an overview of the SCSI data flow. You can see that there are two paths for writing [28:59.850 --> 29:08.330] data to the disk. One through VMkernel and one through VMX. These are two completely [29:08.330 --> 29:15.970] different code paths, belonging to ESXi and workstation, respectively. [29:17.390 --> 29:27.150] The specific code path of SCSI in workstation is shown in the figure. If the user calls the [29:27.150 --> 29:39.850] MPI function SCSIioRequest command, it will enter the LSI logic MPO process SCSIioMessage [29:39.850 --> 29:48.850] function, where it will confirm whether the environment is hosted emulation. Finally, [29:48.850 --> 29:59.410] the LSI logic hosted process SCSIioMessage function calls the relevant handler in VMX [29:59.410 --> 30:11.410] through user RPC. The specific code path of SCSI in ESXi is shown in the figure. [30:11.410 --> 30:21.410] ESXi divides the situation into whether the environment itself is in hosted emulation. [30:21.490 --> 30:29.910] If it's in hosted emulation, it's the same as the workstation path. Otherwise, [30:29.910 --> 30:43.510] it goes to LSI logic VMk process SCSIioMessage. Go to VMkernel through VMk call arguments. [30:45.710 --> 30:56.250] Because of this small code gap, ESXi has a new attack surface that workstation does not have. [30:56.250 --> 31:04.290] Next, I will introduce the vulnerabilities I found on these two different parts. [31:04.830 --> 31:12.430] The first vulnerability we will talk about is located in VMX, [31:12.430 --> 31:18.990] and the official description is out-of-bounds read-write vulnerability. [31:19.790 --> 31:30.270] As a tool for storing data, stability is the most critical and basic requirement for disk. [31:30.270 --> 31:38.540] VMware implements corresponding disk verification capabilities in device emulation. [31:38.810 --> 31:47.310] One of the disk verification capabilities is to detect data corruption through chipset. [31:47.310 --> 31:52.030] This is where the vulnerability occurs. [31:52.550 --> 32:04.570] Before we start, let's first introduce a SCSI command. In the SCSI command's reference menu, [32:04.570 --> 32:14.250] there is a command called write16 that allows the operation of 8-byte logical block address [32:14.250 --> 32:22.550] and 4-byte transfer length. This shows that we can use this command to access [32:22.550 --> 32:33.050] any address in the 64-bit space, provided there is no disk capacity limit check. [32:33.910 --> 32:42.330] VMware did not implement the disk capacity limit check in its disk verification program [32:42.330 --> 32:49.930] implementation. As can be seen in the figure, after applying for a heap of [32:51.150 --> 32:56.590] corresponding size according to the disk capacity, [32:56.590 --> 33:04.050] only the operation is checked to see if it is a read or write operation. [33:05.010 --> 33:16.610] Obviously, this is a heap overflow. The write16 and other read and write commands in the SCSI [33:16.610 --> 33:26.190] command's reference menu allow us to access any 8-byte address. This allows us to easily perform [33:26.190 --> 33:35.150] arbitrary read and write operations. The vulnerability we will discuss next [33:35.150 --> 33:43.530] is located in VMkernel, and the official description is out-of-bounds read. [33:44.150 --> 33:54.150] Still start with the SCSI command's reference menu. In the SCSI command's reference menu, [33:54.150 --> 34:03.410] there is a command called unmap, which can unmap one or more logical basic addresses. [34:04.430 --> 34:14.350] The structure of unmap itself is relatively complex, and is divided into three parts. [34:14.350 --> 34:22.030] unmap command, unmap parameter list, and unmap block descriptor. [34:22.030 --> 34:31.570] Let's first look at the structure definition of unmap command in the SCSI command's reference [34:31.570 --> 34:41.490] menu. The focus of the figure is the parameter length, which indicates the total length of the [34:41.490 --> 34:50.890] unmapped parameter data. The unmapped parameter list is divided into two parts, [34:50.890 --> 34:59.830] unmapped parameter list header and unmapped block descriptor data. The unmapped parameter list [34:59.830 --> 35:08.710] header consists of three fields, unmapped data length, unmapped block descriptor data length, [35:08.710 --> 35:18.470] and reserved. The unmapped block descriptor consists of two fields, unmapped logical block [35:18.470 --> 35:27.750] address and number of logical blocks. These two fields indicate the starting address and [35:27.750 --> 35:37.110] length of the block that the user wants to unmap. This is an open view of the three unmapped [35:37.110 --> 35:46.330] structures, so that everyone can easily understand the structure of the unmapped command. [35:47.270 --> 35:55.970] The three structures are very closely related, and we will focus on parameter list length [35:56.290 --> 36:04.610] and unmapped block descriptor data length. Both fields indicate the length. Unmapped block [36:04.610 --> 36:14.050] descriptor data length indicates the length of all subsequent unmapped block descriptors. [36:14.050 --> 36:22.330] Parameter list length includes not only the length of all unmapped block descriptors, [36:22.330 --> 36:31.450] but also the length of the unmapped parameter list header. Let's see how VMware implements [36:31.450 --> 36:38.810] the unmapped command according to the SCSI command's reference menu. [36:38.970 --> 36:48.410] Before actually running the unmapped command, the vscsi-check-unmapped-cmd function will be [36:48.410 --> 36:58.250] entered first. In this function, a heap of the corresponding size is requested according to the [36:58.250 --> 37:05.850] parameter list length, and all the unmapped data is copied to the heap. [37:05.890 --> 37:13.650] After the unmapped data is copied, the content of the data will be checked. [37:14.030 --> 37:22.010] But it forgets to check the relationship between parameter list length and unmapped block [37:22.010 --> 37:30.250] descriptor data length. And the number of unmapped block descriptors is determined based [37:30.250 --> 37:38.610] on the unmapped block descriptor data length. The user can set a special parameter list [37:38.940 --> 37:47.250] to carry a large number of unmapped block descriptors, but only check the first unmapped [37:47.250 --> 37:57.990] block descriptor. Check completed. Enter the actual use stage. According to the code in the [37:57.990 --> 38:07.010] figure, parameter list length is used as the boundary length, which allows the previously [38:07.010 --> 38:16.870] unchecked unmapped block descriptor to be put into use. The unchecked logical block size [38:16.870 --> 38:27.030] is used as the size variable in the code shown in the figure. An obvious out-of-bounds write. [38:27.030 --> 38:36.450] In fact, it's this out-of-bounds write that actually causes the crash, not the so-called [38:36.450 --> 38:45.690] out-of-bounds read. Regarding the new attack surface of VMkernel, I have summarized the [38:45.690 --> 38:55.650] following three major points. Modify the existing sandbox protection mechanism. Elevate the current [38:55.650 --> 39:04.950] process privileges. Virtual machine escape. Okay, thank you for your listening. If you have any [39:04.950 --> 39:08.910] problem, you can contact us with Twitter.