1 00:00:00,000 --> 00:00:01,880 We'll go ahead and get started. 2 00:00:01,880 --> 00:00:08,500 We'll have Zhengyu Liu and Jingyue Yu present on the Domino Effect. 3 00:00:09,380 --> 00:00:11,520 Let's clap it up for them. 4 00:00:22,230 --> 00:00:23,830 Hello, everyone. 5 00:00:29,280 --> 00:00:31,240 Should we get started? 6 00:00:31,680 --> 00:00:33,200 Okay. 7 00:00:33,280 --> 00:00:35,000 So, hello, everyone. 8 00:00:35,000 --> 00:00:43,160 Welcome to our talk, the Domino Effect automated detection and exploitation of cloud vulnerability at scale. 9 00:00:43,160 --> 00:00:51,240 So, I'm Zhengyu Liu, and this is my collaborator, Jingyue Yu, and this is our joint work with Tao Li, Zifeng Kang, and my advisor, Yingzhi Cao. 10 00:00:51,960 --> 00:00:57,860 And we're both PhD students from Johns Hopkins University, focused on web security and software security. 11 00:00:57,860 --> 00:01:07,380 And we spend our most of time studying vulnerabilities, building security testing tools, and thinking about how to make the modern world a better place. 12 00:01:08,600 --> 00:01:13,300 And today, we're excited to share our research on dump clobbering. 13 00:01:13,300 --> 00:01:22,140 So, I will first start a very quick overview of what dump clobbering is, and then explain the challenges of detecting those vulnerabilities at scale. 14 00:01:22,140 --> 00:01:26,100 And introduce our automated analysis framework, HAWQ. 15 00:01:26,100 --> 00:01:41,700 And after that, Zhengyu will take over to present our large-scale zero-day hunting results and show how we turn those HTML injection into the end-to-end exploits with dump clobbering gadgets we find. 16 00:01:43,260 --> 00:01:45,020 So, let's begin. 17 00:01:45,940 --> 00:01:52,700 So, dump clobbering originates from an old but still standard browser feature defined in the HTML specification. 18 00:01:52,740 --> 00:01:58,500 And it allows you to perform named lookups on window or document objects to access elements on a page. 19 00:01:58,500 --> 00:02:04,360 Well, this feature provides a convenient way to reference dump elements by their ID or name. 20 00:02:04,680 --> 00:02:14,780 It often opens the door to the dump clobbering attack in the scenario where those elements are attacker-controlled, and it's more than the developer's intention to use them at all. 21 00:02:15,220 --> 00:02:28,220 By crafting a name collision between the dump element's ID or name attributes and a property accessed via the window or document, the attacker could pollute the JavaScript value and change the application logic. 22 00:02:29,400 --> 00:02:40,920 So, and especially modern web applications often accept a wide range of user inputs, including like script-less raw HTML to support things like rich text formatting or like embed media. 23 00:02:41,380 --> 00:02:54,000 For a more concrete example, to give an illustration for people not very familiar with this, is that at first the attacker needs to inject a link or element to the page. 24 00:02:54,380 --> 00:03:01,020 And then the page contains JavaScript that probably reads from like window.remote to load additional scripts. 25 00:03:01,020 --> 00:03:06,760 And if it's undefined, it fallbacks to use like a city and URL and load script from there. 26 00:03:07,340 --> 00:03:14,740 However, with the attacker inject link whose ID equals to the remote, the lookup is no longer undefined. 27 00:03:14,740 --> 00:03:17,900 And instead, it refers to the injected A-link. 28 00:03:18,100 --> 00:03:20,420 And this is what we call a clobber. 29 00:03:21,200 --> 00:03:26,400 And later, like when the dump element is concatenated with the string, type cohesion occurs. 30 00:03:26,400 --> 00:03:36,240 And for those link elements, this converts them from a dump element to their ref value and producing a URL controlled by the attacker. 31 00:03:36,760 --> 00:03:43,480 And finally, the URL flows to the script.source and loading malicious code from attacker's domain. 32 00:03:44,940 --> 00:03:55,100 Since dump clobbering was first introduced by Grace Hess in 2013, a lot of work has been working towards understanding various clobbering techniques. 33 00:03:55,100 --> 00:04:06,240 And as a core, the key question is, which HTML markups can clobber which JavaScript targets and probably enter which browser implementations? 34 00:04:06,380 --> 00:04:14,600 Because the clobbering behaviors is defined in the HTML specification, but the browser implementation varies slightly. 35 00:04:15,840 --> 00:04:29,340 And building on years of the findings and also the updates from the browser, the recent paper from Oakland 2003 called Clobbering Time is the first to systematically answer this question. 36 00:04:29,340 --> 00:04:40,960 It uncovered over 30,000 clobbering-capable HTML markups across five distinct techniques, making a real significant forward in this field. 37 00:04:41,880 --> 00:04:48,200 However, identifying those clobbering behaviors is just the initial payload landing step of the attack. 38 00:04:48,420 --> 00:04:53,480 And for the full exploitation, we still need the gadgets and the exploits. 39 00:04:53,540 --> 00:05:05,920 So the following question is, can we automatically detect those gadgets and generate working exploits so that we can really test them at scale and better understand its landscape in our modern web? 40 00:05:05,920 --> 00:05:08,820 And this is where our work comes in. 41 00:05:09,320 --> 00:05:12,180 So to do that, there are two main challenges. 42 00:05:12,260 --> 00:05:21,240 The first one is that real-world JavaScript, especially after minified or bundled, is full of dynamic behaviors, like aliasing or directed property lookups. 43 00:05:21,240 --> 00:05:24,980 And it's very unfriendly to our static analysis tools. 44 00:05:24,980 --> 00:05:34,300 And those features make it extremely hard to track how data flows through an application, and in turn makes the gadgets a very hard problem. 45 00:05:34,700 --> 00:05:36,860 The second challenge is exploit generation. 46 00:05:37,280 --> 00:05:42,120 In DOM clobbering, the payload is no longer a string, which is usually the case. 47 00:05:42,120 --> 00:05:43,620 But it's a DOM element. 48 00:05:43,620 --> 00:05:52,480 And that element needs to be compatible with the JavaScript operations in the gadgets and carry the attacker-controlled values to the sensitive syncs. 49 00:05:52,480 --> 00:06:01,400 And if the element itself is malformed or is not incompatible with the gadgets, it may break the code or just fail to propagate the payload. 50 00:06:02,580 --> 00:06:11,620 Okay, now let's take a look at a motivating example and show how those challenges failed our existing approaches. 51 00:06:11,880 --> 00:06:19,260 This is a zero-day cross-site scripting caused by DOM clobbering found by Hawk in my favorite Red Hat platform, HackMD. 52 00:06:19,520 --> 00:06:28,920 The HTML injection was possible because the developer allowed the name attributes on the tag and exposing its application to the DOM clobbering. 53 00:06:29,560 --> 00:06:38,840 To escalate the HTML injection to cross-site scripting, Hawk found vulnerable gadgets from the Google client API library used in the page. 54 00:06:38,840 --> 00:06:46,820 And the Google client library is used by a website that tries to integrate the Google service, like Google Drive, Google Maps, or YouTube. 55 00:06:46,820 --> 00:07:00,140 And once the library is loaded on the page, it will precise the developer-defined configurations in the page and callbacks in and by searching the corresponding script tag that contains the configuration URL. 56 00:07:00,140 --> 00:07:11,740 And then we'll use a new function, which you can dynamically generate a function, like a generated JavaScript code, by parsing those configuration objects and execute its code. 57 00:07:12,600 --> 00:07:19,160 But here's the problem, that the source it uses, document.script, is vulnerable to DOM clobbering. 58 00:07:19,160 --> 00:07:29,580 So the attacker can inject a clobbered DOM element that is not a script, like an f-frame with a crafted name equals to the script, to hijack the configuration object. 59 00:07:29,820 --> 00:07:44,760 And combining the HTML injection and the DOM clobbering gadgets in the page, the attacker could achieve cross-scripting by sharing a malicious HackMD node and probably perform any unsorted actions on behalf of the user. 60 00:07:45,560 --> 00:07:52,740 And do you know, like, both the HTML injection and DOM clobbering gadgets have been fixed by the HackMD and the Google, respectively. 61 00:07:53,840 --> 00:07:56,520 And let's talk about the private work. 62 00:07:56,660 --> 00:08:02,080 Like, this thing is a static NS2 that tries to detect this by looking at the source code. 63 00:08:02,080 --> 00:08:08,580 But it fails to detect it because of the dynamic behavior and condition logic embedded in the gadget code. 64 00:08:09,220 --> 00:08:17,620 Secondly, exploiting the gadgets requires HTML that satisfy both the data flow and control flow constraints along the chain. 65 00:08:17,620 --> 00:08:24,040 The data flow constraints ensure that payloads can flow from one attacker-controlled variables to another. 66 00:08:24,040 --> 00:08:31,660 While the control flow constraints ensures that the program state, like, SQ the gadget's logic. 67 00:08:31,660 --> 00:08:35,780 So we don't, like, SQ it earlier. 68 00:08:35,920 --> 00:08:41,200 For example, involves a subscript operation of the value. 69 00:08:41,200 --> 00:08:46,040 So this means our objects must behave like a collection , such as collections. 70 00:08:46,420 --> 00:08:53,380 If it's just a single element, the access on it will throw a runtime error and the gadget will just fail to execute. 71 00:08:54,400 --> 00:09:03,520 And the thing fails to generate a working exploit because it only considers the initial pattern, but ignores all the constraints in the gadget code. 72 00:09:03,520 --> 00:09:10,240 And as a result, it produces payloads like image name equals to script that will never reach the sink. 73 00:09:10,600 --> 00:09:19,620 Another popular client-side testing, too, failed to detect it because it relies on a canary-based testing. 74 00:09:19,620 --> 00:09:29,640 While this approach works very well for stream-based exploits by checking whether partial attacker-controlled values reach the sink, it does not apply to dump clobbering. 75 00:09:30,520 --> 00:09:38,080 Because dump clobbering requires a near-correct HTML element and considering all the constraints from the gadgets. 76 00:09:38,080 --> 00:09:42,320 And it randomly generates HTML that will just never reach the sink. 77 00:09:42,500 --> 00:09:49,260 Or even worse, it will just break the website's functionality and skip executing many real gadgets. 78 00:09:50,220 --> 00:09:50,820 Okay. 79 00:09:51,320 --> 00:09:54,600 Now let's see how we solve the problem with HAWQ. 80 00:09:55,500 --> 00:09:58,300 HAWQ operates in three stages. 81 00:09:58,300 --> 00:10:10,800 So our key insight here is that instead of directly injecting HTML marks from the start, we first perform the tint tracking on website-defined values from those potential clobberable source to the sink. 82 00:10:10,800 --> 00:10:19,120 And this phase is non-intrusive and helps us identify a wide range of potential gadgets without needing to guess the payload. 83 00:10:19,220 --> 00:10:26,700 And next, based on the tint trace, we extract the data flow and control flow constraint and use them to generate the corresponding exploit markups. 84 00:10:26,760 --> 00:10:38,960 Finally, we insert those crafted markups to the page and replay the execution and check whether the payloads reach the sink, confirming whether the gadget is really exploitable or not. 85 00:10:42,090 --> 00:10:47,710 Specifically, in the first stage, HAWQ performs dynamic tint analysis on website-defined values. 86 00:10:47,710 --> 00:10:49,950 We categorize the source into two tabs. 87 00:10:49,950 --> 00:10:56,970 First, the lookups on document can be directly shadowed by the attacker-injected values, like documented links, documented strings. 88 00:10:57,010 --> 00:11:02,530 And in this case, we can directly tint the original values and observe how they propagate in the program. 89 00:11:02,670 --> 00:11:10,630 And second, there are lookups on, like, window objects where the attacker clobber value is only used if the original value is undefined. 90 00:11:10,630 --> 00:11:17,630 And this typically appears in, like, those fallback expressions, like tannery operators or, like, logic or checks. 91 00:11:17,630 --> 00:11:26,930 And in such case, HAWQ will track those fallback values instead and identify opportunities where the attacker-controlled value might take effect. 92 00:11:27,310 --> 00:11:36,850 And HAWQ will only inject its own value, like random value, when there is no website-defined value is present as a fallback. 93 00:11:37,690 --> 00:11:45,130 The sink used in our tint tracking are typical, like, client-side sinks, like in VAL, SETs, Temout, and others. 94 00:11:45,770 --> 00:11:48,910 The tinted value in the page are managed in two ways. 95 00:11:48,910 --> 00:11:58,510 For objects with properties, we just insert another, like, specific field, a non-enumerable property, so that it doesn't interfere with the normal behavior. 96 00:11:58,890 --> 00:12:09,110 For those primitive values, which are very hard to be tinted, we wrap them with a special object that holds both a concrete value and its tint metadata. 97 00:12:09,110 --> 00:12:12,770 So, this allows us to track even undefined values. 98 00:12:13,690 --> 00:12:22,070 Our tint engine supports propagation across JavaScript operations, JavaScript built-ins, and browser-native APIs, and so on. 99 00:12:22,550 --> 00:12:31,750 And the tint propagation rules are implemented in a very extensible way, like adding support of new APIs is as simple as defining a single handler function. 100 00:12:32,890 --> 00:12:37,590 And we implement the tint analysis using a code-rewriting approach based on geology. 101 00:12:37,590 --> 00:12:50,970 Instead of instrumenting the browser itself, it gives us a very flexible feature and allows us to track all types of JavaScript values and supports cross-browser analysis without relying on the browser internals. 102 00:12:51,630 --> 00:12:58,350 The output of the first stage would be the tint trace represents in a tint dependency graph. 103 00:12:58,430 --> 00:13:04,630 And the backbone are the operations, and there are concrete values and also the attacker-controlled tinted values. 104 00:13:05,350 --> 00:13:21,530 Next, the challenge would be, once we have this tint dependency graph, how do we generate the HTML markups that can leverage those operations observed in the graph and carry the attacker-controlled strain all the way to the sinks? 105 00:13:21,670 --> 00:13:35,050 And in the second stage, in this stage, we will introduce the concept of a symbolic DOM, which allows us to formally define the constraints that DOM elements must satisfy at each step along the path. 106 00:13:35,050 --> 00:13:44,150 And then we implement a simple DOM constraint solver that uses those representations to automatically generate the compatible and exploit-ready HTML markups. 107 00:13:45,810 --> 00:13:52,430 So, the first step, to model... so, we need to understand what a successful exploit would look like. 108 00:13:52,430 --> 00:14:00,270 So, to model a valid exploit, we treat the HTML payload as flowing through four key stages in the tint dependence graph. 109 00:14:00,270 --> 00:14:06,290 The initial clobbering, where the attacker's DOM elements first inject to the JavaScript program. 110 00:14:06,290 --> 00:14:13,870 The advanced clobbering, where some parts of the first injected DOM elements get loaded to the program. 111 00:14:14,470 --> 00:14:22,090 And the third stage is DOM to strain, where the strain payload loads from the attacker-controlled DOM elements to the page. 112 00:14:22,090 --> 00:14:30,110 And the final stage is strain to strain, where the strain is precise, or transformed and finally flows to the sink. 113 00:14:31,030 --> 00:14:41,310 In the first stage, the DOM elements should contain ID or name attributes correspond to the name, the lookup keys, which is quite straightforward. 114 00:14:41,850 --> 00:14:46,450 On the second stage, the attacker-controlled elements must be further loaded. 115 00:14:46,450 --> 00:14:54,210 And this stage is only necessary when there are additional JavaScript operations before the strain payloads can be loaded. 116 00:14:54,210 --> 00:15:02,730 And since we cannot skip any JavaScript operations in the graph, so we need to use this advanced clobbering techniques to fulfill them. 117 00:15:02,730 --> 00:15:17,750 And the problem would become, if the base object is an attacker-controlled DOM element, how do we format in a way to make the results of the operation could also be attacker-controlled DOM elements and without raising any error? 118 00:15:17,790 --> 00:15:20,110 And there are a few strategies that can be taken. 119 00:15:20,110 --> 00:15:27,830 The first way is HTML injection, that you can inject multiple DOM elements with the same name attributes, and it will look like an array. 120 00:15:28,170 --> 00:15:40,870 The second way is to use the well-known nested window proxy, parent, child, or input form those relationships to clobber lookups, like whose property is a general string. 121 00:15:40,970 --> 00:15:50,130 And the third way targets a certain DOM-specific properties, like previous symboling, and by arranging the DOM elements to match the expected structure. 122 00:15:51,690 --> 00:16:07,070 And later on, when the attacker... there are several rounds of advanced clobbering, and later on the attacker needs to load its string from the controlled DOM elements to the program, because the final payloads shown in the thing should be in a type of string. 123 00:16:07,110 --> 00:16:09,530 And there are three main ways to achieve this. 124 00:16:09,530 --> 00:16:14,830 The first is the well-known techniques through type cohesion during binary operation, like add. 125 00:16:15,010 --> 00:16:18,390 And this applies to the a and area elements. 126 00:16:18,390 --> 00:16:23,210 We are accessing those elements and triggers the use of its ref value as a string. 127 00:16:23,650 --> 00:16:34,590 The catch here is the ref value must be a valid URL, and browser will often auto-fix it with the protocol, like HTTPS, or whatever is used in the current page. 128 00:16:34,590 --> 00:16:43,390 And to bypass this, attacker will need to inject a base tag before the clobbered element, controlling how those relative URLs are resolved. 129 00:16:44,190 --> 00:16:50,490 Another two-stage operations can be leveraged are function calls and get-fued, which is less documented. 130 00:16:50,770 --> 00:16:59,230 For the function calls, some JavaScript built-ins and browser APIs would automatically coerce its argument or property values to a string. 131 00:16:59,530 --> 00:17:08,770 So in that case, if the attacker control value is passed to those and or accessed in this way, the browser would perform the cohesion just like those during the binary operations. 132 00:17:09,450 --> 00:17:13,090 The third way is to exploit the attribute name collision. 133 00:17:13,090 --> 00:17:18,950 Like if a property name matched to a legitimate reflected DOM attribute, it can be abused. 134 00:17:18,950 --> 00:17:33,990 For example, if the application erased the value property from the element, then the attacker could inject an input tag with a payload saved in its value attribute, because it's a valid attribute name. 135 00:17:34,630 --> 00:17:41,650 And our paper includes a comprehensive list of those attributes and APIs that can be used in this stage. 136 00:17:42,530 --> 00:17:48,870 And finally, there would be a result of a string-related transformation and finally flows to the sink. 137 00:17:49,970 --> 00:17:54,850 Okay, so we know what a legitimate DOM element should look like. 138 00:17:54,850 --> 00:18:02,850 To describe those in a formal way so that we can solve them, we need this symbolic DOM syntax. 139 00:18:03,730 --> 00:18:10,450 So it's basically a constraint syntax to describe a set of DOM elements with the same list of features. 140 00:18:10,590 --> 00:18:15,070 And it comes with four primitives, int, boolean, string, node, and collection. 141 00:18:15,350 --> 00:18:20,750 And each node represents a DOM element which can have a tag name and several attributes. 142 00:18:20,850 --> 00:18:24,110 And a node can have siblings and children. 143 00:18:24,110 --> 00:18:29,570 And a valid symbolic DOM that can be concrete to the HTML must have one root node. 144 00:18:30,330 --> 00:18:42,090 And then with each operation type and also the stage we just mentioned, we could generate the constraints on the inputs or outputs elements using the operations. 145 00:18:42,090 --> 00:18:50,230 For example, to achieve document to DOM through the document.p operation, the DOM elements can be described on the page. 146 00:18:50,690 --> 00:18:55,990 Whereas the is root has tag name and has attribute constraints. 147 00:18:56,070 --> 00:19:01,390 And when p equals to the script, so we can concrete to a very simple HTML element. 148 00:19:01,990 --> 00:19:10,510 And with those model constraints, we can traverse all the operations nodes and attach those constraints to the attacker-controlled nodes. 149 00:19:10,510 --> 00:19:22,570 And each attacker-controlled node in the graph should have two conjunctive sets of constraints as they serve as the return value of this operation and arguments of the subsequent operations. 150 00:19:23,430 --> 00:19:26,550 And finally, we need to merge and solve those constraints. 151 00:19:26,630 --> 00:19:33,710 And the key insight here is that the way it starts from small and then connects those and finally concrete to the HTML. 152 00:19:33,890 --> 00:19:34,610 So what does it mean? 153 00:19:34,610 --> 00:19:43,650 It means that first of all, we focus on the local constraints like a C1 and expand it into a disjunctive norm form or DNF form. 154 00:19:43,650 --> 00:19:51,970 And in this form, each local constraint can represent a valid possible DOM trace that satisfies those constraints. 155 00:19:52,070 --> 00:19:58,970 And next, we will merge the formulas across different DNFs if they point to the same tinted nodes. 156 00:19:58,970 --> 00:20:07,270 And during this process, conflicts may rest and we just need to get rid of them and only save the valid combinations. 157 00:20:07,290 --> 00:20:18,130 And you can think of the second stage as attaching different DOM trace at their shared nodes and discard any combination that doesn't fit together. 158 00:20:18,410 --> 00:20:25,850 And in the last step, we will just concrete the formulas to the HTML marks as exploits. 159 00:20:27,650 --> 00:20:39,250 And finally, in the last step, we would just inject our generated payload and replay the web page and see whether our canary value from the exploit could really flow to the sink. 160 00:20:40,030 --> 00:20:45,690 And next, I'm going to hand over to my collaborator and she will show the results. 161 00:20:47,270 --> 00:20:48,390 Hi. 162 00:20:49,770 --> 00:20:50,610 All right. 163 00:20:50,610 --> 00:20:53,150 So let's get to the real exciting part. 164 00:20:53,150 --> 00:21:08,890 Now I'm going to show some real world examples we found with our toolhawk as well as some so those include some DOM clobbering gadgets in the wild in web applications and libraries and also end-to-end exploitations. 165 00:21:09,170 --> 00:21:19,250 So first, we apply our toolhawk to tranquil top 5,000 websites and found 497 zero-day exploitable gadgets. 166 00:21:19,250 --> 00:21:40,610 So there are our cases includes more than web bundlers like webpack, RS pack, white, polyfuse, and some core functional libraries like prism, page find, mess jacks, version 2 and version 3, and also some third-party services including plausible analytics, 167 00:21:40,610 --> 00:21:47,010 Google client, API library, and also web application framers like Astro. 168 00:21:47,010 --> 00:21:48,710 Our data set is public. 169 00:21:48,710 --> 00:21:52,890 You can access the whole data set through this QR code if you are interested. 170 00:21:54,690 --> 00:21:58,550 So the first case I want to show you is the webpack. 171 00:21:58,550 --> 00:22:08,830 So according to an investigation, there are an average of 1.27 webpack bundles per site among the tranquil top 100K websites. 172 00:22:08,830 --> 00:22:17,310 So this vulnerability we found by Hawk can lead to cross-site scripting on websites that uses webpack as the bundler. 173 00:22:17,470 --> 00:22:22,650 So in case you are not familiar, so the pipeline of using webpack is like this. 174 00:22:22,650 --> 00:22:36,090 First you have to feed the website source code to the webpack to generate the production code, which includes a compressed website code and also the webpack runtime code, which is a webpack library code. 175 00:22:36,090 --> 00:22:41,670 And in that webpack runtime code is where we found the dump clobbering gadgets. 176 00:22:41,670 --> 00:22:51,550 So with that dump clobbering gadget, if that website contains an HTML injection, this gadget can cause cross-site scripting. 177 00:22:52,730 --> 00:22:55,810 So let's jump into the code gadget. 178 00:22:56,490 --> 00:23:10,010 So webpack requires the developer to set the public house to be auto or you can either leave it to be empty in hope that the webpack will help you load some external scripts. 179 00:23:10,010 --> 00:23:14,950 But actually it is doing more harm than you think it is doing good. 180 00:23:15,470 --> 00:23:24,850 So if we pay attention to the code itself, in the first box we marked up, so the document or current script can actually be clobbered. 181 00:23:24,850 --> 00:23:31,050 And then in the box 2, the script URL is loaded as the document.script.sauce. 182 00:23:31,050 --> 00:23:47,270 So in this case, if we construct our payload like this with the source equals to HTTPS attacker.control.server, that script URL will be an attacker control URL. 183 00:23:47,270 --> 00:23:58,990 And then later, finally, this script URL is used as the webpack required.p, which will be later load that script from that attacker control domain. 184 00:23:58,990 --> 00:24:03,170 So that will cause arbitrary script loading from the attacker server. 185 00:24:06,260 --> 00:24:09,600 So the second case I want to show is the Astro. 186 00:24:09,600 --> 00:24:17,000 It is a widely adopted client server web framework to help you construct a web application from scratch. 187 00:24:18,280 --> 00:24:28,400 So in this code, we can also find some clobbering gadget where the clobberable element is here, the document.scripts. 188 00:24:28,400 --> 00:24:30,860 But this case is a little bit special. 189 00:24:30,860 --> 00:24:38,260 So if we pay attention how the document.script is used, we can see it is accessed through array.from. 190 00:24:38,260 --> 00:24:46,020 So the code is treating the document.scripts as an array, not just one single HTML element. 191 00:24:46,020 --> 00:24:54,600 So in this case, we have to construct the payload as an HTML collection instead of just single one HTML element. 192 00:24:56,040 --> 00:25:05,060 So and then if we jump into the for loop to see how do we reach the final sync, we can see two conditional checks before we reach the sync. 193 00:25:05,060 --> 00:25:13,680 So the first condition check checks whether the script.dataset.astro.exec is equal to an empty string. 194 00:25:13,680 --> 00:25:23,120 And the second condition checks check the type which is an attribution which is the type attribution of the HTML element we got before. 195 00:25:23,380 --> 00:25:31,320 So to bypass those two condition checks with our payload, the first script.dataset is undefined. 196 00:25:31,320 --> 00:25:36,780 So the first condition will return false which causes the code to continue execution. 197 00:25:36,800 --> 00:25:43,780 And then when we reach the second condition, the type again in our payload, the type attribution does not exist. 198 00:25:43,780 --> 00:25:47,740 So the second condition will also return false. 199 00:25:47,960 --> 00:25:58,980 That will finally lead us to the final sync where the new script is loaded from new script is created as a new element with a script type. 200 00:25:58,980 --> 00:26:04,220 And it's innerHTML is copied from the payloads in innerHTML. 201 00:26:04,220 --> 00:26:12,620 So finally we can achieve arbitrary code execution if we construct our payload as this HTML collection. 202 00:26:13,360 --> 00:26:16,700 So in our case, the innerHTML will be alert 1. 203 00:26:17,560 --> 00:26:20,200 That caused the process drifting. 204 00:26:20,200 --> 00:26:25,160 And then the final case study I want to show you is the UM editor. 205 00:26:25,160 --> 00:26:28,780 It's an editor previously maintained by Baidu. 206 00:26:28,780 --> 00:26:33,580 So in this code, it's a little bit straightforward. 207 00:26:33,580 --> 00:26:48,940 So if we see ‑‑ we can see the clobberable element is the window.UM editor underscore home underscore URL which in our case will be the HTTP attacker.control.com. 208 00:26:48,940 --> 00:26:55,180 And then later that variable URL is used to be assigned to a global variable. 209 00:26:55,180 --> 00:26:58,240 UM editor underscore config. 210 00:26:58,240 --> 00:27:08,420 And then later that variable is concatenated with some constant strings to construct the final URL that will be ‑‑ that the code will be loading the script from. 211 00:27:08,420 --> 00:27:13,780 It is also causing the scripts being loaded from the attacker's domain. 212 00:27:16,330 --> 00:27:21,310 So finally I want to talk about the end‑to‑end exploitation. 213 00:27:21,310 --> 00:27:27,390 So to understand the end‑to‑end exploitation, we first need to achieve HTML injection. 214 00:27:27,390 --> 00:27:35,070 So as mentioned before, the web application they accept and process all sorts of user inputs. 215 00:27:35,070 --> 00:27:37,590 But how does it become unsafe? 216 00:27:37,590 --> 00:27:40,650 So we have some basic findings. 217 00:27:40,650 --> 00:27:48,830 So first, some sanitizers from these websites, they do not strip the ID or name attribution by default. 218 00:27:48,850 --> 00:27:59,590 And the web applications, they are not aware of this vulnerability and they rely on those ID or name attributes for intended logic. 219 00:27:59,590 --> 00:28:10,390 So due to these reasons, the ID or name attribute, they sometimes slip through the white lists as they don't seem harmful at all. 220 00:28:11,730 --> 00:28:22,490 So based on how these web applications process the user inputs, we categorize the input factors of HTML injection into two types. 221 00:28:22,490 --> 00:28:26,590 The first is by user typing and the application rendering. 222 00:28:26,590 --> 00:28:33,650 The second is by the user copy and paste HTML elements into the page directly. 223 00:28:34,010 --> 00:28:37,010 So the first case is easy to understand. 224 00:28:37,010 --> 00:28:51,330 The attacker might input some raw HTML strings such as the image tag with source equals to X and on error equals to alert 1 into some user controllable fields. 225 00:28:51,330 --> 00:28:58,930 And then those strings are later parsed and rendered by the web application without proper sanitization. 226 00:29:00,290 --> 00:29:08,570 So the second input factor is to insert through copy and paste HTML elements into the page directly. 227 00:29:08,570 --> 00:29:11,250 This is based on several factors. 228 00:29:11,250 --> 00:29:19,530 The first is that the elements whose content editable attributes is enabled, they can accept HTML elements directly. 229 00:29:19,530 --> 00:29:27,170 And second is that the clipboard data can have text or HTML MIME type, not just plain text. 230 00:29:27,170 --> 00:29:35,350 And also the browser clipboard APIs, they will sanitize cross-site scripts but they do not sanitize ID or name attributes. 231 00:29:35,350 --> 00:29:40,610 As mentioned before, they don't look harmful at all at most of the cases. 232 00:29:41,450 --> 00:29:52,670 So based on these factors, what if the website just saved these HTML elements input from the user or attacker without proper sanitization? 233 00:29:52,670 --> 00:29:55,690 That will cause the stored HTML injection. 234 00:29:56,770 --> 00:30:00,130 I will show you with one real world example we found. 235 00:30:00,130 --> 00:30:05,330 So this is the Canvas LMS discussion at JHU in our school. 236 00:30:05,330 --> 00:30:15,890 So in the discussion board, in the input box, if you just directly input some raw HTML text into the input box, they will be sanitized. 237 00:30:15,890 --> 00:30:26,450 But if you directly copy and paste HTML elements into the input box, the website will actually accept those elements and render those elements in the website. 238 00:30:26,450 --> 00:30:28,850 That will cause the HTML injection. 239 00:30:29,030 --> 00:30:34,030 This is usually caused by the web application developers. 240 00:30:34,030 --> 00:30:43,370 They are mostly cautious about user inputs by typing but sometimes they are just careless about the contents from the clipboard. 241 00:30:43,370 --> 00:30:47,130 That's why it's causing HTML injection in this case. 242 00:30:48,070 --> 00:30:56,550 So we also manually hunted for HTML injection in the world in real world applications. 243 00:30:56,550 --> 00:31:11,390 So we manually discovered 187 HTML injection vulnerabilities in various web applications including wiki, web mail, forum, editors, RSS, social media, chat bot, and so on. 244 00:31:11,390 --> 00:31:18,530 So and we also summarized 12 editors and client-side libraries that are vulnerable to HTML injection. 245 00:31:18,530 --> 00:31:21,830 They can also be accessed in our public data set. 246 00:31:23,310 --> 00:31:40,030 And then in terms of end to end exploitation, with all the DOM clobbering gadgets we found by HAWQ and also the HTML injection vulnerabilities we found manually, we can achieve 12 end to end exploitation with our with those gadgets and HTML injection. 247 00:31:40,030 --> 00:31:47,990 So in those includes 11 of them leading to cross-site scripting and one of these two CSRF. 248 00:31:47,990 --> 00:31:55,810 And the affected applications include the Jupyter lab or notebook and also Canvas LMS. 249 00:31:57,510 --> 00:32:02,370 So let's dive into the Jupyter lab or Jupyter notebook for details. 250 00:32:02,370 --> 00:32:17,950 The first summary, so we found HTML injection in Jupyter lab, Jupyter notebook, web page, and also we found DOM clobbering gadget with HAWQ in both version 2 and version 3. 251 00:32:18,030 --> 00:32:23,670 The message library is used by the Jupyter lab to render mathematical formulas. 252 00:32:23,670 --> 00:32:28,250 And though combining those two together we can achieve end to end exploitation. 253 00:32:30,050 --> 00:32:49,070 So in terms of the HTML injection, we found that in the markdown preview page of Jupyter lab, if we insert some, if we just type in raw HTML tags for example image or whatever HTML elements, it will be accepted and rendered in the web page. 254 00:32:50,550 --> 00:32:56,510 And we also reported this end to end vulnerability to the developer of Jupyter lab. 255 00:32:56,510 --> 00:33:08,590 And they also confirmed that it is not trivial to mitigate this vulnerability because the ID and name attributes they are assumed to work by a large number of widget libraries. 256 00:33:08,590 --> 00:33:14,750 So a very easy example is that for example there is a markdown file with two hash tags hello. 257 00:33:14,750 --> 00:33:21,710 This tag will be rendered as an H2 element with the ID equals to hello. 258 00:33:21,710 --> 00:33:31,090 And the ID hello will later or somewhere be used as the fragment identifier in the URL to locate that element in the page. 259 00:33:33,840 --> 00:33:45,820 So if we take a look at the MathJax library, it is a library used while used to render mathematical formulas and it is used by the Jupyter lab. 260 00:33:46,600 --> 00:33:54,240 So with our toolhawk we found dump clobbering gadgets in both MathJax version 2 and version 3. 261 00:33:54,240 --> 00:34:01,360 And just days before they released version 4 and they promised to fix this vulnerability but we haven't checked yet. 262 00:34:01,360 --> 00:34:03,760 Just say good luck. 263 00:34:04,560 --> 00:34:05,220 Okay. 264 00:34:05,220 --> 00:34:13,520 So if we take a look at the MathJax version 2 we will find the window dot MathJax here is clobberable element. 265 00:34:13,520 --> 00:34:22,420 And then later that variable is combined is concatenated with some constant strings to construct a file URL. 266 00:34:22,420 --> 00:34:25,660 And here a type coercion happens. 267 00:34:25,840 --> 00:34:39,740 And finally that file URL is used to load is used to the script source which is to load the attacker control the scripts. 268 00:34:40,160 --> 00:34:43,620 That will cause cross-site scripting. 269 00:34:43,620 --> 00:34:58,380 And but if we take a look at the version 3 just at the first glance there is no more clobberable window dot MathJax and there is no more loading of additional dependency scripts by default. 270 00:34:58,520 --> 00:35:11,760 But by leveraging hawk we found that MathJax version 3 they supports using the require macro which allows you to load extension scripts. 271 00:35:12,240 --> 00:35:20,140 So we further found that in version 3 of MathJax there is a clobberable element called document dot current script. 272 00:35:20,140 --> 00:35:30,380 And then later that document dot current script is document dot current script SRC attribution is get. 273 00:35:30,380 --> 00:35:40,320 And with some regular expression replacement operation the string from that payload is retrieved. 274 00:35:40,320 --> 00:35:52,100 And then finally that T variable is assigned to the R dot SRC which is which is the SRC attribute of one script element in a page. 275 00:35:52,100 --> 00:35:56,820 That is also causing loading scripts from the attacker's domain. 276 00:36:00,480 --> 00:36:02,400 So okay. 277 00:36:03,440 --> 00:36:09,780 So till now we have both dump clobbering gadgets from MathJax both version 2 and version 3. 278 00:36:10,020 --> 00:36:27,020 And also with our research on dump clobbering we reported those problems and Firefox is also supporting considering patching the dump clobbering by disabling the shadowing on document lookups. 279 00:36:27,660 --> 00:36:32,980 And they are they are referring to the zero day gadgets found by our tool hawk. 280 00:36:32,980 --> 00:36:34,740 That's good news. 281 00:36:34,840 --> 00:36:45,700 So to summary we design and implement hawk a dynamic analysis tool for automatically detecting and exploiting dump clobbering gadgets. 282 00:36:45,700 --> 00:37:03,220 So and we also conduct a large scale study over the trunk top 5,000 websites and identify 497 exploitable gadgets revealing the widespread presence of dump clobbering vulnerabilities in popular client side libraries. 283 00:37:03,220 --> 00:37:14,360 And also we demonstrate 12 end to end exploitations by combining the discover gadgets with real world HTML injections validating their practical impact. 284 00:37:14,360 --> 00:37:19,980 So our tool the source code, the data set and the paper are all open source. 285 00:37:19,980 --> 00:37:22,960 Feel free to access them if you are interested. 286 00:37:23,100 --> 00:37:29,040 And also both of us, Zhang Yu and Jianjia, we are open to internship or full time jobs. 287 00:37:29,040 --> 00:37:33,660 So if you have any opportunities please feel free to reach out to us. 288 00:37:33,660 --> 00:37:34,260 Thank you.