hello everyone welcome to our talk in this also zero days can hackers launch zero the rc attack on popular software only with chromium and this in this talk i will introduce how we use chromium and this pop-up operators in many popular software hoping to draw attention to browser security and application software this is our first defcon presentation let's introduce ourselves self first we are all security researchers at tyson security xuan lab i'm bohan liu made engaged in browser security i'm also a google chrome bug hunter and zhong wang is our co-speaker he made engaged in browser security and kernel security he found several bugs in apple safari linux kernel and virtualbox another cost speaker is going truly he is co-founder and the former captain of recapping ctft he previously worked on all kinds of software but this time he will focus on system and software security currently focus on rlm with security this there are six sections in this talk let's begin first is introduction as a browser security researcher i researched chromium bugs for avail and wrote many ending exploits and i can do a little reversing but i know little about web security give those skills as i said i just lost my main focus i'd like to show you a few of what's the most important Can I find zero DRC bugs in public software? And if so, what can I do to make this work easier? Now, let's take a look at how Chromium has been integrated into public software. Firstly, there is Chromium-based development, which includes default mobile browsers. Second, there are browser components for various programming languages. For example, the Electron framework is primarily used for software development in Node.js for C++, Java, and Dolphin languages. CEF is also a commonly used library. Additionally, the Qt Web Engine plugin is commonly used in Qt, and Chromium may also be present in other browsers. In addition, there are other popular subline chains. So, Chromium is everywhere in software. Based on data from CVE and Google Project Zero, Chrome may be found around 300 vulnerabilities with CVE ID each year. Of those, around 10 vulnerabilities each year are from in-the-wild attacks, and also many of those vulnerabilities can be transferred into RenderRC through detailed analysis. These vulnerabilities can also be introduced into popular software through the subline chain mentioned above. Google has an open attitude towards vulnerability disclosure, and the bug detail will be made public after being fixed for 40 weeks. With the bug detail and unit tests in patch, attackers can quickly make exploited code. Sometimes it's even a zero-debug for the stable version of Chrome itself. We strongly oppose the disclosure of vulnerability details before they are fixed. But it's hard to see. Hackers have a lot of priori knowledge for Chromium-based software attacks. Therefore, we conducted experiments on some popular software to see how long the introduction of those vulnerabilities can have an impact. Let's start with the definition of RCE window period. RCE window period equals the time the vulnerability was fixed in the software, minus the time the vulnerability was exploitable. Since it's hard to precisely determine the T exploitable, we used a new calculation method to roughly describe a software's RCE window period. The method is called RCE window period. RCE window period is called update gap, which is the time difference between the software's update time and its Chromium component update time. The larger the difference, the higher the likelihood of the software being exploitable during the period. In our experiment, we selected some popular software on the market, including Slack, Skype, Discord, and others. The experiment was divided into three steps. In the first step, we downloaded the software's old version through mirror state. The second step was to identify the browser component in the software, the version, and the release dates. In the sixth step, we calculated the update gap to describe the software's RCE window period. We used our database, which concludes over 200 POCs, to assess in testing. Those POCs were used to search for high-risk exploitable vulnerabilities during the period. The final results varied greatly, with different software having an update gap ranging from 9 to 800 days. Wavebox's Chromium component was relatively independent, and updated more frequently. On the other hand, Dropbox hardly updated its Chromium component. The rest of the software mainly used Electron or Libcf components, which most update periods over 90 days. Some software has a longer update period. Discord has an average update time of 305 days. The shortest update period is over 70 days. As a result, 90 versions has a long RCE period, which was demonstrated at Black Hat USA in 2022. Other software, such as Slack, has more frequent updates, with a packed period of 30 days. However, when it hit a zero-day disclosure, they didn't deal with it. For example, the Chromium zero-day bug was publicly disclosed on GitHub on April 2021, and Slack just released its new version the day before that day. However, it wasn't until June that the bug was patched. It has an RCE window period of almost two months. After analyzing updates, we have come to several conclusions. First, RCE window periods exist in most software, leaving attackers periods to find the ending bugs for the exploit. Second, software built on the Electron framework tend to have a shorter RCE window period due to the lower code company, which makes updates easier to implement. Finally, we have observed that many companies have increased their updates at specific times. However, even with those effects, RCE window periods still exist. Let's come to attack surface and vulnerability discovery. For desktop software, developers use browser components to display specific pages and trigger certain client-side behavior in specific scenarios, making client-side users more convenient and universal. However, for hackers, during the RCE window period, it's easy to launch 0-day RCE attacks when they can control the loaded page. This kind of attack has many advantages for hackers, such as having many exploits with end-day vulnerabilities and no domain-specific requirements. Therefore, all hackers need to fend is a situation where they can control the loading page. So, what are the scenarios that developers tend to overlook? The questions arise. What is the function of browser components? What code runs in the browser component? Let's start with how they are developed. For Electron, all codes are developed by Node.js. It is divided into main process and render process, commuted through IPC. All codes are stored in a resource folder, and there are less modifications to Electron framework code. So, it's easy to locate the source code. If compromised, we can also recover them from the ASAR format. As for debugging, since there are less modifications to Electron framework code, most of the time, we can just use command flags to open its internal development tools, like ESPCT or remote debugging ports, just like this flag. Debugtron is a universal Electron framework debugging tool. We can see here. It is also compiled in this method. CEF is another popular component. Here we use libcef C++ library as an example. From the perspective of development, the code impacted by developers is divided into two parts. The privileged API function impacted by C or C++ is used to impact client behaviors that can't be impacted by browser components. The other part is the local resource code impacted by the HTML, which is the code running in the browser component and used it to display the interface. In the development logic, it initialized first, and then registered passing and processing logic of the privileged domain, and then registered the privileged API function to form a JS object for the local resource code to call. And finally, the local resource from the perspective of the CEF library is actually a series of calls to exploit the function. For CEF, its features are it exists in the form of dynamic link library, and the use of CEF is more flexible and more checked before use. A privileged API is implied by C or C++, and the local resource code is implied by HTML. And the location of the local resource file is uncertain, and the file may be encrypted. So, are there any common debugging methods? Yes, you can hook the API in libcf and then get and modify what we want. For example, the developer will use cfstreamreader.create for file, cfzipreader.create or other functions to load the resource. We can get a field location, and decrypted password via hooking the info transfer between API functions, as shown here. As for debugging, although developers call CEF initialized with static conf parameters, we can still dynamically modify the remote debugging port. A parameter to gen develops capabilities by hook, and we can also build more powerful debug tools based on development mode. Let's take a look at some cases that developers can overlook. First is a whitelist of loaded load. Developers are only allowed to use the browser components to open specific pages, such as the official homepage. Other pages will be opened by default system browser, maybe completed by shell-execute-open. For example, scap has the same logic here. The first way to bypass check is the page redirection. Here are three main ways. Type link navigation, 30X reduction, JavaScript navigation. Its principle is that this kind of check is when handling click, and then the page was loaded in Chromium component. And the subsequent jump in Chromium will no longer trick the check logic again. So SSO is a good pass tool, as shown in the figure on the right. The following is a demo that uses page redirection to imply RCE attack. It's an ARM software. For security region, all the software mentioned in this topic will not disclose the product information. Okay, after click, a calculator is here. Another point is check itself. Like an incorrect regular expression or an incorrect triple tag. This is another real-world case. The checker uses a long regular expression. They ask check GPT. And around here, it told me that there are many domains easily redressed by hackers can pass the check. For example, abcdjd.hk. Okay, this is the demo mentioned before. It's also an ARM software. After passing the check, URL check, we can easily load our HTML code. We can easily pop up the calculator. In addition, another point is the special URL handler. There are two main aspects. One is the scheme registered in the system. And the other is the custom domain registered in the browser component. This is their provided domain. It's easy to miss some check while operating in them. The follow is the demo using this method. We can see that ARM software is a vulnerable area in this development case. Okay. The next is a paid code injection. It's a classic top. But let's focus on the unique aspects of XSS in Chromium-based software. Here are three key differences. Firstly, XSS type. In web security, XSS typically includes reflective stored and DOM-based XSS. In Chromium-based software, resources are often stored locally. So XSS in this context is typically DOM-based. Secondly, this vulnerability discovery method in web security, the code that handle a user input is typically located on the server side. So the bug is discovered mainly through black-box testing. However, with the code location tools we previously developed, we can white-box code review in Chromium-based software. Thirdly, input source. In web security, input usually comes from URL parameters or the database. In Chromium-based software, there may be fewer URL parameters but more unique input sources which we will discuss in the next section. Based on those features, as a researcher who knows little about web security, I mainly use the following methods to discover XSS in local resources. Firstly, I use the tools we developed to decrypt local resources. Then, I identify the unprotected resources fields result CSP and filter out input point that can be controlled. Finally, I trace whether this input can trigger code injection. This image is a real-world case I found. I have abstracted the key code and you can see that the get-url-param function process the parameters in the URL and put them into the page using inner-HTML in two. Finally, leading to XSS. Another thing to note is that XSS vulnerability can also be inducted through the subline chain. For example, the ECU-2959 of TypePro. Attackers can execute the JS code in TypePro by exploring XSS vulnerability in the mermaid library and then use the provided API to achieve RCE. We can also use the Chrome NDAB vulnerabilities from two years ago, to do the same thing as the provided API bug. Here is a very simple example of a RCE bug. The RCE bug is a very common bug in the web security because it can be exploited with XSS or specific domain need. We also found a RCE bug in a popular note-taking software using this trick. We would have liked to release it here as an example, but it's being fixed, so we can't disclose it here. For desktop software, it may face much more complex situations than a website, such as no network or speed requirements. This requires some local cache to solve this problem. When reading or writing this logic, the developers usually trust the cache and don't check it again when updating or loading it. Cache data can exist locally in various forms, such as database JSON or custom format. So, if you want Cache Data store Cache Data, you can see that when the database content is modified, there are no valid data checks on the data when it's loaded, allowing any FRIM to be inserted. Here is another interesting example. In a certain application, I found that when three-party components were added, the app inserted an FRIM here into the page. But the SRC attribute is strictly displayed here. But in the local cache, I found a custom property called HF. I modified it to access code and reopen the program. The page is which means that we bypassed the check by modifying the local cache. When I assessed the web version of this app, I found that the web page also changes to the local Therefore, by using the code injection, we bypassed the validation and achieved RCE. And further, we polluted the server, which can lead to more remote attacks. Okay. Some applications also allow developers to use more convenient extension functions. Software gives developers more functionality, but plugins usually need to be officially reviewed before putting on the store. With the browser components, hackers may use it to bypass plugin reviews. For example, when a plugin is reviewed, the page in the plugin is a normal page. But when it is put on the market, the website is redirected to a page with expired code, thereby realizing a water hole attack. The following is an example of IntelliG IDEA software. The Medicare plugin is loaded, and attackers can use the browser component to achieve RCE. So, when a plugin is reviewed, it is necessary to pay attention to the URL in it. Now, in the video, we load the plugin. Okay. Some functions may have arbitrary page processing process, such as the preventing of crawlers or nodes. For example, the was found a RCE bug in a passive scanning function in 2021. Now, our co- speaker will give you I will finish the last part. Given the short duration of RCE window period, it is crucial to develop its voice quickly. When it comes to type vulnerabilities, a common technique is to use optimized functions to create inconsistencies that ultimately lead to type confusion. However, for use number three bugs, there doesn't seem to be a publicly universal exploit method. Here, we propose a solution Let's start by discussing some relevant background knowledge. We know garbage collection recycles objects from the young generation, which divides memory and copies them from the from space to the to space, updating object pointers. Then, the from space and to space are swapped, and the next round of garbage collection is performed. During scavenging, there is also an additional set of root objects, which are pointers from old space to new space objects, where it uses red barriers to track these references. When the garbage collection identifies relevant references in the old space, it does not reclaim the objects in the new space. Here is a Chrome issue 101307610. This was caused by a missing red barrier when generating the last index object for a red expression object. When last index acts the SMI range and the red expression is in the red space, reclaimable due to the lack of reference information, resulting in a use of free vulnerability. In V8, there is a type of string called 1-byte internalized string. Its memory layout is as follows. From front to back, there are the object's map, hash, string length and the string's content. The core idea we used was to forge a string with an extremely large length and place the target object after the string in memory. Then, we can use the search method of the string to find the address of the target object after the mark. Thus, we can construct the address of primitive. Using the same technique, we can place a JS array after the fixed string. By using the string's auto-bound spread, we can modify the elements member of the JS array to point to arbitrary address and achieve arbitrary memory read and write. To fix such a string, we need to create a fixed string map. We used this map large number of array buffer objects to obtain a stable address and then forge the necessary members of the string map at this address. Finally, we place the fixed string in a JS array and allocate a large number of JS array objects on the right. Here is a demonstration video of our successful exploration in Chrome version 91. So, as for Chromium-based software, we found firstly, a bug or feature can lead to RCE attack. Secondly, there is a leak of attention to the attacked path of browser vulnerabilities now. So, the attack surface is relatively rudimentary and hackers also can bypass mitigation directly using powerful Chromium bugs. This section is about how to achieve RCE attack without sandbox escape bug. The sandbox is a security protection mechanism of Chromium. Even if a hacker gets the random RCE, he still cannot get the full execution permission. This includes mandatory access-controlled environment, isolated process when HTML rendering and JavaScript execution. And finally, the limited resource access and limited IPC or Chromium interaction access. The end day of sandbox escape is much less than the end day of enable software without a Chromium sandbox escape bug. First, let's see what's the difference between Chrome build's Chromium based software and Chrome browser. The one is privileged API. It's very easy to access in It's quite easy to access the object that you want use. It's a very easy way to access a code, we can execute the implemented handler in the browser process through IPC call. Based on this idea, there are usually two implementation logic for the privileged API. The first one checks the URL loaded by the browser component when it is initialized. If it is a specific domain, register the privileged API in the loaded context. At runtime, only the privileged domain can obtain the JavaScript object. So when we call in some function from this API, the browser process calls it without checking the source domain. The second logic is to register the privileged API object no matter what domain it is at. And then the developer can check the domain when the privileged API is called. There are some problems with both methods. For the first one, whatever non-privileged webview gets a privileged context. For the second one, how to properly check the IPC access is from privileged domain. The research shows that, in August 2018, Maestro shared research on context isolation, which is used to isolate the context between the renderer process and preload. If this configuration is disabled, even with sandbox protection enabled, the renderer process can also call privileged functions exported from preload, such as shell.open external function. At Black Hat Asia in 2019, Luca shared his research on preload. He discovered that, even with sandbox protection enabled, preload.js may still access certain native node classes and some elastron modules. Attackers can use prototype solution to execute arbitrary IPC calls. At Black Hat USA in 2022, a sandbox bypass method was demonstrated when the renderer process could load the preload.js file in a child file frame by overwriting the node integration in subframe member. We can also overwrite the preload context isolation and disable CISO in new renderer process. Then we can send an unauthorized IPC call with prototype solution. We also found some interesting and wide-ranging issues with the second model. But since the renderers are working on a fix, we will share the details when it's fixed. We will make some security recommendations for Chromium-based software in two aspects. Firstly, it is necessary to update the latest version of the Chromium. Secondly, for software with high coupling, it's better to use a stable development version. And introduce security patches with software updates. Thirdly, we should enable the Chromium sandbox. And last, we need to disable unused software functional realities or enable internal mitigations. For developers, we can add backend validation and front-end rendering validation. Follow the principle of latest privilege. Both privileged domain, range, and privileged API function. Enable universal mitigation such as CSP and be vigilant about input from unexpected sources. Here is the conclusion and takeaways of this topic. In this topic, we verify that a large number of Chromium-based software have RCE window period. And then, we summarize some software attack surfaces that cooperate with the RCE window period, which makes the hackers can launch zero-day attack with Chromium-n days and give real-world examples. And we share a general way it's used after free exploit method in 32-bit, which may help make exploit faster. At last, we provide some security recommendations to help strengthen the security of Chromium-based software. At last, thanks to all the partners for their contribution to this topic. Here is the list. Okay, thanks for your listening. Here is the references of this topic. If you have any problem, you can contact us with email or on Twitter.