1 00:00:00,000 --> 00:00:06,280 I'm going to get Maxim going here fairly quickly because he was asking me about the timer very quickly, which means he has a lot to cover. 2 00:00:06,500 --> 00:00:12,580 And it's a super important topic about supply chain attacks, because if the robots don't get us, this shit will. 3 00:00:13,380 --> 00:00:15,020 Have a wonderful time. 4 00:00:15,020 --> 00:00:15,820 Thank you. 5 00:00:16,120 --> 00:00:18,740 Let's give him a big round of applause and a big welcome. 6 00:00:19,220 --> 00:00:20,200 Thank you. 7 00:00:26,590 --> 00:00:37,170 Imagine one sunny morning, you read the news, a crypto war disrupts operations of hundreds of companies around the world and government networks of 25 countries. 8 00:00:37,170 --> 00:00:48,130 The war is spreading and the initial blast radius is estimated to be around 28,000 machines and now likely affecting much more computers around the planet. 9 00:00:48,150 --> 00:00:52,330 Security industries struggle to understand how did this happen? 10 00:00:52,330 --> 00:00:54,910 There is no one source of compromise. 11 00:00:55,110 --> 00:01:02,330 Eventually, a security researcher with support from cloud providers connect all the dots and find the source. 12 00:01:02,330 --> 00:01:10,030 All backdoor software were pulled from cloud buckets that were abandoned in the past and reclaimed by the threat actor. 13 00:01:10,030 --> 00:01:16,050 The risk many researchers have raised in the past materialized on the truly gigantic scale. 14 00:01:16,050 --> 00:01:23,610 The buckets are taken down by the cloud provider with estimates suggesting like about 5,000 buckets being affected. 15 00:01:25,030 --> 00:01:35,870 This is not a real incident, it was me who claimed 5,000 buckets and those are images of a fake news channel generated with LLM. 16 00:01:35,870 --> 00:01:45,590 But the risk is very real and today I want to invite you on a journey to dissect the anatomy of such an attack and talk about root cause remediation. 17 00:01:47,050 --> 00:01:53,730 My name is Max, I am security researcher and engineer at Big Tech, mostly doing Red Team in these days. 18 00:01:53,730 --> 00:01:55,970 I have a PhD in computer security. 19 00:01:55,970 --> 00:02:06,910 I presented at this stage twice in the past and I open sourced a couple of projects for fuzzing, for software analysis, and for GCP scanning. 20 00:02:07,830 --> 00:02:11,570 So the talk will be logically divided into five parts. 21 00:02:11,570 --> 00:02:17,850 We're going to try to understand the motivation of supply chain attack via S3 buckets. 22 00:02:17,890 --> 00:02:30,590 We will discuss how an attacker equipped with modern elements of big data analysis and LLMs can bring those attacks on a really giant scale. 23 00:02:30,590 --> 00:02:37,070 We're going to walk through nine case studies and then we're going to talk about root cause remediation here. 24 00:02:37,270 --> 00:02:42,730 Before we start I need to say that I'm presenting on my own behalf. 25 00:02:42,970 --> 00:02:47,470 This presentation does not reflect opinion of any of my past or current employers. 26 00:02:48,670 --> 00:02:53,330 So why do we want a supply chain attack in the first place? 27 00:02:53,350 --> 00:02:58,990 So if you've ever done Red Team on pen test, you know that perimeter penetration might be really hard. 28 00:02:58,990 --> 00:03:08,390 And then as an attacker you might notice, right, that attack costs grow as long as you want a higher efficiency. 29 00:03:08,530 --> 00:03:13,050 And you kind of want to invert this game, right, in your advantage. 30 00:03:13,170 --> 00:03:16,410 And in my opinion supply chain attack gives you that advantage. 31 00:03:16,410 --> 00:03:19,790 The attack surface usually grows with the size of the company. 32 00:03:20,370 --> 00:03:26,090 Depending on the software you can actually end up in privileged parts of network or even in prod, right. 33 00:03:26,090 --> 00:03:30,550 And the obvious disadvantage is precision, right. 34 00:03:30,550 --> 00:03:39,570 You have to target something that's used by your target or maybe you don't care or maybe you compromise something that's used by anyone. 35 00:03:39,570 --> 00:03:40,890 So there's benefit. 36 00:03:41,150 --> 00:03:43,990 How does it work in practice in case of cloud buckets? 37 00:03:43,990 --> 00:03:51,090 So let's say you have something that's running on a potential weakness machine and pull executable code from a cloud bucket. 38 00:03:51,090 --> 00:03:57,330 It can be an automated job or users just follow some instruction, let's say curl and pipe it in the bash. 39 00:03:57,730 --> 00:04:00,610 What's going to happen if bucket is deleted? 40 00:04:00,850 --> 00:04:07,010 Well, users will get 404 from AWS, but the bucket namespace is available. 41 00:04:07,010 --> 00:04:18,730 So someone with bad intent can claim the bucket, put malware into it, make it public and well, everyone who rely on that bucket will get infected, right. 42 00:04:19,650 --> 00:04:22,510 Same is actually applicable to malware. 43 00:04:22,710 --> 00:04:27,870 Imagine you have a host compromised with stage one that's pulling stage two from S3 bucket. 44 00:04:28,030 --> 00:04:35,810 Someone sends abuse report to cloud provider, the bucket is taken down and at some point recycled back to consumers. 45 00:04:35,810 --> 00:04:49,730 An attacker who is not affiliated with the original malware can claim this bucket and again, put malware into it, enable public access to it and well, infect all the victims of that malware. 46 00:04:49,730 --> 00:04:55,690 And in general, this risk is not something that's unknown to the industry, right. 47 00:04:55,830 --> 00:05:01,990 Real threat actors and security researchers have been abusing and show this risk in the past. 48 00:05:01,990 --> 00:05:15,410 For example, backdooring Python packages, targeting AWS S3 buckets, expired domains, popular NPM packages and even top level domains of a sovereign state, right. 49 00:05:15,410 --> 00:05:17,990 And it was also presented at this stage at DEF CON. 50 00:05:17,990 --> 00:05:26,430 People were hacking software and two years ago, Thomas Johansson presented the danger of expired TLD domain, well, to pwn internet. 51 00:05:26,430 --> 00:05:28,030 So there's a risk. 52 00:05:28,230 --> 00:05:32,350 And as for malware, this Watchtower research is quite cool. 53 00:05:32,690 --> 00:05:41,890 They showed that it's possible to hijack a lot of expired domains in web shells with backdoors, where backdoor phones back to those expired domains. 54 00:05:41,890 --> 00:05:43,750 So check it out, it's quite cool. 55 00:05:43,750 --> 00:05:52,530 And the closest work to this one is this another great Watchtower research where they claimed 150 buckets and also showed the risk, right. 56 00:05:52,610 --> 00:05:57,550 They published that when I was wrapping up the first bunch of my research here. 57 00:05:57,950 --> 00:06:03,490 But still, we have still a lot of remaining unknowns here, right? 58 00:06:03,490 --> 00:06:05,290 What is the real scale of the attack? 59 00:06:05,290 --> 00:06:08,210 What if we claim a lot of buckets, right? 60 00:06:08,310 --> 00:06:09,650 What would be impact? 61 00:06:09,650 --> 00:06:12,510 Can we actually simulate it and see how it works? 62 00:06:12,510 --> 00:06:21,310 Because, well, in theory, everything works, it was true in this research. 63 00:06:21,310 --> 00:06:25,210 I had a lot of buckets that I initially thought are exploitable, they were not. 64 00:06:25,390 --> 00:06:27,230 And, well, what about data? 65 00:06:27,950 --> 00:06:30,030 We will have a lot of data, right? 66 00:06:30,170 --> 00:06:33,330 You will see, and how do you navigate this data? 67 00:06:33,330 --> 00:06:34,950 What is the true cost of attack? 68 00:06:34,950 --> 00:06:37,650 And actually no one talked about root cause remediation here. 69 00:06:37,650 --> 00:06:39,630 We're going to close these gaps today. 70 00:06:40,330 --> 00:06:42,390 We also have to be very careful. 71 00:06:42,390 --> 00:06:44,390 There are certain rules of engagement here. 72 00:06:44,390 --> 00:06:47,430 First of all, buckets always has to stay private, right? 73 00:06:47,430 --> 00:06:49,330 We always return 403. 74 00:06:49,330 --> 00:06:51,410 We don't want to compromise actual people. 75 00:06:51,410 --> 00:06:55,390 If we want to test anything, we test it on a clone of the bucket. 76 00:06:55,390 --> 00:06:56,710 We respect user privacy. 77 00:06:56,710 --> 00:07:00,330 We don't attribute to individual IPs, individual organization. 78 00:07:00,330 --> 00:07:03,890 I want to show you the scale and the big picture here. 79 00:07:03,890 --> 00:07:08,590 And we also responsibly disclose the findings later about that. 80 00:07:08,690 --> 00:07:10,750 And our approach is quite simple. 81 00:07:10,750 --> 00:07:12,050 We search for buckets. 82 00:07:12,070 --> 00:07:13,990 We check if it's available. 83 00:07:13,990 --> 00:07:14,830 We claim it. 84 00:07:14,830 --> 00:07:16,870 We enable logs for five days. 85 00:07:16,890 --> 00:07:19,710 We triage logs to find sensitive stuff. 86 00:07:19,710 --> 00:07:21,650 We evaluate security impact. 87 00:07:21,750 --> 00:07:23,350 And, well, I guess profit. 88 00:07:23,890 --> 00:07:26,890 Let's move to the part where we search for the buckets. 89 00:07:27,070 --> 00:07:30,450 And the best place to store your code these days is GitHub, right? 90 00:07:30,450 --> 00:07:33,890 It's petabytes of data, millions of repositories. 91 00:07:33,890 --> 00:07:39,490 And unfortunately they don't kind of allow you to search through all the code, right? 92 00:07:39,490 --> 00:07:40,670 You cannot just query. 93 00:07:40,670 --> 00:07:45,290 What enabled this nice tool called source graph, search engine. 94 00:07:45,290 --> 00:07:49,330 It allows you to search GitHub just in seconds, right? 95 00:07:49,330 --> 00:07:56,430 And now all you need to do is to search for S3.Amazon.AWS.com or S3, right? 96 00:07:56,430 --> 00:07:57,590 And you get everything. 97 00:07:57,590 --> 00:08:01,970 And then you expect bucket names with this like ugly regular expression. 98 00:08:02,350 --> 00:08:03,310 And that's it. 99 00:08:03,350 --> 00:08:08,670 And you can say apply same for Maven and PyPy where you have millions of files. 100 00:08:09,230 --> 00:08:13,590 You need to list and fetch repos from repo one or PyPy. 101 00:08:13,870 --> 00:08:15,670 You like download package. 102 00:08:15,670 --> 00:08:16,970 You extract it in memory. 103 00:08:16,970 --> 00:08:18,610 You apply the three gaps. 104 00:08:18,610 --> 00:08:19,650 And, well, you have buckets. 105 00:08:19,650 --> 00:08:22,850 The only difference here that in case of GitHub it was seconds. 106 00:08:23,230 --> 00:08:30,570 In Maven and PyPy it was one and a half months running on like machine on my wife's computer. 107 00:08:30,570 --> 00:08:31,650 It was super noisy. 108 00:08:31,650 --> 00:08:32,550 A lot of CPUs. 109 00:08:32,550 --> 00:08:33,810 Eventually it lost power. 110 00:08:33,810 --> 00:08:34,930 So I gave up. 111 00:08:34,930 --> 00:08:37,170 Like, okay, I don't want to run it anymore. 112 00:08:37,930 --> 00:08:44,890 But eventually, like, I think I managed to crawl through like 45% of everything there. 113 00:08:45,050 --> 00:08:48,910 Anyway, for malware it's even more challenging, right? 114 00:08:49,270 --> 00:08:51,870 You cannot just get all malware. 115 00:08:51,870 --> 00:08:58,210 And I was pretending to be a lazy and, well, since lazy and poor hacker in this research. 116 00:08:58,210 --> 00:09:03,030 So it was impossible for me to get all the samples. 117 00:09:03,030 --> 00:09:06,370 And even if I would get them, there was still a problem, right? 118 00:09:06,370 --> 00:09:09,170 Malware is usually packed and obfuscated. 119 00:09:10,310 --> 00:09:16,070 You need to probably run it in sandbox and it opens another layer of problems, right? 120 00:09:16,070 --> 00:09:24,830 But then this nice resource called URL host, I found it and, yeah, it was relatively straightforward. 121 00:09:24,830 --> 00:09:30,850 They allow you to get all links to Amazon AWS, right? 122 00:09:30,850 --> 00:09:32,470 So it was perfect for me. 123 00:09:32,590 --> 00:09:33,030 Okay. 124 00:09:33,030 --> 00:09:35,550 I'm pretty sure you are interested in what I got. 125 00:09:35,790 --> 00:09:46,290 I registered 480 buckets, 255 received traffic, 4.5 million requests and 3.5 gigabyte of logs. 126 00:09:46,490 --> 00:09:48,490 This is a geography of requests, right? 127 00:09:48,490 --> 00:09:52,430 15,000 hosts, 129 countries. 128 00:09:52,490 --> 00:10:00,090 For malware I got like 188 buckets , 175 received traffic, 2 million requests, almost 4 gigabytes of logs. 129 00:10:00,090 --> 00:10:02,470 And this is a geography. 130 00:10:02,470 --> 00:10:12,210 So it's 20,000 hosts from 142 countries and they were mostly pulling executables and JavaScript, right? 131 00:10:12,410 --> 00:10:23,030 As for GitHub, there we got 4.5,000 buckets, 1.5 received traffic, almost 4 million requests and 19 gigabytes of logs. 132 00:10:23,030 --> 00:10:24,790 So it was quite a lot. 133 00:10:24,790 --> 00:10:26,610 And this is a geography. 134 00:10:26,610 --> 00:10:33,650 So it's 243,000 hosts, all countries except probably North Korea, right? 135 00:10:33,650 --> 00:10:37,810 But keep in mind that most of those requests are not sensitive. 136 00:10:37,810 --> 00:10:40,390 They might not be dangerous in the first place, right? 137 00:10:40,390 --> 00:10:43,730 So how do we find dangers out of this noise? 138 00:10:43,750 --> 00:10:45,250 And, well, let me show you. 139 00:10:45,250 --> 00:10:55,930 This is an example of a log query to AWS, a lot of fields, but what we really care about is bucket name, IP address, request type, object URL referrer and user agent, right? 140 00:10:56,150 --> 00:10:59,290 This data allow you to get the context around requests. 141 00:10:59,290 --> 00:11:04,270 But still, we had 26 gigabytes of logs and 11 million requests. 142 00:11:04,270 --> 00:11:05,610 So it's a lot, right? 143 00:11:05,610 --> 00:11:07,470 And I needed to navigate through it. 144 00:11:07,510 --> 00:11:16,910 But a lot of those requests are coming to pull non-sensitive stuff such as pictures, videos, some text files, like training data and so on. 145 00:11:16,910 --> 00:11:18,570 You can just remove it, right? 146 00:11:18,570 --> 00:11:27,310 We can also filter out like bots, scanners, you know, a lot of bots these days that try to scrape everything for LLM training. 147 00:11:27,530 --> 00:11:29,310 You can like remove it. 148 00:11:29,310 --> 00:11:31,710 You can also aggregate unique IP, right? 149 00:11:31,710 --> 00:11:33,710 Is someone pulling something in the loop? 150 00:11:33,710 --> 00:11:36,130 We counted this on one host, right? 151 00:11:36,170 --> 00:11:39,690 And still, I had a lot of requests. 152 00:11:40,190 --> 00:11:43,870 Probably three years ago, I would just give up or look through them manually. 153 00:11:43,870 --> 00:11:48,450 But these days, we have LLM agents that can help to do the classification for you. 154 00:11:48,450 --> 00:11:53,350 So I leveraged the custom LLM agents to classify requests. 155 00:11:53,530 --> 00:12:03,310 And I got like, I guess, time saving from like a month to a couple of days from like gigabytes of logs to a few megabytes with 500 sensitive buckets . 156 00:12:03,310 --> 00:12:07,290 Of course, I had like hallucinations and like when LLMs was simply wrong. 157 00:12:07,290 --> 00:12:09,210 But still, it kind of worked. 158 00:12:09,710 --> 00:12:12,830 If you're curious about LLM, this is architecture, right? 159 00:12:12,830 --> 00:12:16,190 You have three components working together. 160 00:12:16,550 --> 00:12:21,390 One element is a planner, aggregator, classifier. 161 00:12:21,390 --> 00:12:27,570 I give tools like internet search and GitHub search for the agent and I save answers to the database, right? 162 00:12:27,570 --> 00:12:29,430 And so this is like the prompt, right? 163 00:12:29,430 --> 00:12:39,370 You provide the bucket name, you provide actual requests, it like construct a plan, then in the aggregator with the tools, right? 164 00:12:39,370 --> 00:12:41,850 It actually query and all the content. 165 00:12:42,470 --> 00:12:46,550 And then with all this context, the classifier makes the final decision. 166 00:12:46,590 --> 00:12:48,210 This is how it looks in practice, right? 167 00:12:48,210 --> 00:12:49,450 That ugly little page, right? 168 00:12:49,450 --> 00:12:51,350 With a lot of context. 169 00:12:51,350 --> 00:13:09,490 And this is an example of LLM like telling me that, well, something is trying to pull minecraft-py from assets.minecraft.net, unpacking it and well, classification is executable because I know that on the website they ask users to execute it. 170 00:13:09,490 --> 00:13:12,030 So, yeah, a big time saver. 171 00:13:12,710 --> 00:13:15,450 All right, so let's talk about results. 172 00:13:15,890 --> 00:13:21,770 Before we show examples, those are the sensitive types that I came up with. 173 00:13:21,770 --> 00:13:33,130 So it's executables, ML models, archived executables, PyPy packages, I had dynamic web content, static sensitive files, configs and data write attempts. 174 00:13:33,130 --> 00:13:36,990 So let's start with examples on executables, right? 175 00:13:36,990 --> 00:13:46,070 So statistics were dominated by PyTorch and Microsoft executables and archives as executables. 176 00:13:46,490 --> 00:13:52,090 For SN, statistics, mostly ISPs, so like end users, right? 177 00:13:52,090 --> 00:13:58,050 I had requests from like universities, maybe students on campus, maybe administrative network, you never know. 178 00:13:58,050 --> 00:14:04,070 And I had a lot of like business entities, like small, medium business and a large stock trading company. 179 00:14:04,410 --> 00:14:19,470 A canonical example would be this large network equipment company who used to surf installation binary from three buckets, they changed the distribution policy, made an announcement and deleted the bucket. 180 00:14:19,470 --> 00:14:30,050 But unfortunately, the link was still used by a lot of clients not affiliated to the original tool owner, right? 181 00:14:30,050 --> 00:14:35,510 Like this one, like a partial script where they pull and execute a binary from the bucket. 182 00:14:35,510 --> 00:14:43,250 And in this case, it's 162 hosts who would execute our malicious code. 183 00:14:43,730 --> 00:14:45,950 And another example is Minecraft, right? 184 00:14:45,950 --> 00:15:06,810 It can be played on Raspberry Pi and you need to download the website with reference in the package that you need to download and unpack and execute from, again, an S3 bucket, an S3 bucket was abandoned, and well, again, this gives us a very straightforward to get code execution on a lot of hosts. 185 00:15:08,130 --> 00:15:14,830 I also had a lot of requests to pull Vagrants.box VMs, right, from abandoned S3 buckets. 186 00:15:15,630 --> 00:15:21,610 You can obviously put backdoor in VM, but escaping VM is not an easy job, right? 187 00:15:21,610 --> 00:15:23,930 And how about executing code on the host? 188 00:15:23,930 --> 00:15:25,310 And it's also possible. 189 00:15:25,310 --> 00:15:36,650 Because Vagrants allow you to put like system command in the config and any time user like download the box and edit, not like execute, even add, you can execute your code. 190 00:15:36,650 --> 00:15:40,890 So a very straightforward way to get code execution, right? 191 00:15:40,970 --> 00:15:43,810 Now, PyTorch models. 192 00:15:44,070 --> 00:15:49,570 A quarter of requests came to pull PyTorch models, right? 193 00:15:49,570 --> 00:15:57,850 And they allow arbitrary code execution because they support like PyTorch relies on pickle deserialization to load models, right? 194 00:15:57,930 --> 00:16:03,710 And well, it's pickle deserialization allow you arbitrary code execution by design, right? 195 00:16:03,710 --> 00:16:09,450 They put some controls in place, but not everyone rely on them, right? 196 00:16:09,450 --> 00:16:12,710 And let me show how it works in practice. 197 00:16:12,710 --> 00:16:14,730 Hopefully the demo will work. 198 00:16:14,730 --> 00:16:15,070 Okay. 199 00:16:15,070 --> 00:16:17,570 So we have this open source project, right? 200 00:16:17,570 --> 00:16:18,830 Super gradients. 201 00:16:18,830 --> 00:16:20,770 4,000 stars. 202 00:16:21,010 --> 00:16:28,490 They used to serve prebuilt models from like S3 buckets, right? 203 00:16:28,950 --> 00:16:31,410 And then they change it. 204 00:16:31,410 --> 00:16:34,410 But people who rely on the old ones still were vulnerable. 205 00:16:34,410 --> 00:16:38,210 And you can see like one example. 206 00:16:38,210 --> 00:16:42,410 We are going to use this one in this demonstration, so we go back. 207 00:16:42,990 --> 00:16:47,190 This is just a simple script on how to load this model, right? 208 00:16:48,110 --> 00:16:49,630 Or does it load it? 209 00:16:49,630 --> 00:16:58,030 And if we execute it, right, you will see 403 with the attempt to pull it from the bucket. 210 00:16:58,030 --> 00:17:00,510 So this is 403, right? 211 00:17:00,510 --> 00:17:07,150 If you scroll it up, you see the attempt to download it from the bucket. 212 00:17:07,210 --> 00:17:10,170 And this is the package, right? 213 00:17:10,170 --> 00:17:12,310 The old version to show in the demo. 214 00:17:12,310 --> 00:17:14,270 It's like two years ago, right? 215 00:17:14,270 --> 00:17:15,950 I need to apply patch. 216 00:17:15,950 --> 00:17:20,630 As you remember, we don't want to run it on like actual bucket. 217 00:17:20,630 --> 00:17:21,710 We want the clone. 218 00:17:21,710 --> 00:17:25,090 So this is the only way you can simulate it safely, right? 219 00:17:25,090 --> 00:17:27,370 So this is the change. 220 00:17:27,370 --> 00:17:31,490 Like just two places where this random string to the bucket name, right? 221 00:17:31,490 --> 00:17:32,850 And claim the bucket. 222 00:17:32,970 --> 00:17:36,450 And we can scroll down, and that's basically another one. 223 00:17:37,030 --> 00:17:42,310 So we patch it, and now we can go back. 224 00:17:43,030 --> 00:17:54,650 If you run it again, just to validate, right, you're going to see the attempt to pull the model from the copy of the bucket, right? 225 00:17:55,310 --> 00:17:55,930 Okay. 226 00:17:55,930 --> 00:18:00,550 So now let's poison the model, right? 227 00:18:00,550 --> 00:18:04,330 We're going to rely on this code snippet from Snook, right? 228 00:18:04,330 --> 00:18:07,670 It's a minimal implementation to inject code in PyTorch. 229 00:18:08,110 --> 00:18:09,810 Relatively straightforward. 230 00:18:10,330 --> 00:18:13,910 Just import the system calculator. 231 00:18:14,050 --> 00:18:15,510 So that's basically it. 232 00:18:15,510 --> 00:18:17,990 And we save it in the PTH file, right? 233 00:18:18,570 --> 00:18:19,070 All right. 234 00:18:19,070 --> 00:18:22,070 So let's close it. 235 00:18:22,350 --> 00:18:32,430 So we're going to poison this model, right, that I downloaded from their new place. 236 00:18:32,670 --> 00:18:33,030 Okay. 237 00:18:33,030 --> 00:18:34,850 So we have the model. 238 00:18:34,850 --> 00:18:42,390 Now we need to reconstruct the folder structure, the tool expect, right, the open source supergradients. 239 00:18:42,530 --> 00:18:45,250 And now we are ready to upload it to S3 bucket, right? 240 00:18:45,250 --> 00:18:48,650 So this is the name of the bucket, right? 241 00:18:48,650 --> 00:18:51,250 So we upload it. 242 00:18:51,250 --> 00:18:53,750 We need to upload folder, not file. 243 00:18:54,390 --> 00:18:54,970 All right. 244 00:18:54,970 --> 00:18:56,410 So we go back. 245 00:18:58,090 --> 00:18:59,390 We upload it. 246 00:18:59,390 --> 00:19:03,010 So the model is 34 megabytes, right? 247 00:19:03,450 --> 00:19:07,230 And all you need is just to enable access to it, right? 248 00:19:07,230 --> 00:19:09,630 Well, world access. 249 00:19:10,430 --> 00:19:10,990 Okay. 250 00:19:10,990 --> 00:19:12,310 So we upload it. 251 00:19:21,060 --> 00:19:25,840 And now we can pull the model, like just rerun the script, right? 252 00:19:25,840 --> 00:19:27,640 And we will get the calculator. 253 00:19:30,190 --> 00:19:31,870 So the model is loading. 254 00:19:31,870 --> 00:19:35,370 And we got this ugly full screen calculator. 255 00:19:35,370 --> 00:19:35,870 Okay. 256 00:19:35,870 --> 00:19:37,830 Now let's move to another example. 257 00:19:37,830 --> 00:19:43,510 I had even bigger open source project with 33,000 stars. 258 00:19:43,510 --> 00:19:45,710 Again, same problem there, right? 259 00:19:46,050 --> 00:19:49,810 People who rely on our bucket got compromised, right? 260 00:19:49,830 --> 00:19:59,030 And in this case, you can, again, poison PyTorch model and get code execution when people load their, like, their buckets, right? 261 00:19:59,330 --> 00:20:00,270 All right. 262 00:20:00,270 --> 00:20:03,050 So let's go to Maven and PyPy packages. 263 00:20:03,050 --> 00:20:07,930 Out of hundreds of buckets, I actually got only nine sensitive buckets, right? 264 00:20:07,930 --> 00:20:13,190 Still like 3.8 thousand IPs, JavaScript, and executables. 265 00:20:14,150 --> 00:20:16,290 I want to show you one example. 266 00:20:16,290 --> 00:20:19,710 It's not so pretty, I think. 267 00:20:20,230 --> 00:20:27,590 The old version is vulnerable because it tries to pull a pre-built binary from an S3 bucket, right? 268 00:20:27,590 --> 00:20:30,310 Now it returns 403. 269 00:20:30,310 --> 00:20:32,990 Well, 403 because we control it right now. 270 00:20:32,990 --> 00:20:45,270 And the plea is basically a wrapper around a native binary that will be installed on your machine from that S3 bucket, right? 271 00:20:45,270 --> 00:20:48,070 And we can just modify that library. 272 00:20:48,070 --> 00:20:56,170 We can add our code every time the library is loaded and, well, get code execution on the machine. 273 00:20:56,170 --> 00:20:58,310 And let me show how it works in practice, right? 274 00:20:58,310 --> 00:21:06,190 So, again, so if we execute this not so plea package, right? 275 00:21:06,190 --> 00:21:10,670 So an old version is probably like five years old. 276 00:21:10,670 --> 00:21:13,530 You see the attempt 403. 277 00:21:13,610 --> 00:21:13,970 Yep. 278 00:21:13,970 --> 00:21:20,250 So it's trying to pull that archive and extract it on the machine, right? 279 00:21:20,250 --> 00:21:21,790 So this is the name, basically. 280 00:21:21,790 --> 00:21:28,830 And I have a version of it slightly, like, newer just to make it easier to compile. 281 00:21:28,830 --> 00:21:30,930 But it's basically the same package, right? 282 00:21:30,930 --> 00:21:32,710 And vulnerable to the same problem. 283 00:21:32,710 --> 00:21:40,390 So let's change, again, the reference to the bucket to something without active clients. 284 00:21:40,390 --> 00:21:47,890 So we add just additional string, right? 285 00:21:47,930 --> 00:21:55,870 And now I already compiled the library and put it in the bucket to make it faster. 286 00:21:56,930 --> 00:22:01,810 All we need now is to basically execute the package, right? 287 00:22:01,810 --> 00:22:11,390 So if we execute it, so it tries to fetch a bunch of stuff. 288 00:22:11,570 --> 00:22:16,210 But at some point, it will fetch the prebuilt library and install it on the machine, right? 289 00:22:16,210 --> 00:22:19,970 So, okay, now at this point, the backdoor library is there. 290 00:22:19,970 --> 00:22:24,630 And if we execute the binary, we get arbitrary code execution. 291 00:22:25,010 --> 00:22:25,770 So, yeah. 292 00:22:25,850 --> 00:22:27,230 Pretty nice. 293 00:22:29,590 --> 00:22:30,670 Thank you. 294 00:22:32,750 --> 00:22:35,530 And the impact of this would be quite interesting. 295 00:22:35,530 --> 00:22:51,310 It would lead to installation of a backdoor library on five Fortune 500 companies, like, including three largest banks in the world, AV vendor, a global telecom company, and a huge retail company, right? 296 00:22:51,310 --> 00:22:55,030 And there's another example called kuva-dev. 297 00:22:55,030 --> 00:23:03,890 This one is interesting because it references an additional host repository for this package that I have never heard about. 298 00:23:03,890 --> 00:23:13,290 But in the log, I found, like, 288 hosts pulling thousands of packages from that repository. 299 00:23:13,290 --> 00:23:14,990 This is an example of logs. 300 00:23:14,990 --> 00:23:17,150 And this would be also quite dangerous. 301 00:23:17,150 --> 00:23:28,710 It would lead to, again, installation of backdoor packages on five government entities in Europe and South America, global investment fund, and two major, like, tech and telecom companies. 302 00:23:28,710 --> 00:23:34,990 And we have limited time, so I cannot go through all examples of sensitive request types. 303 00:23:34,990 --> 00:23:39,410 I just want to quickly mention that I had a lot of requests to PHP and JavaScript. 304 00:23:39,530 --> 00:23:43,650 I also had requests to static, like, sensitive files and webpages. 305 00:23:43,890 --> 00:23:48,770 And most of them, like, PDF docs and, well, Microsoft formats. 306 00:23:49,190 --> 00:23:53,490 You might be thinking, okay, Max, what's the problem with the static file format? 307 00:23:53,490 --> 00:23:59,890 Well, it's a good social engineering vector because you already have established trust with a potential victim, right? 308 00:23:59,890 --> 00:24:15,750 So they come and download something on the website, and you can, well, it wouldn't be super odd to ask them to run some command, let's say, in the PDF, like, a manual, or in case of this weird engineering calculator, ask them to enable macros, right? 309 00:24:15,750 --> 00:24:26,010 And in this particular case, it would be, like, three state-level agencies in, like, in Europe and in South America, and, like, integration design firms, right? 310 00:24:26,010 --> 00:24:28,130 So it's a relatively interesting vector. 311 00:24:28,730 --> 00:24:31,730 And what's funny, I had, like, data write attempts. 312 00:24:31,730 --> 00:24:36,470 So I created a bucket, and I see people trying to put logs in my buckets, right? 313 00:24:36,750 --> 00:24:39,170 Which is quite funny, in my opinion. 314 00:24:39,170 --> 00:24:40,510 But obviously, I didn't enable. 315 00:24:40,510 --> 00:24:46,910 I don't know what they wanted to put into my buckets because it might be sensitive, right? 316 00:24:47,130 --> 00:24:47,590 Okay. 317 00:24:47,590 --> 00:24:52,130 Let's go to the most, like, funny part, which is the malware. 318 00:24:52,630 --> 00:24:55,550 Let's start with some statistics. 319 00:24:56,090 --> 00:25:01,950 We can see the stats are dominated by two families, RK and Linker. 320 00:25:02,990 --> 00:25:07,650 Basically, they represent a huge chunk of all of the malware. 321 00:25:07,650 --> 00:25:13,770 But Linker is a malicious Chrome extension masquerading as a benign application in the web store. 322 00:25:13,770 --> 00:25:17,710 For example, a playlist on the screenshot on the slide. 323 00:25:17,910 --> 00:25:26,490 And when a victim visits some interesting websites, Linker pulled JavaScript from S3 and injected it into the victim's browser, right? 324 00:25:26,490 --> 00:25:28,810 And the main purpose is to show ads. 325 00:25:28,810 --> 00:25:31,430 It was active, like, three, four years ago. 326 00:25:31,590 --> 00:25:38,710 But since then, it was taken down from Chrome web store, and the author eventually abandoned it. 327 00:25:39,070 --> 00:25:42,650 But in the logs, you can still see a lot of requests for those buckets. 328 00:25:43,590 --> 00:25:44,950 Requests, name. 329 00:25:45,410 --> 00:25:47,830 What's important for us is refer, right? 330 00:25:47,830 --> 00:25:55,750 It actually tells us the context in which, like, website this JavaScript will be executed, right? 331 00:25:55,750 --> 00:25:59,010 And there is even public research on that sample. 332 00:25:59,010 --> 00:26:03,210 And the extension just pulled config from this FlashPlaylist.com, right? 333 00:26:03,210 --> 00:26:11,550 And the website should return this mixed panel variable with the link to the bucket and JavaScript, right? 334 00:26:11,650 --> 00:26:12,710 Name. 335 00:26:14,530 --> 00:26:27,370 And the code is obfuscated, but all it does is basically install it in the Chrome local storage, and then this variable is used to pull the script any time a user visits a web page, right? 336 00:26:27,370 --> 00:26:31,530 And, well, since we control S3 bucket, we can put any JavaScript we want. 337 00:26:31,650 --> 00:26:34,170 Let me show you how it works in practice. 338 00:26:34,170 --> 00:26:52,030 So, again, a clone of the S3 bucket with no active clients, malicious JavaScript, and this bucket, just to show you, well, some data can be exfiltrated from the JavaScript, and this is a malicious extension installed in the browser, right? 339 00:26:52,430 --> 00:26:57,050 Let's just visit some websites to show how it works. 340 00:26:57,050 --> 00:27:02,750 Gmail, Twitter, Instagram, Facebook, LinkedIn, right? 341 00:27:02,750 --> 00:27:09,810 And you can see, our JavaScript got executed on all of those websites, right? 342 00:27:10,510 --> 00:27:24,230 And you can take a look at logs, right, and see that there's actual attempt to pull the JavaScript from the bucket we control, right? 343 00:27:24,230 --> 00:27:30,570 And let me show that, well, it's possible to weaponize it in some context, right? 344 00:27:30,570 --> 00:27:38,090 So, for example, on TikTok, well, you can actually exfiltrate some data. 345 00:27:38,090 --> 00:27:42,150 Well, Amazon is allowed in CSP policy on TikTok, so it's quite easy, right? 346 00:27:42,150 --> 00:27:51,590 So, in the JavaScript, we take everything that's available to our JavaScript in the context and put it into the bucket, right? 347 00:27:51,590 --> 00:28:03,370 So, obviously, you cannot, like, steal HTTP-only cookies and probably not all the data, but still, I mean, this is a question on how to weaponize XSS on all of those resources for the attacker, right? 348 00:28:03,370 --> 00:28:06,570 You can see, like, cookies, you can see page data. 349 00:28:07,850 --> 00:28:09,970 I want to rant about this capture. 350 00:28:09,970 --> 00:28:11,410 It's just crazy. 351 00:28:11,410 --> 00:28:23,890 So, I wanted to show you a test account from Microsoft, and I tried to register an account, and, like, I spent a decent amount of time, probably the hardest challenge within the whole research, and it's crazy. 352 00:28:23,890 --> 00:28:25,090 This capture is crazy. 353 00:28:25,090 --> 00:28:25,890 I couldn't. 354 00:28:25,890 --> 00:28:27,290 So, no Microsoft demo for you. 355 00:28:27,290 --> 00:28:30,150 Like, I didn't know how to move the person to the right place. 356 00:28:31,190 --> 00:28:32,610 I don't know. 357 00:28:32,990 --> 00:28:34,610 Well, this is impact, right? 358 00:28:34,610 --> 00:28:41,250 So, thousands of users on, like, many, many websites, like Google, YouTube, and Facebook, and so on. 359 00:28:41,250 --> 00:28:43,570 But, obviously, there's nothing wrong with those websites. 360 00:28:43,570 --> 00:28:48,070 It's basically malicious Chrome extension that injects JavaScript. 361 00:28:48,070 --> 00:29:00,130 It has control over the browser, and I hope that, naturally, this extension will die, right, because of introduction of manifest v3, and the extension depends on manifest v2. 362 00:29:00,130 --> 00:29:01,150 We'll see. 363 00:29:01,270 --> 00:29:03,370 What about sensitive users? 364 00:29:03,410 --> 00:29:04,770 We have a lot of them. 365 00:29:04,770 --> 00:29:13,750 Again, a lot of people visiting, like, government websites in certain countries, and , actually, people from government networks visiting government websites. 366 00:29:13,750 --> 00:29:15,630 So, yeah, quite risky. 367 00:29:17,450 --> 00:29:18,130 RK. 368 00:29:18,130 --> 00:29:23,810 RK is malware pretending to be useful, like, executable. 369 00:29:23,810 --> 00:29:25,010 It tries to steal your data. 370 00:29:25,010 --> 00:29:27,010 It was active, like, four years ago. 371 00:29:27,470 --> 00:29:30,190 It was forked by other families. 372 00:29:30,670 --> 00:29:32,510 That's how it looks in the logs, right? 373 00:29:32,510 --> 00:29:37,410 A machine-generated bucket name, and the request to pull executable. 374 00:29:37,450 --> 00:29:43,070 And there are a bunch of old sandbox reports indicating, okay, that actually happened. 375 00:29:43,670 --> 00:30:00,210 The problem is replicating this malware is quite challenging, because you actually need to find the executable who would, like, pull from the bucket, and it was hard, because, first of all, anti-VM, anti-debugging, and, second, well, malware is not active anymore. 376 00:30:00,210 --> 00:30:05,850 Part of its infrastructure is dead, so you cannot reproduce it in any way. 377 00:30:05,850 --> 00:30:11,830 But for you, I found the sample after, like, a really long search, so RK Stealer. 378 00:30:11,910 --> 00:30:14,510 So we are in Windows VM. 379 00:30:14,510 --> 00:30:15,470 We have Wireshark. 380 00:30:15,470 --> 00:30:19,450 Installer is actually our malware, and we have FakeNetNG. 381 00:30:19,450 --> 00:30:21,490 I'll tell you why we need it. 382 00:30:21,510 --> 00:30:29,210 So let's start Wireshark just to see what's going on, like, on the wire, right? 383 00:30:31,250 --> 00:30:33,650 So then we run installer. 384 00:30:34,050 --> 00:30:35,350 We see some traffic, right? 385 00:30:35,350 --> 00:30:36,790 At this point, you are infected. 386 00:30:36,790 --> 00:30:39,910 Don't, this is fake. 387 00:30:40,530 --> 00:30:44,290 We can see the actual request, right? 388 00:30:44,290 --> 00:30:49,630 And it's HTTP, obviously, because, well, malware doesn't care about your security at all, right? 389 00:30:49,630 --> 00:30:53,330 So it tries to pull the executable over HTTP, right? 390 00:30:53,330 --> 00:30:55,150 This is the actual executable. 391 00:30:55,150 --> 00:31:03,070 And what you can do, actually, you can spin up FakeNetNG that will respond with executable to every request that malware makes, right? 392 00:31:03,070 --> 00:31:06,070 So it's like a fake server for malware. 393 00:31:06,210 --> 00:31:09,010 And in our case, we're going to serve it calculator. 394 00:31:09,010 --> 00:31:10,970 So now see what's going to happen. 395 00:31:10,970 --> 00:31:16,110 So we run malware, and we have our calculator, right? 396 00:31:16,390 --> 00:31:22,090 So now in FakeNetNG, you can see the actual request, right? 397 00:31:22,090 --> 00:31:29,690 It tries to probe whether the bucket is available and the executable is there, and then just download it over HTTP, right? 398 00:31:29,690 --> 00:31:32,510 And we, like, just give it calculator, right? 399 00:31:32,510 --> 00:31:34,250 And it executes it blindly. 400 00:31:34,430 --> 00:31:34,890 All right. 401 00:31:34,890 --> 00:31:37,130 So that was RK. 402 00:31:37,670 --> 00:31:41,030 Now let's move towards total impact. 403 00:31:41,030 --> 00:31:47,710 This is the overall map of the users that I verified would have been compromised from this attack, right? 404 00:31:47,710 --> 00:31:56,190 It's 28,000 users, 158 countries, 134 organizations, and 25 government networks, right? 405 00:31:56,190 --> 00:32:00,050 And you might be thinking, well, Max, we saw, like, bigger attacks, right? 406 00:32:00,050 --> 00:32:04,490 But I want to remind you it's just five days of monitoring logs, right? 407 00:32:04,990 --> 00:32:07,770 God knows what would happen if I would look for two months. 408 00:32:07,770 --> 00:32:08,950 Again, lazy hacker. 409 00:32:09,210 --> 00:32:12,330 Anyway, country statistics. 410 00:32:12,330 --> 00:32:16,570 US, Russia, China, Germany, and other European countries, right? 411 00:32:17,410 --> 00:32:20,490 $20 the cost of attack. 412 00:32:20,490 --> 00:32:27,250 You can likely do it in, like, zero budget that I spent on, like, log storage, right? 413 00:32:27,270 --> 00:32:29,370 And this is attacker profiles. 414 00:32:29,370 --> 00:32:44,790 As you can see from impact, that would be interesting from anyone, from hacktivist for fun to cyber crime for, well, cause financial damage, ransomware and stuff like that, to APT groups for sabotage and espionage purposes, right? 415 00:32:44,830 --> 00:32:47,950 And responsible disclosure is quite interesting here. 416 00:32:47,950 --> 00:32:52,070 As one person who helped me with this research pointed out, there's a paradox here. 417 00:32:52,070 --> 00:32:56,290 In order to find vulnerability, you have to fix vulnerability. 418 00:32:56,290 --> 00:33:01,350 Because once you claim the bucket, it's not any more vulnerability because the bucket is claimed, right? 419 00:33:01,350 --> 00:33:07,470 So, but still, I didn't want to sit on all of those buckets because, well, it's quite dangerous, right? 420 00:33:07,470 --> 00:33:20,810 So eventually I collaborated with AWS on a mediation campaign and they seemed to hold all the buckets that were identified as sensitive, right? 421 00:33:21,930 --> 00:33:27,150 Yeah, it was a positive collaboration with them. 422 00:33:27,190 --> 00:33:31,370 But I want to highlight that this is likely a tip of an iceberg here, right? 423 00:33:31,370 --> 00:33:36,170 A sizable tip, but what about other package repository? 424 00:33:36,370 --> 00:33:38,590 What about GitHub commit history? 425 00:33:38,590 --> 00:33:41,950 Because source graph doesn't allow you to search in the commit history. 426 00:33:41,950 --> 00:33:43,610 What about proprietary code? 427 00:33:43,610 --> 00:33:46,310 And what about other cloud providers, right? 428 00:33:46,310 --> 00:33:51,990 AWS is just one example because of its size, I picked it, but there are others. 429 00:33:52,310 --> 00:33:55,990 And S3 buckets is just one problem, right? 430 00:33:55,990 --> 00:34:05,590 There are other type of abundant resources that an attacker can exploit like domain IP and domains and other stuff. 431 00:34:05,590 --> 00:34:06,790 So, yeah. 432 00:34:07,050 --> 00:34:22,670 And if we ask any cloud provider, they would point out that it's basically customer's responsibility for, well, don't forget your code and references to dangling buckets, right? 433 00:34:22,670 --> 00:34:25,650 And unfortunately, I think they're right. 434 00:34:25,650 --> 00:34:28,650 We should not forget about the code, right? 435 00:34:28,650 --> 00:34:34,350 We should not forget about the references to the buckets that doesn't exist, that represent risk. 436 00:34:34,350 --> 00:34:50,070 And through the course of collaboration with AWS, they also wanted to share that it's also possible to rely on machine generated bucket names in certain cases or make them less predictable to reduce the risk here. 437 00:34:50,070 --> 00:34:57,950 And also, they rolled out recently a higher cap for amount of buckets you can have, so per account. 438 00:34:57,950 --> 00:35:01,730 So per account, you can now have like 10,000 buckets. 439 00:35:01,830 --> 00:35:03,190 And, well, it's a lot. 440 00:35:03,310 --> 00:35:09,690 You probably, like, it would probably incentivize people to, well, not delete buckets. 441 00:35:09,690 --> 00:35:10,950 Like, why do we need to delete it? 442 00:35:10,950 --> 00:35:12,630 Keep it, right? 443 00:35:12,630 --> 00:35:17,770 Yeah, so those are the references, if you want to look deeper into that. 444 00:35:18,590 --> 00:35:21,790 And, like, blaming engineers is nice, right? 445 00:35:21,790 --> 00:35:23,670 But it's not productive. 446 00:35:23,670 --> 00:35:25,110 I would say it's counterproductive. 447 00:35:25,110 --> 00:35:30,010 And I would believe, I believe that in general, as a security industry, we can do better, right? 448 00:35:30,010 --> 00:35:46,430 So if you work on, like, static source code analysis or you're a code storage provider or you're just within a security team within the organization, look for dangling buckets that reference to something that doesn't exist and, well, remove it. 449 00:35:46,850 --> 00:35:48,050 It's not that hard. 450 00:35:48,050 --> 00:35:52,950 And I wanted to release a tool to do it, but eventually I found a bunch of tools that already exist for that. 451 00:35:52,950 --> 00:35:57,550 So just use one of them and they're pretty decent and much better than I would write them. 452 00:35:57,610 --> 00:36:05,090 And the real root cause fix here would involve secure by default cloud, right? 453 00:36:05,090 --> 00:36:10,310 So it's either bucket namespace to be project scoped, right? 454 00:36:10,310 --> 00:36:14,130 So you have project name and bucket name, where project name is immutable. 455 00:36:14,130 --> 00:36:16,770 You cannot, like, delete and someone else reclaim it. 456 00:36:16,770 --> 00:36:21,490 Or even better, like, just make bucket names non-recyclable at all. 457 00:36:21,490 --> 00:36:24,530 So it's not possible to reclaim them, right? 458 00:36:25,430 --> 00:36:31,370 It's possible, probably there are some caveats with abuse potential, right? 459 00:36:31,370 --> 00:36:35,230 Or general people claiming all cool buckets. 460 00:36:35,550 --> 00:36:37,190 Maybe, maybe not. 461 00:36:37,510 --> 00:36:41,830 It requires some research on critical user journeys, right? 462 00:36:42,290 --> 00:36:47,630 And as for buckets used by malware, I think the best path forward is just keep them always private. 463 00:36:47,630 --> 00:36:55,350 There's even, like, this shadow server initiative that's in whole domains used by malware. 464 00:36:55,350 --> 00:37:01,310 So we can, well, cloud providers, I think, can apply the same strategy for buckets, right? 465 00:37:02,130 --> 00:37:02,910 All right. 466 00:37:02,910 --> 00:37:08,730 I hope I convinced you that abundant cloud buckets is a serious problem, right? 467 00:37:08,730 --> 00:37:11,710 You can run the attack with relatively low cost. 468 00:37:12,330 --> 00:37:20,050 And LLMs and elements of big data analysis can really bring this on, like, gigantic scale, right? 469 00:37:20,170 --> 00:37:23,830 And, well, help attack reduce the time and effort required here. 470 00:37:23,870 --> 00:37:38,050 I would like to thank Electronic Frontier Foundation for help here and a lot of amazing people who made this talk possible, as well as James Erickson and overall Amazon security for very positive collaboration. 471 00:37:38,650 --> 00:37:46,370 They wanted to share that they are always welcome to collaborate with security researchers to make, like, the cloud and their customers more secure. 472 00:37:47,630 --> 00:37:49,090 Those are the references. 473 00:37:49,450 --> 00:37:51,310 And, well, basically, that's it. 474 00:37:51,310 --> 00:37:52,230 Thank you. 475 00:37:52,230 --> 00:37:53,690 And I'll be near the stage.