Thanks for attending our talk. Uh, today we'll share about how we exploit the QoCom WLAN and modem over the air and finally compromised the Linux kernel. Uh, about us, uh, we are the, uh, security researchers from Tencent Blade team. Uh, Tencent Blade team is founded by Tencent Security Platform Department in 2017. Uh, we focus on, uh, security research in the area of AIoT, mobile devices, cloud visualization, blockchain, and ETC. Uh, this is the agenda. Uh, firstly we'll introduce some, uh, related works. Uh, we know that, uh, WLAN security is a hot topic in recent years. Uh, the known exploit on protocol wifi chip is on 2017 and this year on malware. Today our talk is about the QoCom. As we know, uh, this is the first time there is no public exploit on QoCom wifi chip. So how secure, uh, is the QoCom, uh, QoCom wifi? There is a simple, uh, illustration about the architecture of QoCom, QoCom wifi. Uh, there are two important things. Uh, the first one, uh, is that, uh, start from Snapdragon 835. The WLAN firmware is integrated into the baseband sub-system. So the WLAN and the modem firmware are the same processor now. The second thing is that you can see, uh, in QoCom's, uh, implementation, most of the function there is implemented in the Linux kernel driver named QCACLD. Uh, there are plenty of vulnerabilities in this driver. Uh, that is the well-known WLAN host vulnerabilities. Our talk is not about the WLAN host issues. It is about the WLAN firmware itself. Uh, the uh, we know that, uh, there is no public talk on the QoCom WLAN firmware previously. So how about the security status? Uh, we will answer this question. Before we go into the details of the WLAN and modem firmware, we need to introduce the debugger we use to debug the firmware. This is a key step for us to analyze the modem and the WLAN. Uh, there are, uh, modem boot authenticator and the modem images in our system. You can see, uh, mba.mbn is the mba image. Modem.mdt and the modem.bxx are modem images. This images have a specific format according to QoCom's official document. Like, uh, application processor, modem processor also has this secure boot flow. The flow is like this. You can create a command from these uh firstly Linux kernel will load MBA and uh modem images from file system to physical memory. The second uh uh Linux kernel will set the start physical address of MBA and reset the modem processor. Modem PBL in ROM will verify the MBA image. If success it will jump to the MBA code. Finally, MBA will read and verify modem images. If if success it will jump to the modem main code. Uh the peer boot function in Linux kernel describes the boot flow of modem. Uh it will load uh mo- MBA and modem images to physical memory and then check MBA and modem images to be verified and executed in modem processor. Linux kernel will set the kernel can restart the modem processor at any time and it will hit uh peer boot function each time when restart. Uh the vulnerability we use to bypass uh the modem uh secure boot is uh time of check, time of use bug. When MBA verifying modem images it doesn't lock the physical mem- memory region. Means that Linux kernel still can modify the modem images. So uh the after MBA verified one image Linux kernel can still modify it which means that we have bypassed the secure boot check. Uh the poke for the vulnerability is quite simple. There is the uh diff- diff file of peer boot function. We just let the uh uh peer reclaim mem function after we modify modem images. Uh after we have ability to modify the modem images uh we can modify the image images. We can inject debug server to modem side. Uh we injected uh demo thread uh to wait for command from Linux side. The commands and the result results will be exchanged using shared physical memory. Uh we now can uh issue debug command to debug WLAN and the modem firmware. Uh now we have the uh debugger. We can analyze the modem and WLAN firmware much easier. And uh Xilin will introduce the following details. Uh okay. Uh I'm going to introduce the reverse engineering and the vulnerability and exploitation of WLAN. And uh finally we'll get into the Linux kernel. Okay. Let's re-use the architecture of the WLAN. Uh the WLAN is now in the baseband subsystem. And the WLAN is now in the baseband subsystem. And the WLAN is now in the hexagon architecture. Yeah not каждый gemacht architecture. Hexagon architecture. So you can analyze it and if we controlled so WLAN we have actually controlled the baseband the subsystem. Okay. Uh here is the sample figure for the WLAN architecture. Uh from the fear we can see that WLAN four beck formwork. Most of the function of W, WLAN digital human than uh implemented in the Linux Java. You can see here in the QCAC Java. Okay. That's leading to a smaller attack surface than the other vendors. The work to be done here in the firmware is called the offloader. You see the offloader mic layer. Uh the major attack surface is here in the offload handler. The offload handler is actually a table. A function table. It will inspect the OTA packet and if interested in will pass the packet and do and do some job. So the attack could happen here uh when the offload handler handle the packet. So you can analyze it. Okay. Give a an example for how the offloader handle the packet. Okay. The wifi access point is displayed on the wifi list. Okay. If you uh turn on the UI and the fitting and open the wifi you'll see a list of the access point. Okay. Actually when you turn turn on the wifi the Android framework will issue command to the driver and the driver will command the f-firmware to scan the nearby wifi hotspot. Finally the firmware will give the to two-two handlers into the handler table. When the other hotspot or access point send the packet yes if you have an uh access point it will send out a beacon and other packets. So our handler will received receive the data and pass it. If uh into the management beacon it is a transfer into to the driver and finally will notifies the uh the public worker and uh the application so that you can see the SSID and uh other information. Okay? Okay? So now we have some basic things about the Qualcomm WLAN. Uh let's start the reverse engineering. Uh this is the firmware loaded by modem. Uh this is the WLAN firmware. It will load by modem from this position and this is the distance simpler and this is the wonderful SDK provided by Qualcomm and uh instructor reference for the hexagon architecture. Okay? Okay? So uh the WLAN firmware have more than 8000 functions. It's a difficult task to reverse these functions without any knowledge. Uh likely Qualcomm have given us some hint. You can see the most useful thing is the string table. Uh we can find a lot of function names. And the other thing is the input function because the WLAN firmware is load loaded by the modem as a shared library. So the WLAN uses a lot of functions from the modem and they leave the function names in the input function table. They are quite useful. The string table and the input function. Okay? The target we are going to reverse engineering. So we are going to do is um run this test in our falls state set in our . Uh see what events are happening and see what logic are being used in this transition. Uh typically the password is a code that is shipped from the high-end server to problem перед or porter, and when this is�� is collapsed the module will automatically�� this, this is a big function. Actually it's a, it's a big loop and fetch the atoms in the handler table and then call the functions to do the job. Okay. So this is the, uh, major tech services. You can find the table here and find the functions. Uh, this is a sample function. One of the functions looks like this. The most important thing is to find the data pointer. If you send the data, uh, if you want to attack the WLAN, you first send the data. So how to find the data, the data flow? Uh, this is the entry. The one of the handler. You can see. Here, this is the data pointer. Uh, OX5B, 5A, 59, 58. This is the data pointer. So you find this function and find the data pointer and analyze the function and the process of the uh, uh data pointer then you know how, what the, is the function doing and handle vulnerabilities. Okay. Uh, I think this is the most important slide in this, this talk. You can find the function and find the data and handle vulnerabilities as you want. Okay? Okay. So, let's start exploitation. Uh, this is a load map. Uh, we are here, we can send out some single using the Wi-Fi dongle or something else. We are here, we can send out the signals, Wi-Fi signals and we are going to compromise the WLAN and then we are escape into modern and finally we are into the Linux kernel. Okay. To compromise the full Linux kernel. Okay. So before we go, let's check the uh medication status of WLAN to set up an exploitation strategy. Okay. From the medication table we can see that there are lots of medications. Uh for example the HIP. HIP have ASLR. The address of the HIP is not a pixel. And the HIP have platexion, HIP cookie. So uh the overflow of the HIP is not fixed. So the HIP is not fixed. So on the HIP is very difficult to exploit. And also there are DEP. Uh you are unable to uh jump into the data segment. Uh also you are unable to write to the code segment directly. If you want to do so, you have to change the memory attribution. Okay. Also there are frame limiter. Frame limiter to protect the SP. The frame key to protect take the data. Okay. So the return address. Uh so uh if uh you want to use some technical like uh ROP. ROP uh this doesn't work because of the platexion here. Mhmm. But uh we are very lucky. The code ASLR is not enabled. So the code address is fixed. And the CFI is not enabled. So if we uh although we cannot use ROP, we can use something called uh uh FOP. Function Oriented Programming. That is um in the uh gadget of the ROP. All the gadget is uh uh function core. Not a return core. Uh return is a function core. That is function oriented programming. Okay. And uh we are also very lucky. The issue we found is in the global data area. That is here. There is also no ASLR. So the address of the data is also fixed. Okay. We know the address of the data. The water around the the data address. Okay. Let's see the detail of the vulnerability. Uh it's a CVE 2019 10540. Okay. This issue has already been announced in the Android and the Qualcomm August security briefing. And uh has been patched. So if you are interested in about the detail information for the vulnerability, please check the security briefing in August 29. Okay. Uh this issue has been fixed already. Uh uh this issue in one of the off-loader uh handler uh you you remember this table. The off-loader table. There are lots of functions uh called uh off-loader handler. One of the handler have a problem. And uh it's uh pre-auth frame handler. Uh handle the OAE. Uh the pre-auth uh pre-auth means you don't have to connect to a specified access point. You don't have connect to connections to uh hotspot. You just turn on the wifi. The then the uh phone is vulnerable. Okay. It's a pre month vulnerability. Okay. Uh this is uh mommy computer. I would transfer transfer negative into the . The data of what there is is without celebrates for a change of this is straight forward. You can see this loop and this load check about the length and we are copying a lot of data into the destination. We are copying, copying. So endless loop. If you have enough data. Okay. This is 100 bit. Okay. Okay. So let's check the data around the overflow address. You can see it will overflow from here. Global buffer. And uh if you want to do a copy. Overcast 44 data into each item. From here the group of buffer into here. You can see 44 bytes of data. 44, 44. It's a loop. Okay. You know this is the, this is the global buffer in the global static area. So the address will be already know. Because there is no SLR. The meditation table you remember. There is no SLR so we know the address of the overflow data. So it's very convenient for us to exploit. Okay. We can analyze the data around the overflow address. We can analyze the data here. And then we can analyze the data quickly. We can find out the after set of C is a very useful data. It's a very useful data pointer. Pointer to uh uh something we can uh do some useful job. We call it the smart pointer. Using the vulnerability we can override this smart pointer. Over override the content of this pointer. Okay. See how. We use the smart pointer. We can send out a package and uh uh goes into this this uh code flow to use the override data. You can see this is a smart pointer. We override so we can we can change it to our destination we are interested in. And uh if we call into this code flow finally we will override this two bytes uh actually this is three bytes C, D and a 14. We override these three bytes. Okay. Let's see the detail. We override the smart pointer using the vulnerability. And it will uh have two tests. The first test is to test our destination equal to one. And the second test is to test the smart point plus six equal to the MAC address of the sender. And finally, if the two test pass, it will write to the, uh, three bytes using the data from the OTA packet. Uh, this is, uh, the data we control on the sender. And the MAC address is also we control on the sender. So, the only constraint is that if we pass, bypass this, this, this check, we can write arbitrary code to the destination we are interested in. So, we can overwrite something like a function pointer, data pointer, or other thing we are interested in to do the job. Okay? So, we have, uh, uh, global write, write primitive. So, we can write it to anywhere we want if we can bypass this check. Okay. For example, uh, we overwrite the smart pointer to this address. And, uh, the b is the bit in one, so we can bypass the check here. Uh, we can, we can bypass the check here. Okay. And, uh, then we can write it to the offset of C, uh, uh, 56, 7, 8. We can see here, we can write a C and a D. That is uh, uh, six, uh, five, six, seven, eight. We can write it to here. We can use, we call the it is a primitive global write with constraint. Okay? You can write it to anywhere if the no is the beta is one setup. So uh meaningful address or data is all with 4 bytes. So how to write 4 bytes? The answer is quite simple. We just using the write trace. The first time on the node 2 bytes, you know the 5, 6, 7, 8 and the second time we move the smart pointer forward offset by 2 and this one, this bit is still 1. We can write 1, 2, 3, 4 then that is 1, 2, 3, 4, 5, 6, 7, 8. That is 4 bytes and there is still another problem. You see you want to write here 5, 6 and the problem is this bit is not equal to 1. So how to solve this problem? You can search 30-up and if this is 1 then we can use the global write to modify this this this bit. Okay? You can set up to 1. Then you can write to the target. So this is a method we use. So for this complex figure, I can separately also write to the target. So let's discuss the actually we want to control the PC and R0. R0 we have 8 bytes, the first 4 bytes is the PC and the second is R0. We search out from the memory and find this place that we can writeable and reachable by our remote packet. Okay. Then you see there are a lot of one, a lot of one we can move, move the smart pointer forward, move one, move one more and then we can hold right to the type of PC and R0. Okay. So we have control of PC and R0. Uh we can um we can then run some FOP to do some complex job such as to run into the uh FOP and the mapping the uh WX page. This is to map some page to uh modify the code segment. For example uh this is a code segment B00 and uh originally mapping from uh 936. Uh we wanted to want to write the code segment so we using the FOP to um map it to 4242 uh using this uh for FOP. So now we can uh write to the code segment. And uh we can write to, we have a arbitrary write. So we can copy, copy our shell code into the, into the code space and trigger it. You can see we copy the shell code. The shell code is originally in the data packet. So we copy the data packet of data into the destination that is 4242. Then we trigger, trigger this function. Okay. So now we can see that we have uh uh a WM. So now we have running our arbitrary code in the WM. Actually we have now in the WM. Okay. We are going to the modem. Uh the WM in the different uh process in the base band of the modem. Okay. You can see the kernel in the QRTOS and the WM and the modem. So we can run in the process in the running the use of space. So how to get into the WM? Uh into the modem from the WM. There are dangerous actions such as modify the code segment uh and uh write uh modem data or call complex functions uh by the uh uh or illegal. Uh if you if you cause uh if you do this dangerous actions the base band subsystem you are crushed. Okay. But you remember you can map memory. So how about we map the modem memory directly into the WM. Okay. Just like this we map the modem um memory from on the WM. Okay. It's a memory map. Okay. We just map the physical memory into the WM virtual address and then we can modify the memory content. So we can modify the code of the modem. So we are control the modem. Okay. So the last step is to escape from the modem into the Linux kernel. Okay. This is the load map we are going to do. Okay. There are a lot of attack surfaces here. So if you are interested you can read the white paper for detailed information. Okay. Uh the uh the uh the uh the uh the uh the uh the uh this is uh the issue uh the 3 2019 and one five 3 8 which are already been fixed in August um you can see there is a check from the data packer coming from the modem. Okay. Uh what's this doing? Uh actually is about the memory management of K立仿multiprocessor. Uh. So uh very big topic in fact about memory management. So it's a simplified figure. There are two things you need to know. The first thing is the Linux master model. That means the whole system, the memory of the whole system is managed by the Linux kernel. So the peripheral such as Windows, Modern, WLAN or Bluetooth are the peripheral subsystem. The memory is all management by the Linux kernel. And the Linux kernel will use the SMMAU to protect the memory. For example, if the Modern owns this memory, every time and other peripheral such as Windows visit this DRAM, the SMMAU will check the permission and find out that the Windows data has this permission and then the whole system is done. So this is the two things you remember is the Linux master model and SMMAU to protect the memory. So the problem is here. In fact, this is a mystery logic. Generally, Linux will decide the address and the size to assign to other peripheral subsystems. But here you can see the address and the size are determined by the Modern. We don't know why. But if the Modern sends out the address to Linux, then Linux will use this address directly. And if the Modern sends out the address to Linux, then it will use the size directly. So if we set the address to the code address of Linux, so the address will be mapped into Modern. And then Modern can modify the code address of the Linux kernel. And that is the issue. Okay. So now we are actually in the Linux kernel. So we are going to talk about how to set the code address to the code address of the Linux kernel. So we are going to talk about how to send out the payload. Actually before we are using the SCAPI and Wi-Fi dangle. But it's not very stable. So finally we are using a pixel tool to send out the payload and using pixel tool to attack the pixel tool xl. So you can see the pixel tool send out Wi-Fi payload and then pixel tool xl will receive the payload and binnet compromise. Okay. So this is a very interesting thing. So we are using a pixel tool to send out the payload and this is the whole road map. We are using to send out this and finally from more than into the link kernel. Okay. Into WLAN into more than into link kernel. Okay. Uh, let's use some uh, the demo is here. Uh, can you see? Okay. Uh, this is on the left is the pixel pixel two. Uh, it is it is send sending out a uh, package. Send out a payload to attack the the left is the pixel two XL. Okay. You can see it is a version of the system. Okay. So the whole process needs about three minutes. Can see? Uh, now we are we are in the shell and the this kernel uh, SELinux is enforcing. So we have no permission and to do the uh, dangerous things such as de-messaging. Okay. So it is still sending out the payload and uh, let's let's speed up. Speed up. Speed up. So the SELinux is still enforcing you know. Enforcing. So the pixel two is still sending out the payload. Okay. It's uh, it's about three minutes. Okay. Okay. It's fully done. Okay. Can see? I wait for about one minute. Okay. So it's still sending out the payload. Okay. And you can see finally we have get into the Linux kernel and uh, disable the SELinux. So uh, now okay. You can read the de-message. So actually we are running arbitrary code in the Linux kernel from the remote WLM. Okay. Uh, uh. Uh, thank you. Uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh. Uh. So time you up and uh, um to a note that these issues have already been fixed uh in the whilst operating and the pack. Uh, and you can see the detail information here. And today we walk about how to remotely into, into the kernel from the OTA package uh into WLM and the more than the full, full chain and the vulnerability and the exploitations and the subsystem. So, thanks very much for your time. Thanks very much. Okay.