1 00:00:05,970 --> 00:00:09,690 Alright everyone, thank you so much for coming out to this talk. 2 00:00:09,690 --> 00:00:15,050 It's called Secrets and Shadows, Leveraging Big Data for Vulnerability Discovery at Scale. 3 00:00:15,050 --> 00:00:21,810 I'm so excited to be here for another year at another DEF CON, and I really do have something in store for you today. 4 00:00:21,970 --> 00:00:23,730 Let's get right into it. 5 00:00:26,700 --> 00:00:37,700 So, just a disclaimer, everything we're going to talk about today was done completely independent of my employer, outside of work, with my own money, my own resources. 6 00:00:38,100 --> 00:00:44,560 If you want to talk about this work outside of this presentation, just please refer to me as an independent security researcher. 7 00:00:44,560 --> 00:00:48,020 It helps me be able to do work just like this. 8 00:00:51,330 --> 00:01:01,650 So, my name is Bill Demerkappa, and I'm a security researcher with a diverse background in low-level software security, and also cloud security. 9 00:01:05,610 --> 00:01:07,950 I'm interested in defense and offense. 10 00:01:07,950 --> 00:01:19,350 I love solving hard security problems, and while I did start with a software security background, I feel like the impact we can have with cloud security is much wider. 11 00:01:19,350 --> 00:01:32,010 For example, you could have the most complex software vulnerability in the world, but at the end of the day, a simple missing ID check in a cloud environment can lead to a much broader impact. 12 00:01:32,010 --> 00:01:34,550 And that's what really got me interested in the cloud. 13 00:01:34,550 --> 00:01:43,230 It's the ability to have an impact without the same technical complexity that comes with exploiting low-level vulnerabilities. 14 00:01:45,270 --> 00:01:51,350 So, in this talk, we're going to discuss vulnerability discovery at scale. 15 00:01:51,350 --> 00:02:02,950 And what I mean by that is, we're going to take a look at how we traditionally approach vulnerability discovery with two common bug classes, dangling cloud resources and leaked secrets. 16 00:02:02,950 --> 00:02:11,810 The goal is to identify the limitations of our historical approach and shift our perspective through some practical examples. 17 00:02:14,900 --> 00:02:16,700 So, some background. 18 00:02:18,500 --> 00:02:22,080 Now, from a high level, everyone knows what cloud computing is. 19 00:02:22,500 --> 00:02:32,320 It's basically a way where you can create infrastructure, like servers, websites, and more, without needing to actually purchase your own physical server rack. 20 00:02:32,940 --> 00:02:36,240 The cool part is, this can save you a lot of money. 21 00:02:36,240 --> 00:02:41,300 If you're just creating your own blog, you really don't need that many resources at all. 22 00:02:41,380 --> 00:02:43,480 Why not borrow someone else's? 23 00:02:43,480 --> 00:02:47,240 And that's really the fundamental principle of cloud computing. 24 00:02:47,260 --> 00:02:52,260 All you're doing is borrowing from someone else's pool of shared resources. 25 00:02:56,820 --> 00:02:59,900 So, cloud environments are managed over the Internet. 26 00:02:59,900 --> 00:03:02,540 But how do we actually secure this access? 27 00:03:02,960 --> 00:03:08,600 Well, for AWS, the way it works is that you can use something called an access key. 28 00:03:08,660 --> 00:03:21,340 An access key can be short-lived or a long-term token that specifies credentials for your account and allows you to manage your AWS resources, depending on the role and permissions assigned to you. 29 00:03:21,980 --> 00:03:25,280 Can we please increase the microphone sound? 30 00:03:25,900 --> 00:03:28,900 And for other platforms, it's similar. 31 00:03:28,900 --> 00:03:42,960 For example, for Google Cloud, the types of authentication include service accounts, you can use CLI credentials, and in general, tokens are how we're able to operate with these cloud environments. 32 00:03:43,640 --> 00:03:47,600 Unfortunately, tokens also present a pretty severe risk. 33 00:03:49,380 --> 00:03:58,200 So, cloud provider tokens are dangerous because, by default, little restriction, there's little restriction on who can use those tokens. 34 00:03:58,420 --> 00:04:08,480 For example, by default, if you create a root access key in AWS, anyone from any IP can use that access key to manage your cloud environment. 35 00:04:08,860 --> 00:04:14,620 Now, obviously, the impact of a leaked cloud credential will really depend on the context. 36 00:04:14,740 --> 00:04:27,000 For example, a lot of websites hard-code a Google Maps API key, and in reality, despite the fact that it can lead to billing overcharges and abuse, the impact is still fairly limited. 37 00:04:27,500 --> 00:04:32,640 But with a root AWS key, the dangers are much more problematic. 38 00:04:32,900 --> 00:04:47,380 For example, if you stored your database in AWS, or you store your computing in AWS, an attacker could use your credentials to not only access customer data, but to interfere with your production workflows. 39 00:04:49,260 --> 00:05:01,800 Now, when we talk about how everything in the cloud is shared and borrowed, what I mean by that is, by nature, by its nature, the cloud model introduces risk from this sharing model. 40 00:05:02,180 --> 00:05:10,800 So, for example, when you create a virtual machine, what's really happening is you're borrowing time on a physical server that your cloud provider has bought. 41 00:05:11,100 --> 00:05:16,740 And on this physical resource, you get assigned a network IP, for example. 42 00:05:16,960 --> 00:05:31,360 And the reason this is dangerous is because once you're done with a resource, if you still have dangling DNS records pointing at that resource, suddenly that exposes an opportunity for an attacker to take advantage of. 43 00:05:31,440 --> 00:05:35,680 So, from a high level, I view cloud resources in two categories. 44 00:05:35,700 --> 00:05:38,320 Primitive resources and shared resources. 45 00:05:38,600 --> 00:05:44,360 So, a primitive resource is something like a virtual machine where you get assigned a dedicated IP address. 46 00:05:44,500 --> 00:05:48,160 That IP address is not used by any other customer but you. 47 00:05:48,300 --> 00:05:55,620 Whereas with a shared resource, what's really going on is it's a serverless application that serves multiple customers. 48 00:05:55,740 --> 00:06:08,240 For example, if you have a serverless function that you can call on your cloud provider, that URL you use to connect to that serverless function probably corresponds to an IP that serves a lot of other customers. 49 00:06:08,260 --> 00:06:15,740 The reason this distinction is important is because it impacts what type of dangling DNS records you need to worry about. 50 00:06:15,760 --> 00:06:27,680 So, for primitive resources where you have that unique IP address, that includes pretty much every type of DNS record that could be dangling, like an A record, a C name record, a name server, and et cetera. 51 00:06:27,780 --> 00:06:37,660 But whereas if it's a shared resource where the endpoint is shared across customers, that's gonna be limited to C names, name server, MX, those types of records. 52 00:06:37,800 --> 00:06:47,580 And the distinction there is that when the endpoint is shared, suddenly you don't have to worry about the A record pointing at an IP address you no longer control. 53 00:06:48,240 --> 00:06:51,520 So, what can an attacker do with that domain control? 54 00:06:51,660 --> 00:06:56,320 Well, from a high level it can enable phishing, malware distribution, scams, et cetera. 55 00:06:56,320 --> 00:06:58,340 It can lead to cross-site scripting. 56 00:06:58,340 --> 00:07:08,200 Uh, and there's going to be context specific impact, like you can bypass the trusted host names check in a software update installer, that's something I've seen pretty common. 57 00:07:08,200 --> 00:07:14,100 You can abuse the brand trust and reputation in order to spread misinformation. 58 00:07:14,500 --> 00:07:21,180 Now, I included a quote below from APNIC on an article talking about this potential abuse. 59 00:07:21,500 --> 00:07:40,160 So, from a high level, they found that when it came to dangling DNS record abuse, um, in general, 75% of the hijacked dangling resources were being used to, for black hat se- search engine optimization and really promoting bad websites you don't want anyone going to. 60 00:07:43,500 --> 00:07:50,180 So, to be clear, past approaches for these types of bugs already exist. 61 00:07:50,280 --> 00:08:00,960 Where, with dangling cloud resources, you know, we've seen that attackers can go ahead and enumerate cloud IP pools and capture these resources that are dangling. 62 00:08:00,960 --> 00:08:07,520 But, with leaked secrets, what we've seen is that a lot of work really relies on a limited scope. 63 00:08:07,760 --> 00:08:14,880 So, what I mean by that is, everything that happens with leaked secrets is always about a specific target. 64 00:08:14,880 --> 00:08:20,280 Like a specific folder, a specific repository, or a specific directory. 65 00:08:21,020 --> 00:08:34,180 And the problem with this is, to start with dangling resources, some past work includes, you can buy DNS data and then enumerate your cloud provider's IP pool in order to find what's dangling. 66 00:08:34,180 --> 00:08:43,580 So, if I go ahead and create a resource over and over again in a cloud environment, I'll be assigned IP addresses that are not assigned to any other customer. 67 00:08:43,680 --> 00:08:57,040 And if one of these IP addresses matches a DNS record that I've found in DNS data that threat intelligence providers sell, well, that's one way you can capture a dangling DNS record. 68 00:08:57,620 --> 00:09:01,820 And other attempts also include going after a specific target. 69 00:09:01,820 --> 00:09:13,060 So, instead of using DNS data you buy from threat intelligence providers, you'll instead go ahead and enumerate that provider pool, but this time compare against sub-domains you've enumerated for that specific provider. 70 00:09:15,380 --> 00:09:19,480 So, to give you some examples, there's been a lot of work in this area. 71 00:09:19,480 --> 00:09:36,280 Bishop Fox originally came out in 2015 with an article where they used this passive DNS data, or at least a variant of it, in order to enumerate an AWS cloud IP pool and then capture AWS IPs that corresponded to a specific domain they were interested in. 72 00:09:36,360 --> 00:09:40,720 So, in that case they used bing.com to find those dangling DNS records. 73 00:09:41,780 --> 00:09:54,840 Some other work includes flying a false flag from Black Hat, it's a talk, where they used passive DNS data from these threat intelligence providers to determine whether IPs they captured were dangling. 74 00:09:56,160 --> 00:10:02,720 So, this project was again focused on creating these backends for C2 malware platforms. 75 00:10:02,720 --> 00:10:09,160 They wanted to take control of legitimate domains so that they could abuse those domains for a false level of trust. 76 00:10:09,920 --> 00:10:21,260 And one interesting note about this project is that they noted that after releasing it, it would appear that AWS and GCP now assign IPs from a limited pool for your account. 77 00:10:21,260 --> 00:10:27,020 We'll touch on this more later, but this is what we're going to be focusing on when it comes to dangling DNS resources. 78 00:10:27,120 --> 00:10:33,840 The topic is well traversed, but what's not well traversed are the modern deterrents against it and how we can bypass them. 79 00:10:34,780 --> 00:10:43,180 And finally, there's still a lot of work where attackers simply enumerate your domain subdomains and then find IPs that match them. 80 00:10:44,620 --> 00:10:48,320 Now when it comes to leaked secrets, the story's a bit different. 81 00:10:48,340 --> 00:10:52,160 It's not as well traversed as dangling DNS records at all. 82 00:10:52,360 --> 00:10:58,760 So for example, there's tools that you can use to search a Git repository for these secret patterns. 83 00:10:58,900 --> 00:11:08,580 And even GitHub has a system where they'll scan every content, every piece of code uploaded to their platform for these secret patterns. 84 00:11:08,660 --> 00:11:14,540 But the limitation with this work is that it's really a, it's very small scope. 85 00:11:14,540 --> 00:11:17,840 I mean, think about how much code is really going to end up on GitHub. 86 00:11:17,840 --> 00:11:25,680 You know, most enterprises aren't going to put their closed source applications on GitHub where this scanning would occur in the first place. 87 00:11:27,360 --> 00:11:34,500 Now going on to defender approaches to mitigate these vulnerabilities, well, they've been pretty limited as well. 88 00:11:34,640 --> 00:11:39,960 Oftentimes these are treated as customer vulnerabilities, which technically is correct. 89 00:11:39,960 --> 00:11:47,040 If you think about it from a high level, if you leak a secret or leave a DNS record dangling, that is your responsibility. 90 00:11:47,080 --> 00:11:54,440 But what I think that is often missed is the provider's responsibility and how they encourage these insecure defaults. 91 00:11:54,520 --> 00:11:58,540 So for example, tokens are really, really easy to use. 92 00:11:58,740 --> 00:12:03,080 Have you ever thought about how easy it is to use a token in your code? 93 00:12:03,160 --> 00:12:06,020 And that's how it can get leaked in the first place. 94 00:12:06,400 --> 00:12:12,820 Now Fortune 500 companies might have those standard secure development lifecycle practices where they can avoid this. 95 00:12:12,820 --> 00:12:21,380 But in reality, a lot of small to medium sized businesses might not understand this nuance or be able to apply it uniform across their organization. 96 00:12:23,800 --> 00:12:28,320 Now, this is something we're going to talk about later, but I want you to keep it in mind. 97 00:12:28,540 --> 00:12:36,280 Remember, even though it's a cloud customer vulnerability, there's incentives that lead to them being created in the first place. 98 00:12:36,700 --> 00:12:39,900 So let's talk about the traditional security mindset. 99 00:12:40,740 --> 00:12:45,280 Traditional bugs discovery is often centered around a specific target. 100 00:12:45,280 --> 00:12:49,140 You know, if I'm looking for vulnerabilities, I might go reverse engineering an application. 101 00:12:49,340 --> 00:13:01,840 And with dangling domains, one of the earliest approaches was going first, enumerating the subdomains of my target, and then enumerating the cloud provider IP pools in order to identify dangling resources. 102 00:13:02,020 --> 00:13:09,620 Now for secrets, again, we start with a specific target, whether that be a single repository or a single platform like GitHub. 103 00:13:10,220 --> 00:13:18,500 And what I really started to think about as I looked into this further and further was whether there's an opportunity for some vulnerabilities to be approached differently. 104 00:13:18,740 --> 00:13:22,660 For example, were we really facing tunnel vision here? 105 00:13:22,660 --> 00:13:25,900 Why do we need to start with a specific target? 106 00:13:26,320 --> 00:13:34,760 It's almost as if, you know, there is a lack of focus in the industry against finding bugs at scale, and rather finding bugs in individual areas. 107 00:13:34,760 --> 00:13:40,860 And that's what I really wanted to focus on with this research is, can we find these vulnerabilities at scale? 108 00:13:41,600 --> 00:13:49,220 So to expand on this with dangling resources, the traditional mindset might include, start with a target and then capture vulnerable assets. 109 00:13:49,220 --> 00:13:53,960 But as we've seen with past work, it can often be a lot larger than that, too. 110 00:13:53,960 --> 00:14:05,920 For example, the security at scale approach to dangling domains would be to capture dangling assets first, and then check if there's any DNS records still pointing at them using passive DNS replication data. 111 00:14:06,080 --> 00:14:08,680 Now here's where it gets interesting. 112 00:14:08,680 --> 00:14:11,440 For leaked secrets, there's no such equivalent. 113 00:14:12,000 --> 00:14:23,780 You know, we have approaches to scan limited scopes for these secret patterns, but when it comes to that security at scale mindset, it still goes around a very limited target. 114 00:14:23,780 --> 00:14:33,260 You know, we start with a repository, a folder, a file, instead of starting with a diverse data source that allows us to look for these secrets in a broad manner. 115 00:14:37,380 --> 00:14:46,680 So this is what I really want you to take away from this talk from a high level, is that there's an untapped potential to use unconventional data sources to find these vulnerabilities. 116 00:14:46,980 --> 00:14:59,580 We're about to go through some examples, but what I really want you to think about is not just, you know, here's how Bill applied it to dangling domains and leaked secrets, but rather how you can apply it to other types of vulnerability classes as well. 117 00:14:59,600 --> 00:15:02,480 This is not just about these two vulnerability classes. 118 00:15:02,480 --> 00:15:06,460 These two vulnerability classes are examples that you can apply to your own work. 119 00:15:08,240 --> 00:15:11,840 So let's talk about how we would actually implement this in practice. 120 00:15:12,200 --> 00:15:16,220 From a high level, we start with the vulnerability, not the target. 121 00:15:16,500 --> 00:15:19,980 So and then we work backwards by using creative data sources. 122 00:15:20,320 --> 00:15:23,860 Remember, for dangling resources, we already have a playbook. 123 00:15:23,860 --> 00:15:31,000 You can, you know a dang, a DNS record is dangling if it points at an IP address that the customer no longer controls. 124 00:15:31,080 --> 00:15:34,760 How do you know if an IP is no longer controlled by a customer? 125 00:15:34,760 --> 00:15:45,020 Well, we can enumerate the cloud IP pool and determine every IP that we get in our attacker account is likely something that no other customer controls because that IP is assigned to us. 126 00:15:45,020 --> 00:15:46,880 But how do we know if it's dangling? 127 00:15:46,880 --> 00:15:49,680 Well again, that passive DNS replication data. 128 00:15:49,680 --> 00:15:59,960 And if you're not familiar with this, how it works is that threat intelligence providers from DNS, will work with DNS providers to sell this aggregate DNS traffic data. 129 00:15:59,960 --> 00:16:07,620 For example, you can give these threat intel providers an IP address and they'll give you every single DNS record that points at it. 130 00:16:09,500 --> 00:16:15,420 Now again, we can capture assets first with DNS records instead of starting with a target. 131 00:16:15,420 --> 00:16:24,680 What we'll do is we'll go through a cloud provider pool and we'll go and enumerate every IP address that we're able to get and look for DNS records that point at it. 132 00:16:24,760 --> 00:16:32,180 What we're going to do in the next section is apply this generic technique we've seen in past work against modern deterrence. 133 00:16:33,660 --> 00:16:35,500 But what about secret scanning? 134 00:16:35,500 --> 00:16:36,600 So this is the interesting one. 135 00:16:36,600 --> 00:16:40,600 This is one that we still have a lot of research to do in. 136 00:16:40,680 --> 00:16:44,820 We have passive DNS replication data for dangling resources. 137 00:16:45,180 --> 00:16:46,660 But what about leaked secrets? 138 00:16:46,920 --> 00:17:03,720 From a high level, the ideal data source needs to be diverse, needs to be sufficient in volume, and it needs to include a diverse set of websites, executables, you know, not just open source applications, but we need to include closed source applications too. 139 00:17:04,160 --> 00:17:07,400 And we need to make sure that this is done in a feasible way. 140 00:17:07,400 --> 00:17:15,040 For example, even if we have a large data set of these files, we need to make sure we can scan it in a practical manner. 141 00:17:15,680 --> 00:17:19,240 So where can we find this large collection of apps and scripts? 142 00:17:20,080 --> 00:17:23,840 So what about virus scanning platforms? 143 00:17:24,900 --> 00:17:27,440 This is where it's going to get really interesting. 144 00:17:27,500 --> 00:17:34,820 So what we've seen with past work is a lot of people focusing on these platforms with limited diversity. 145 00:17:35,360 --> 00:17:42,420 You know, we look at GitHub, it's really going to only be open source repositories that are being scanned and automatically revoking keys. 146 00:17:42,560 --> 00:17:49,760 You know, we look at these tools, they all focus on scanning individual targets, like folders, specific repos, etc. 147 00:17:49,940 --> 00:17:52,660 But what we're missing is that diverse data source. 148 00:17:52,660 --> 00:17:55,400 And that's what I really focused on in this research. 149 00:17:55,420 --> 00:18:00,680 What I found was that virus scanning platforms were actually a really interesting target. 150 00:18:00,680 --> 00:18:05,860 Because think about it, think about all the stuff that people upload to virus scanning platforms. 151 00:18:06,160 --> 00:18:16,900 You know, think about all the websites that are automatically scanned, all the applications, all the mobile apps that are included in this virus total data source, and as well as other platforms. 152 00:18:17,780 --> 00:18:27,840 Now, with these scanning platforms, it'd be infeasible to go ahead and, you know, download what, a billion, nine billion files, and each scan each of them individually. 153 00:18:27,840 --> 00:18:32,340 But we don't need to do that, because we can use the tools that they already provide us. 154 00:18:32,360 --> 00:18:42,720 Nearly every virus scanning platform lets you search for specific patterns, specific strings, like they're literally spoon feeding us the perfect data source here. 155 00:18:42,720 --> 00:18:48,580 And traditionally, what we've used this data source for is to find malware, you know, find malicious use, etc. 156 00:18:48,580 --> 00:18:55,240 But what's really interesting about them is that, what if we use secret patterns instead of malicious patterns? 157 00:18:55,240 --> 00:18:58,740 What if instead of looking for malware, we look for secrets instead? 158 00:18:59,860 --> 00:19:11,100 And with virus total, this is retro hunt, but seriously, if you look at nearly every other virus scanning platform, what you'll find is that they have a similar future, um, at least if you have an account. 159 00:19:12,200 --> 00:19:14,440 So, let's apply this in practice. 160 00:19:17,290 --> 00:19:20,730 So with secret split scanning, the plan is from a high level. 161 00:19:20,730 --> 00:19:28,310 We want to make sure that we look for secret patterns, and what that really means is, think about your AWS access key. 162 00:19:28,310 --> 00:19:32,170 I don't know if you've noticed, but it'll often start with A-K-I-A. 163 00:19:32,170 --> 00:19:42,550 And what we can do is we can create these regex strings for identifying these secrets, and we can look for them using the same tools we have available for malware hunting. 164 00:19:42,710 --> 00:19:46,710 So, most virus platforms allow you to search by a Yara rule. 165 00:19:46,730 --> 00:19:57,310 And so what we can do is we can create a Yara rule for these secret patterns, and then we can search samples uploaded to the platform for whether these patterns exist in them. 166 00:19:57,450 --> 00:20:02,690 Now, one thing interesting that I did in this research was also focused on validating these secrets. 167 00:20:02,690 --> 00:20:16,450 So, I've looked at a lot of past work into leaked secrets, and what I've found is, there's a lot of theoretical research that discusses things like, oh, we looked for these secret patterns, and, you know, we found these unique keys, but you read into it a little deeper, 168 00:20:16,450 --> 00:20:18,850 and they didn't even check if those keys are legitimate. 169 00:20:19,070 --> 00:20:21,370 And that's something that didn't really make sense to me. 170 00:20:21,370 --> 00:20:28,750 There's going to be thousands and thousands and tens of thousands of keys that match a specific pattern, but are not active in practice. 171 00:20:28,930 --> 00:20:39,070 And so what we did was that I used a platform to actually validate these keys, at least with basic metadata, and validate that they're legitimate for our use case. 172 00:20:39,270 --> 00:20:52,950 Now, some patterns are going to be really noisy, but if the provider doesn't make it easy to identify their secrets, you're going to find that you're going to have to scan thousands and thousands of secret patterns and thousands of thousands of files. 173 00:20:53,110 --> 00:20:55,850 So, how do we deal with this large volume? 174 00:20:55,870 --> 00:21:02,290 Well, what I did to do it on my budget, remember, I'm doing this everything out of pocket, was leverage serverless computing. 175 00:21:02,370 --> 00:21:11,530 So, I needed a capacity of having several physical server racks, but I don't have money to buy several physical server racks. 176 00:21:11,530 --> 00:21:24,490 Instead, I can rent them using the cloud, and what that really means is I made a serverless function in order to scan these files, and I also made a serverless function to validate the keys that were found. 177 00:21:24,690 --> 00:21:29,830 And this way, I don't actually have to pay that much, because I only pay for what I use. 178 00:21:29,830 --> 00:21:34,090 In practice, my costs were actually fairly reasonable for an individual. 179 00:21:35,230 --> 00:21:46,750 Now, for dangling resources, again, the methodology from a high level was to reallocate resources over and over and over again, and then it was to cross check them with passive DNS replication data. 180 00:21:46,850 --> 00:21:55,810 Remember, this isn't necessarily new, but what's interesting about them is that we're going to be talking about bypassing modern deterrents. 181 00:21:55,810 --> 00:22:05,550 And what I mean by that is a lot of cloud providers have implemented these mitigations to make it harder to do this dangling DNS record enumeration, and we're going to bypass them. 182 00:22:06,910 --> 00:22:11,690 So, from a high level, one thing I want to call out is that earlier note. 183 00:22:11,690 --> 00:22:20,950 Remember, it would appear that AWS began serving Elastic IPs from a small, specific pool similar to GCP. 184 00:22:21,110 --> 00:22:24,870 This severely limits the diversity of addresses received. 185 00:22:25,010 --> 00:22:27,810 And so, let me tell you what this really means in practice. 186 00:22:28,110 --> 00:22:53,750 So, what's going on here is that AWS and GCP have a mitigation where when you are asked to assign me an IP address, whether that be an Elastic IP or in GCP case, nearly every resource that you can go ahead and allocate that needs an IP, these cloud providers will only give you a specific set of IPs assigned to a shared pool that's limited to your account and maybe a few others. 187 00:22:54,410 --> 00:22:58,670 And for AWS, this is going to be largely Elastic IP sharing. 188 00:22:58,730 --> 00:23:08,450 So, that means whenever you ask for a dedicated Elastic IP, you'll notice if you free an Elastic IP and allocate another one, you're going to be assigned the same one over and over again. 189 00:23:08,450 --> 00:23:09,610 Or in general. 190 00:23:09,610 --> 00:23:13,390 It's really hard to actually enumerate that pool using Elastic IPs alone. 191 00:23:14,370 --> 00:23:29,890 Now, with AWS, they also introduced a mitigation, I don't know if intentionally to go against dangling DNS enumeration, but they did introduce a mitigation in 2024 where every IP address you received was actually had an increased surcharge . 192 00:23:29,890 --> 00:23:33,350 So, now every IP you got allocated cost you extra money. 193 00:23:33,350 --> 00:23:41,030 And this deters attacks by making it more expensive to enumerate their public IP pools and capture these dangling DNS records . 194 00:23:42,950 --> 00:23:45,530 Now for Google Cloud, it's interesting. 195 00:23:45,530 --> 00:23:48,070 They actually had quite a lot more than I expected. 196 00:23:48,130 --> 00:23:55,310 So, for project levels, so every account can have about 15, 10 to 15 projects assigned to them by default. 197 00:23:55,310 --> 00:23:57,810 You can request an increase, but you need justification. 198 00:23:58,170 --> 00:24:01,890 Now, IPs are again assigned from a small pool just like AWS. 199 00:24:02,210 --> 00:24:07,030 You only have 8 IPs you can use by default in per region and globally. 200 00:24:07,670 --> 00:24:12,230 And with these accounts, you also had something called a billing account restriction. 201 00:24:12,330 --> 00:24:17,330 So, with Google Cloud, every credit card can be created into a billing account. 202 00:24:17,330 --> 00:24:31,790 Now, you can create a few billing accounts based off of one credit card, but if you try to create more than a few, you'll automatically hit their suspension and you'll have to go justify why are you creating a 50th, you know, credit card account or billing account with one credit card. 203 00:24:32,030 --> 00:24:38,170 And so, all these deterrents really make it difficult for attackers to enumerate these dangling domains. 204 00:24:38,250 --> 00:24:53,070 In fact, with Google Cloud, while managed DNS enumeration was always a thing and has been for the past few years, attackers haven't been able to enumerate Google Cloud's public IP pools for quite some time, at least none researched that I could find online. 205 00:24:54,810 --> 00:24:58,950 So, with those AWS mitigations, they're actually pretty simple to bypass. 206 00:24:59,070 --> 00:25:09,590 Instead of allocating elastic IPs, we can just restart EC2 instances with ephemeral IPs and we can perform the enumeration by just restarting, restarting, restarting. 207 00:25:09,590 --> 00:25:20,630 And my IP address that my EC2 instance is assigned will generally rotate a lot faster through unique IPs than if you tried with elastic IPs. 208 00:25:20,630 --> 00:25:29,670 In fact, um, I actually was able to enumerate nearly 2.4 million unique IP addresses in a span of 6 months by using this methodology. 209 00:25:29,870 --> 00:25:37,830 Now, with Google Cloud, again, they had a harder set of mitigations, but they, those mitigations were deterrents. 210 00:25:37,970 --> 00:25:45,490 So, how it worked was that I used a backend bucket with a load balancer in order to assign IP addresses to my resources. 211 00:25:45,490 --> 00:25:49,490 But this still didn't let me get past these cloud resource restrictions. 212 00:25:49,490 --> 00:25:50,850 How do we do that? 213 00:25:50,950 --> 00:25:57,030 Well, once we have this primitive for enumerating cloud IPs, we can talk about those limitations. 214 00:25:57,030 --> 00:26:04,650 But for high level information, we used forwarding rules instead of virtual machines in order to enumerate these IPs. 215 00:26:05,870 --> 00:26:09,130 So, with Google Cloud, remember all those restrictions? 216 00:26:09,130 --> 00:26:12,190 Well, we can actually bypass all of them fairly cheaply. 217 00:26:12,830 --> 00:26:19,430 So, number one, with a billing account, one interesting thing I found was that you can assign billing accounts across Google accounts. 218 00:26:19,610 --> 00:26:25,930 This was a useful primitive where if I could create a billing account in one account, I can actually assign it across several accounts. 219 00:26:25,930 --> 00:26:29,550 And the reason this is interesting is, well, what about those quotas? 220 00:26:29,870 --> 00:26:34,010 Well, with account quotas, remember you can only create a certain amount of projects. 221 00:26:34,010 --> 00:26:39,010 Now, again, you can request an increase in this limit, but you don't want to have to do this justification. 222 00:26:39,050 --> 00:26:43,250 I felt that it would be inappropriate to assume that an attacker would be able to get this quota increase. 223 00:26:43,390 --> 00:26:46,910 What I found was, though, you can create a Google Workspace environment. 224 00:26:46,910 --> 00:27:00,230 So, what that means is I can create a fakebusiness.com, I can create Google Workspace environment for it, and I can create practically as many Google accounts as I want for about $6 per account per month. 225 00:27:00,230 --> 00:27:09,310 And this way, each of those accounts gets a dedicated quota limit and allows you to bypass these quota limits by creating, for example, 10 accounts. 226 00:27:09,310 --> 00:27:13,710 Now that's $60, but now your quota has been 10-timed. 227 00:27:13,710 --> 00:27:22,330 And finally, to bypass billing account restrictions, remember those credit card restrictions, billing accounts can only be associated with a certain number of projects. 228 00:27:22,330 --> 00:27:25,490 Well, we can instead then use virtual credit cards. 229 00:27:25,490 --> 00:27:27,110 And I use privacy.com. 230 00:27:27,110 --> 00:27:30,930 That's not a recommendation, it's just one of the easiest that worked for me. 231 00:27:30,990 --> 00:27:47,690 And what really this means is, it's not like they're bypassing KYC practices, they verified my identity, but it still allows me to create as many credit card numbers as I want and be able to create as many billing accounts as I want to be able to bypass every single restriction we discussed with Google Cloud. 232 00:27:48,050 --> 00:28:06,790 And so this is what I really want to mention from a high level, is Google Cloud implemented all these deterrents to try to make sure you can't enumerate their dangling IPs, but in practice, these deterrents weren't addressing the root cause, which was the fact that the dangling IPs still existed in the first place. 233 00:28:10,980 --> 00:28:18,380 So let's talk about a little bit of the discovery process and what I was able to find with these techniques. 234 00:28:19,640 --> 00:28:26,960 So with dangling resources, I was able to enumerate over 2 million IP addresses for Google Cloud and AWS. 235 00:28:27,020 --> 00:28:31,520 These are unique IP addresses and they're mostly primitive resources. 236 00:28:31,600 --> 00:28:40,100 So these IPs were created by, remember, restarting an EC2 instance or creating forwarding rules over and over again. 237 00:28:40,260 --> 00:28:50,160 As far as I'm aware, this is one of the first methodologies to successfully bypass every single Google Cloud deterrent that is intended to stop this type of attack in the first place. 238 00:28:50,320 --> 00:28:55,480 I captured over 60,000 unique fully qualified domain names. 239 00:28:55,740 --> 00:29:06,880 And this reflects past research into this area where researchers found that these FQDNs, there are a lot of different A records that pointed at IPs that were no longer being controlled. 240 00:29:07,380 --> 00:29:13,840 Now out of these 60,000 FQDNs, there are about 54,000 unique second level domains. 241 00:29:13,840 --> 00:29:23,420 And what that really means is that once you take away the subdomain, let's say A.B.com, we're just focusing on the unique number of Apex or second level domains. 242 00:29:23,500 --> 00:29:26,080 Well, that was over 54,000. 243 00:29:26,560 --> 00:29:35,520 And finally, one of- over 5,000 of the domains that I was able to capture included- were included in the Tranco top 1 million list. 244 00:29:35,520 --> 00:29:49,120 So Tranco is a listing of every domain that they're aware of within a certain ranking and it allows you to compare what- it's supposed to be an objective metric for a ranking of a domain based on DNS data. 245 00:29:49,260 --> 00:30:02,600 Now, there are a lot of Fortune 500 companies impacted and what I found really interesting was that with AWS, we had a roughly 25- a rate of 25 dangling domains per 1,000 IPs. 246 00:30:02,600 --> 00:30:06,400 But with Google Cloud, it was nearly 36. 247 00:30:06,500 --> 00:30:15,700 And so what I suspect this discrepancy is as a result of is that Google Cloud hasn't been able to be enumerated for quite a few years. 248 00:30:17,620 --> 00:30:25,720 Now, this talk isn't going to focus on the actual impact against customers because I promised DEF CON review board I wouldn't get stuck on it. 249 00:30:25,720 --> 00:30:40,780 But you can see that I was able to compromise some of the world's largest organizations including the Western District Court of Texas, um, the New York Times, uh, the California- State Government of California, and Dior. 250 00:30:41,020 --> 00:30:43,460 And, um, yeah, it was a pretty fun time. 251 00:30:43,460 --> 00:30:44,920 There was a lot more examples here. 252 00:30:44,920 --> 00:30:47,240 Again, this isn't intended to cover it. 253 00:30:47,240 --> 00:30:49,700 That's, uh, on a separate blog post as well. 254 00:30:49,700 --> 00:30:51,740 I really go into detail about the impact. 255 00:30:52,220 --> 00:31:03,400 And for a secret scanning, again, what was really interesting was that I scanned over 5 million unique files for- from various platforms , not just VirusTotal, that was just one of them. 256 00:31:03,400 --> 00:31:07,460 Um, and I discovered over 15,000 validated secrets. 257 00:31:07,460 --> 00:31:26,480 And out of these secrets, they included over 2,500 unique, again, validated, these aren't just, you know, may match a pattern, these are validated, to over 2,500 validated secrets, over 2,400 unique AWS keys, over 2,200 GitHub personal access tokens and fine-grain tokens, 258 00:31:26,480 --> 00:31:39,260 over 600 Google's cloud service accounts, over 460 Stripe accounts, and the rest are largely from miscellaneous providers added up together that I didn't feel the need to include in this slide. 259 00:31:40,560 --> 00:31:40,700 And, 260 00:31:47,830 --> 00:31:56,930 and again, there will be a blog to recap this, but from a high level, it's some of the largest organizations in the world were impacted. 261 00:31:56,950 --> 00:32:06,610 You know, just a fun example a few months ago was Slack, Stanford's entire Slack workspace, um, Samsung's workspace for Bixby. 262 00:32:06,610 --> 00:32:20,370 I was able to get a bot token for this Samsung Bixby tenant and, which allowed me to read messages from nearly every channel, every single channel that the bot had access to because of a default scope that was quite broad. 263 00:32:20,370 --> 00:32:35,190 You know, some other interesting things included the Supreme Court of Nebraska, that was a fun one, where they uploaded a password list to VirusTotal with like 300 credentials from different, like, I don't know, different AWS providers, different cloud providers, 264 00:32:35,190 --> 00:32:37,230 their security solutions, et cetera. 265 00:32:37,230 --> 00:32:38,750 That was a really fun one. 266 00:32:38,870 --> 00:32:44,690 Um, you know, there are database backups with a lot of these AWS keys that had broad access to S3 buckets. 267 00:32:44,730 --> 00:32:48,630 Anyways, you'll be able to read a lot more about this this following week. 268 00:32:49,210 --> 00:32:57,330 So by leveraging a security at scale mindset, we can help protect thousands of organizations far beyond a limited scope. 269 00:32:57,710 --> 00:33:08,610 Remember, instead of starting with a specific target, by starting with a diverse dataset, we were able to have a much wider impact than any of past work into leaked secrets. 270 00:33:08,890 --> 00:33:16,790 You can read more about some of this impact in an, in an article that should be released right now, uh, by Matt Burgess from Wired. 271 00:33:16,790 --> 00:33:25,690 And I'll be releasing a detailed technical blog later this week once I figure out whether a certain cloud provider can actually revoke some of these keys or not. 272 00:33:27,250 --> 00:33:29,730 So, bringing it all together. 273 00:33:32,530 --> 00:33:36,130 Hardcoding, hardcoding secrets is the path of least resistance. 274 00:33:36,130 --> 00:33:43,530 So remember, these are customer vulnerabilities, but what enables them is these bad incentives. 275 00:33:43,990 --> 00:33:53,850 Think about it, think about how easy it is to go ahead and generate an AWS access key or generate a Google Cloud service account and then put that into your executable directly. 276 00:33:53,850 --> 00:34:00,270 You know, the libraries for these different providers allow this direct interface in the first place. 277 00:34:01,130 --> 00:34:07,110 Now, the reason this is really important is because a lot of developers are going to follow the path of least resistance. 278 00:34:07,570 --> 00:34:10,630 Especially from smaller to mid-cap businesses. 279 00:34:11,190 --> 00:34:14,630 And with dangling DNS records, the same problem exists. 280 00:34:14,730 --> 00:34:16,870 It's the path of least resistance. 281 00:34:16,970 --> 00:34:28,850 I created an AWS EC2 instance, I put my DNS record pointing at that AWS EC2 instance, and the path of least resistance is leaving that DNS record even if I deallocate it. 282 00:34:29,250 --> 00:34:35,950 And what I think we need to really focus on is making sure that the path of least resistance is the secure path. 283 00:34:36,070 --> 00:34:44,930 And what this really means is with dangling resources, I think we need to have better ownership of cloud resources and DNS records. 284 00:34:44,930 --> 00:34:46,570 Better association. 285 00:34:46,790 --> 00:34:55,510 So for example, some cloud providers have tried to associate their DNS services with their EC2 resources as one example. 286 00:34:55,670 --> 00:35:01,770 Um, and the problem with this is a lot of different customers are going to use different DNS providers, different cloud providers. 287 00:35:01,770 --> 00:35:09,890 What we really need is an industry wide solution of tracking DNS records and tracking cloud resources and putting them together. 288 00:35:12,580 --> 00:35:22,120 Now, for hard coded secrets, what I really think we need to focus on is making sure that it's hard to include secrets in your code. 289 00:35:22,120 --> 00:35:27,980 So don't have short access tokens that your library just blindly accepts from a string . 290 00:35:30,530 --> 00:35:32,670 But instead, for- 291 00:35:47,290 --> 00:35:50,010 alright, thank you for that. 292 00:35:50,010 --> 00:35:51,830 That was a nice wake up call. 293 00:35:51,990 --> 00:35:54,430 Um, alright. 294 00:35:54,430 --> 00:36:05,750 Uh, anyways, so yeah, with these hard coded secrets, what I really think we need to do is make sure to limit the secrets so that they can only be inserted from an environment or from a file on disk. 295 00:36:05,750 --> 00:36:10,110 And make it hard to hard code these secrets inside of an executable in the first place. 296 00:36:10,110 --> 00:36:15,470 Now again, you can have exceptions, you know, you can have it so a customer can opt out from the secure default. 297 00:36:15,710 --> 00:36:19,990 But we need to make sure that the secret default is secure. 298 00:36:21,670 --> 00:36:25,070 So what about remediating these vulnerabilities? 299 00:36:25,550 --> 00:36:35,410 Well, remember, for dangling records at a high level, it's going to be hard to contact every single host of every 60,000 dangling domain that I was able to discover. 300 00:36:35,430 --> 00:36:39,310 What we really need is a way to tie ownership to DNS records. 301 00:36:39,310 --> 00:36:43,710 And we need to do this across the industry because of that multi-cloud approach. 302 00:36:45,370 --> 00:36:49,590 Now for secrets, this is where it gets really interesting. 303 00:36:49,590 --> 00:37:00,910 So I went ahead and asked a bunch of organizations that I found secrets for, including GitHub, including AWS, including OpenAI, whether I could report secrets to them and they could revoke them automatically. 304 00:37:00,950 --> 00:37:05,710 Now GitHub has that program for scanning secrets on their platform already. 305 00:37:05,710 --> 00:37:14,910 Remember, if you actually go ahead and post a, for example, OpenAI access key on a public repository, that access key will be revoked within a few minutes. 306 00:37:15,430 --> 00:37:20,150 And what I was curious was, hey GitHub, can I please use this mechanism you already have? 307 00:37:20,150 --> 00:37:22,370 Well, unfortunately they said no. 308 00:37:22,670 --> 00:37:38,070 And in fact, several providers said no, like AWS, despite the fact that they already had given this mechanism to GitHub and despite the fact that an attacker could access the mechanism by posting a public git or public commit. 309 00:37:38,130 --> 00:37:49,290 Now one exception to this was OpenAI, who immediately responded with an endpoint for reporting these keys and allowed me to automatically revoke the keys that I discovered in the wild. 310 00:37:49,590 --> 00:37:51,790 But what do we do about everyone else? 311 00:37:52,230 --> 00:37:59,490 So the problem with these secret keys is that the impact is far, far, far greater than dangling DNS records. 312 00:37:59,490 --> 00:38:04,810 In fact, we just saw some of the world's largest organizations and there were several more impacted. 313 00:38:04,950 --> 00:38:12,150 I didn't feel comfortable releasing this work without at least some stopgap until these cloud providers could take the secure default. 314 00:38:12,630 --> 00:38:24,730 So what I actually did was I developed a mechanism that used GitHub's mechanism anyway for revoking these secrets, because they said no, but I don't care. 315 00:38:25,410 --> 00:38:33,510 But yeah, so what I did was I have this system now where whenever new secrets are discovered, I'll go ahead and create a gist. 316 00:38:33,510 --> 00:38:43,210 And the way I create this gist is by automating the entire GitHub login process and then just using a UI endpoint for creating a public gist. 317 00:38:43,210 --> 00:38:50,010 And this way it'll actually trigger the GitHub secret scanning mechanism that they could have given me direct access to anyway. 318 00:38:50,010 --> 00:38:51,690 So yeah, anyways. 319 00:38:56,900 --> 00:39:04,740 Now what's really cool about this is that every, almost every secret that you saw listed in the previous section, a lot of them are going to be revoked. 320 00:39:04,880 --> 00:39:06,860 There's an exception to that though. 321 00:39:06,860 --> 00:39:10,560 One of the largest providers which did have leaked secrets was AWS. 322 00:39:10,580 --> 00:39:13,400 Now AWS takes an interesting approach. 323 00:39:13,400 --> 00:39:26,000 When you post your AWS access key on a public GitHub commit or post, what they do is that they'll create a support case for you and restrict write access using that key. 324 00:39:26,000 --> 00:39:27,160 I found that kind of interesting. 325 00:39:27,160 --> 00:39:34,860 So what's really happening is AWS is aware of these secret keys, but they're choosing not to revoke them for some reason. 326 00:39:35,320 --> 00:39:37,340 Yeah, that's an interesting one. 327 00:39:37,340 --> 00:39:49,260 So effectively if you find a leaked AWS access key on GitHub, you can still use that key to read S3 buckets, read RDS database data, to read download files from S3. 328 00:39:49,260 --> 00:40:00,580 You know, I remember I looked at a AWS key last weekend for a casino that was alleged to deal with over $1 billion of bets a month. 329 00:40:00,620 --> 00:40:03,260 And I was like, okay, wait a minute, was this reported? 330 00:40:03,260 --> 00:40:04,720 We should get this revoked. 331 00:40:04,720 --> 00:40:09,160 But in reality what happened was AWS created this support case. 332 00:40:09,160 --> 00:40:15,320 The customer never saw it because the support email was sent to their generic billing account. 333 00:40:15,320 --> 00:40:22,040 You know, a lot of people, a lot of enterprises set up an AWS account and use a generic billing email that no one really looks at. 334 00:40:22,040 --> 00:40:25,860 And so the support case was ignored and this key is still active today. 335 00:40:25,880 --> 00:40:30,060 You know, it's disappointing because I don't know what more I can do for my shoes. 336 00:40:30,060 --> 00:40:38,040 You know, I've created a mechanism that can help automatically revoke most of these keys, but what do we do about keys that the provider doesn't take action on? 337 00:40:38,220 --> 00:40:50,640 And so this is where I really think providers need to switch up is, number one, if someone's secret key, you have both components, is on the internet and you know about it, you need to revoke that immediately. 338 00:40:51,180 --> 00:40:57,280 I mean, it's crazy to me to think that even on GitHub, if you post your AWS access key, that's not going to be automatically revoked. 339 00:40:57,280 --> 00:41:00,240 Every other provider I looked at does automatically revoke. 340 00:41:00,240 --> 00:41:03,880 Google Cloud revokes, Slack revokes, OpenAI revokes. 341 00:41:03,900 --> 00:41:07,240 The largest cloud provider by market share does not revoke. 342 00:41:10,340 --> 00:41:19,320 Now, if you're interested in starting this sort of research yourself, what I'd focus on is breaking down the traditional methods of finding vulnerabilities. 343 00:41:19,320 --> 00:41:26,300 So with dangling domains, that was checking if the DNS record is actually pointing at a uncaptured IP address. 344 00:41:26,560 --> 00:41:32,940 And with secrets, it was trying to find those secret patterns in a diverse data source. 345 00:41:32,940 --> 00:41:42,680 So in this case, we used virus scanning platforms, but you can use a similar methodology against a lot , a larger set of vulnerability classes. 346 00:41:43,180 --> 00:41:49,680 And what you really want to do is correlate those steps with these large data sets, regardless of their intended usage. 347 00:41:51,020 --> 00:41:53,220 Thank you so much for coming out to this talk. 348 00:41:53,380 --> 00:41:54,700 What a fun time. 349 00:42:00,780 --> 00:42:03,060 We do have a few minutes for questions. 350 00:42:05,220 --> 00:42:07,380 Oh, we apparently don't have microphones. 351 00:42:08,260 --> 00:42:10,560 All right, yeah. 352 00:42:10,560 --> 00:42:14,460 If you have questions, feel free to come up and we can have a chat over on stage. 353 00:42:14,460 --> 00:42:16,420 Thank you so much for coming out to this talk. 354 00:42:16,420 --> 00:42:17,420 What a fun time. 355 00:42:17,420 --> 00:42:21,280 And yeah, I look forward to working with these providers to address these vulnerabilities.