[00:05.970 --> 00:11.510] Alright everyone, thank you so much for coming out to this talk. It's called Secrets and Shadows, [00:11.510 --> 00:17.230] Leveraging Big Data for Vulnerability Discovery at Scale. I'm so excited to be here for another year [00:17.230 --> 00:23.730] at another DEF CON, and I really do have something in store for you today. Let's get right into it. [00:26.700 --> 00:32.420] So, just a disclaimer, everything we're going to talk about today was done completely independent of [00:32.420 --> 00:39.880] my employer, outside of work, with my own money, my own resources. If you want to talk about this work [00:39.880 --> 00:44.560] outside of this presentation, just please refer to me as an independent security researcher. [00:44.560 --> 00:48.020] It helps me be able to do work just like this. [00:51.330 --> 00:58.130] So, my name is Bill Demerkappa, and I'm a security researcher with a diverse background in low-level [00:58.130 --> 01:01.650] software security, and also cloud security. [01:05.610 --> 01:13.090] I'm interested in defense and offense. I love solving hard security problems, and while I did start with a [01:13.090 --> 01:19.570] software security background, I feel like the impact we can have with cloud security is much wider. [01:19.570 --> 01:24.890] For example, you could have the most complex software vulnerability in the world, but at the end of the day, [01:25.030 --> 01:32.010] a simple missing ID check in a cloud environment can lead to a much broader impact. [01:32.010 --> 01:38.510] And that's what really got me interested in the cloud. It's the ability to have an impact without the same [01:38.510 --> 01:43.230] technical complexity that comes with exploiting low-level vulnerabilities. [01:45.270 --> 01:51.350] So, in this talk, we're going to discuss vulnerability discovery at scale. [01:51.350 --> 01:56.570] And what I mean by that is, we're going to take a look at how we traditionally approach vulnerability discovery [01:56.570 --> 02:02.950] with two common bug classes, dangling cloud resources and leaked secrets. [02:02.950 --> 02:09.890] The goal is to identify the limitations of our historical approach and shift our perspective through some [02:09.890 --> 02:16.700] practical examples. So, some background. [02:18.500 --> 02:24.740] Now, from a high level, everyone knows what cloud computing is. It's basically a way where you can create [02:24.740 --> 02:31.040] infrastructure, like servers, websites, and more, without needing to actually purchase your own physical [02:31.040 --> 02:37.980] server rack. The cool part is, this can save you a lot of money. If you're just creating your own blog, [02:37.980 --> 02:43.480] you really don't need that many resources at all. Why not borrow someone else's? [02:43.480 --> 02:49.620] And that's really the fundamental principle of cloud computing. All you're doing is borrowing from someone [02:49.620 --> 02:59.900] else's pool of shared resources. So, cloud environments are managed over the Internet. [02:59.900 --> 03:06.820] But how do we actually secure this access? Well, for AWS, the way it works is that you can use something [03:06.820 --> 03:13.800] called an access key. An access key can be short-lived or a long-term token that specifies credentials [03:13.800 --> 03:19.640] for your account and allows you to manage your AWS resources, depending on the role and permissions [03:19.640 --> 03:25.280] assigned to you. Can we please increase the microphone sound? [03:25.900 --> 03:33.000] And for other platforms, it's similar. For example, for Google Cloud, the types of authentication include [03:33.000 --> 03:41.060] service accounts, you can use CLI credentials, and in general, tokens are how we're able to operate with [03:41.060 --> 03:47.600] these cloud environments. Unfortunately, tokens also present a pretty severe risk. [03:49.380 --> 03:55.860] So, cloud provider tokens are dangerous because, by default, little restriction, there's little restriction [03:55.860 --> 04:04.080] on who can use those tokens. For example, by default, if you create a root access key in AWS, anyone from [04:04.080 --> 04:11.180] any IP can use that access key to manage your cloud environment. Now, obviously, the impact of a leaked [04:11.180 --> 04:17.940] cloud credential will really depend on the context. For example, a lot of websites hard-code a Google Maps [04:17.940 --> 04:25.400] API key, and in reality, despite the fact that it can lead to billing overcharges and abuse, the impact is [04:25.400 --> 04:34.380] still fairly limited. But with a root AWS key, the dangers are much more problematic. For example, if you [04:34.380 --> 04:41.300] stored your database in AWS, or you store your computing in AWS, an attacker could use your credentials [04:41.300 --> 04:50.400] to not only access customer data, but to interfere with your production workflows. Now, when we talk [04:50.400 --> 04:57.660] about how everything in the cloud is shared and borrowed, what I mean by that is, by nature, by its nature, [04:57.660 --> 05:04.840] the cloud model introduces risk from this sharing model. So, for example, when you create a virtual machine, [05:04.840 --> 05:10.800] what's really happening is you're borrowing time on a physical server that your cloud provider has bought. [05:11.100 --> 05:18.400] And on this physical resource, you get assigned a network IP, for example. And the reason this is dangerous [05:18.400 --> 05:25.780] is because once you're done with a resource, if you still have dangling DNS records pointing at that resource, [05:25.780 --> 05:33.400] suddenly that exposes an opportunity for an attacker to take advantage of. So, from a high level, I view [05:33.400 --> 05:40.060] cloud resources in two categories. Primitive resources and shared resources. So, a primitive resource is [05:40.060 --> 05:46.400] something like a virtual machine where you get assigned a dedicated IP address. That IP address is not used by any [05:46.400 --> 05:52.780] other customer but you. Whereas with a shared resource, what's really going on is it's a serverless application [05:53.320 --> 05:59.500] that serves multiple customers. For example, if you have a serverless function that you can call on your [05:59.500 --> 06:06.280] cloud provider, that URL you use to connect to that serverless function probably corresponds to an IP that [06:06.280 --> 06:13.400] serves a lot of other customers. The reason this distinction is important is because it impacts what type of [06:13.400 --> 06:19.040] dangling DNS records you need to worry about. So, for primitive resources where you have that unique IP [06:19.040 --> 06:25.340] address, that includes pretty much every type of DNS record that could be dangling, like an A record, a C name [06:25.340 --> 06:31.320] record, a name server, and et cetera. But whereas if it's a shared resource where the endpoint is shared [06:31.320 --> 06:38.280] across customers, that's gonna be limited to C names, name server, MX, those types of records. And the [06:38.280 --> 06:44.100] distinction there is that when the endpoint is shared, suddenly you don't have to worry about the A record [06:44.100 --> 06:51.520] pointing at an IP address you no longer control. So, what can an attacker do with that domain control? [06:51.660 --> 06:56.860] Well, from a high level it can enable phishing, malware distribution, scams, et cetera. It can lead to [06:56.860 --> 07:03.240] cross-site scripting. Uh, and there's going to be context specific impact, like you can bypass the [07:03.240 --> 07:08.200] trusted host names check in a software update installer, that's something I've seen pretty common. [07:08.200 --> 07:16.040] You can abuse the brand trust and reputation in order to spread misinformation. Now, I included a [07:16.040 --> 07:23.760] quote below from APNIC on an article talking about this potential abuse. So, from a high level, they [07:23.760 --> 07:30.600] found that when it came to dangling DNS record abuse, um, in general, 75% of the hijacked dangling [07:30.600 --> 07:37.560] resources were being used to, for black hat se- search engine optimization and really promoting bad [07:37.560 --> 07:48.600] websites you don't want anyone going to. So, to be clear, past approaches for these types of bugs [07:48.600 --> 07:56.060] already exist. Where, with dangling cloud resources, you know, we've seen that attackers can go [07:56.060 --> 08:01.780] ahead and enumerate cloud IP pools and capture these resources that are dangling. But, with [08:01.780 --> 08:08.700] leaked secrets, what we've seen is that a lot of work really relies on a limited scope. So, what I [08:08.700 --> 08:14.880] mean by that is, everything that happens with leaked secrets is always about a specific target. [08:14.880 --> 08:23.380] Like a specific folder, a specific repository, or a specific directory. And the problem with this is, [08:23.380 --> 08:29.820] to start with dangling resources, some past work includes, you can buy DNS data and then enumerate [08:29.820 --> 08:36.820] your cloud provider's IP pool in order to find what's dangling. So, if I go ahead and create a [08:36.820 --> 08:41.740] resource over and over again in a cloud environment, I'll be assigned IP addresses that are [08:41.740 --> 08:48.360] not assigned to any other customer. And if one of these IP addresses matches a DNS record that I've [08:48.360 --> 08:54.740] found in DNS data that threat intelligence providers sell, well, that's one way you can capture a [08:54.740 --> 09:02.260] dangling DNS record. And other attempts also include going after a specific target. So, instead [09:02.260 --> 09:06.840] of using DNS data you buy from threat intelligence providers, you'll instead go ahead and [09:06.840 --> 09:11.440] enumerate that provider pool, but this time compare against sub-domains you've enumerated for [09:11.440 --> 09:19.480] that specific provider. So, to give you some examples, there's been a lot of work in this area. [09:19.480 --> 09:25.720] Bishop Fox originally came out in 2015 with an article where they used this passive DNS data, or at [09:25.720 --> 09:33.000] least a variant of it, in order to enumerate an AWS cloud IP pool and then capture AWS IPs that [09:33.000 --> 09:37.500] corresponded to a specific domain they were interested in. So, in that case they used [09:37.500 --> 09:46.320] bing.com to find those dangling DNS records. Some other work includes flying a false flag from [09:46.320 --> 09:50.840] Black Hat, it's a talk, where they used passive DNS data from these threat intelligence [09:50.840 --> 09:58.300] providers to determine whether IPs they captured were dangling. So, this project was again [09:58.300 --> 10:04.160] focused on creating these backends for C2 malware platforms. They wanted to take control of [10:04.160 --> 10:10.860] legitimate domains so that they could abuse those domains for a false level of trust. And one [10:10.860 --> 10:15.700] interesting note about this project is that they noted that after releasing it, it would appear [10:15.700 --> 10:22.280] that AWS and GCP now assign IPs from a limited pool for your account. We'll touch on this more [10:22.280 --> 10:27.500] later, but this is what we're going to be focusing on when it comes to dangling DNS resources. The [10:27.500 --> 10:32.220] topic is well traversed, but what's not well traversed are the modern deterrents against it and [10:32.220 --> 10:38.540] how we can bypass them. And finally, there's still a lot of work where attackers simply [10:38.540 --> 10:45.660] enumerate your domain subdomains and then find IPs that match them. Now when it comes to [10:45.660 --> 10:50.800] leaked secrets, the story's a bit different. It's not as well traversed as dangling DNS [10:50.800 --> 10:57.060] records at all. So for example, there's tools that you can use to search a Git repository for [10:57.060 --> 11:04.000] these secret patterns. And even GitHub has a system where they'll scan every content, every [11:04.000 --> 11:10.140] piece of code uploaded to their platform for these secret patterns. But the limitation with [11:10.140 --> 11:16.240] this work is that it's really a, it's very small scope. I mean, think about how much code is [11:16.240 --> 11:20.360] really going to end up on GitHub. You know, most enterprises aren't going to put their [11:20.360 --> 11:27.880] closed source applications on GitHub where this scanning would occur in the first place. Now [11:28.400 --> 11:33.200] going on to defender approaches to mitigate these vulnerabilities, well, they've been pretty [11:33.200 --> 11:38.800] limited as well. Oftentimes these are treated as customer vulnerabilities, which technically [11:38.800 --> 11:44.220] is correct. If you think about it from a high level, if you leak a secret or leave a DNS record [11:44.220 --> 11:50.140] dangling, that is your responsibility. But what I think that is often missed is the provider's [11:50.140 --> 11:56.380] responsibility and how they encourage these insecure defaults. So for example, tokens are [11:56.380 --> 12:02.180] really, really easy to use. Have you ever thought about how easy it is to use a token in your [12:02.180 --> 12:08.380] code? And that's how it can get leaked in the first place. Now Fortune 500 companies might have [12:08.380 --> 12:13.680] those standard secure development lifecycle practices where they can avoid this. But in [12:13.680 --> 12:18.620] reality, a lot of small to medium sized businesses might not understand this nuance or be able to [12:18.620 --> 12:26.100] apply it uniform across their organization. Now, this is something we're going to talk about [12:26.100 --> 12:31.480] later, but I want you to keep it in mind. Remember, even though it's a cloud customer [12:31.480 --> 12:37.500] vulnerability, there's incentives that lead to them being created in the first place. So let's [12:37.500 --> 12:43.460] talk about the traditional security mindset. Traditional bugs discovery is often centered [12:43.460 --> 12:47.540] around a specific target. You know, if I'm looking for vulnerabilities, I might go reverse [12:47.540 --> 12:53.260] engineering an application. And with dangling domains, one of the earliest approaches was going [12:53.260 --> 12:58.460] first, enumerating the subdomains of my target, and then enumerating the cloud provider IP [12:58.460 --> 13:04.400] pools in order to identify dangling resources. Now for secrets, again, we start with a specific [13:04.400 --> 13:11.020] target, whether that be a single repository or a single platform like GitHub. And what I really [13:11.020 --> 13:15.200] started to think about as I looked into this further and further was whether there's an [13:15.200 --> 13:20.680] opportunity for some vulnerabilities to be approached differently. For example, were we [13:20.680 --> 13:27.260] really facing tunnel vision here? Why do we need to start with a specific target? It's almost as [13:27.260 --> 13:31.920] if, you know, there is a lack of focus in the industry against finding bugs at scale, and [13:31.920 --> 13:36.820] rather finding bugs in individual areas. And that's what I really wanted to focus on with this [13:36.820 --> 13:43.720] research is, can we find these vulnerabilities at scale? So to expand on this with dangling [13:43.720 --> 13:47.860] resources, the traditional mindset might include, start with a target and then capture [13:47.860 --> 13:53.300] vulnerable assets. But as we've seen with past work, it can often be a lot larger than that, [13:53.300 --> 13:57.700] too. For example, the security at scale approach to dangling domains would be to capture [13:57.700 --> 14:03.520] dangling assets first, and then check if there's any DNS records still pointing at them using [14:03.520 --> 14:10.080] passive DNS replication data. Now here's where it gets interesting. For leaked secrets, there's [14:10.080 --> 14:15.860] no such equivalent. You know, we have approaches to scan limited scopes for these secret [14:15.860 --> 14:22.240] patterns, but when it comes to that security at scale mindset, it still goes around a very [14:22.240 --> 14:29.340] limited target. You know, we start with a repository, a folder, a file, instead of starting with a [14:29.340 --> 14:38.720] diverse data source that allows us to look for these secrets in a broad manner. So this is what [14:38.720 --> 14:42.860] I really want you to take away from this talk from a high level, is that there's an untapped [14:42.860 --> 14:47.960] potential to use unconventional data sources to find these vulnerabilities. We're about to go [14:47.960 --> 14:52.240] through some examples, but what I really want you to think about is not just, you know, here's [14:52.240 --> 14:57.140] how Bill applied it to dangling domains and leaked secrets, but rather how you can apply it to [14:57.140 --> 15:01.640] other types of vulnerability classes as well. This is not just about these two vulnerability [15:01.640 --> 15:06.460] classes. These two vulnerability classes are examples that you can apply to your own work. [15:08.240 --> 15:13.560] So let's talk about how we would actually implement this in practice. From a high level, we [15:13.560 --> 15:18.900] start with the vulnerability, not the target. So and then we work backwards by using creative [15:18.900 --> 15:24.920] data sources. Remember, for dangling resources, we already have a playbook. You can, you know [15:25.160 --> 15:30.120] a dang, a DNS record is dangling if it points at an IP address that the customer no longer [15:30.120 --> 15:35.260] controls. How do you know if an IP is no longer controlled by a customer? Well, we can [15:35.260 --> 15:40.480] enumerate the cloud IP pool and determine every IP that we get in our attacker account is [15:40.480 --> 15:45.760] likely something that no other customer controls because that IP is assigned to us. But how do [15:45.760 --> 15:50.320] we know if it's dangling? Well again, that passive DNS replication data. And if you're not [15:50.320 --> 15:54.800] familiar with this, how it works is that threat intelligence providers from DNS, will work [15:54.800 --> 16:01.720] with DNS providers to sell this aggregate DNS traffic data. For example, you can give these [16:01.720 --> 16:06.920] threat intel providers an IP address and they'll give you every single DNS record that points at [16:06.920 --> 16:15.420] it. Now again, we can capture assets first with DNS records instead of starting with a target. [16:15.420 --> 16:20.720] What we'll do is we'll go through a cloud provider pool and we'll go and enumerate every IP [16:20.720 --> 16:25.800] address that we're able to get and look for DNS records that point at it. What we're going to do [16:25.800 --> 16:31.020] in the next section is apply this generic technique we've seen in past work against modern [16:31.020 --> 16:37.640] deterrence. But what about secret scanning? So this is the interesting one. This is one that we [16:37.640 --> 16:43.840] still have a lot of research to do in. We have passive DNS replication data for dangling [16:43.840 --> 16:49.740] resources. But what about leaked secrets? From a high level, the ideal data source needs to be [16:49.740 --> 16:57.240] diverse, needs to be sufficient in volume, and it needs to include a diverse set of websites, [16:57.240 --> 17:02.280] executables, you know, not just open source applications, but we need to include closed source [17:02.280 --> 17:08.380] applications too. And we need to make sure that this is done in a feasible way. For example, even [17:08.380 --> 17:13.720] if we have a large data set of these files, we need to make sure we can scan it in a [17:13.720 --> 17:21.900] practical manner. So where can we find this large collection of apps and scripts? So what about [17:21.900 --> 17:29.300] virus scanning platforms? This is where it's going to get really interesting. So what we've seen [17:29.300 --> 17:35.540] with past work is a lot of people focusing on these platforms with limited diversity. You know, [17:35.540 --> 17:40.000] we look at GitHub, it's really going to only be open source repositories that are being scanned [17:40.000 --> 17:45.600] and automatically revoking keys. You know, we look at these tools, they all focus on scanning [17:45.600 --> 17:52.220] individual targets, like folders, specific repos, etc. But what we're missing is that diverse data [17:52.220 --> 17:57.280] source. And that's what I really focused on in this research. What I found was that virus scanning [17:57.280 --> 18:02.740] platforms were actually a really interesting target. Because think about it, think about all [18:02.740 --> 18:07.700] the stuff that people upload to virus scanning platforms. You know, think about all the websites [18:07.700 --> 18:11.800] that are automatically scanned, all the applications, all the mobile apps that are [18:11.800 --> 18:19.400] included in this virus total data source, and as well as other platforms. Now, with these scanning [18:19.400 --> 18:24.880] platforms, it'd be infeasible to go ahead and, you know, download what, a billion, nine billion [18:24.880 --> 18:30.100] files, and each scan each of them individually. But we don't need to do that, because we can use [18:30.100 --> 18:36.720] the tools that they already provide us. Nearly every virus scanning platform lets you search for [18:36.720 --> 18:41.800] specific patterns, specific strings, like they're literally spoon feeding us the perfect data [18:41.800 --> 18:46.780] source here. And traditionally, what we've used this data source for is to find malware, you [18:46.780 --> 18:52.020] know, find malicious use, etc. But what's really interesting about them is that, what if we use [18:52.020 --> 18:57.200] secret patterns instead of malicious patterns? What if instead of looking for malware, we look [18:57.200 --> 19:03.300] for secrets instead? And with virus total, this is retro hunt, but seriously, if you look at [19:03.300 --> 19:08.000] nearly every other virus scanning platform, what you'll find is that they have a similar [19:08.000 --> 19:18.250] future, um, at least if you have an account. So, let's apply this in practice. So with secret [19:18.250 --> 19:23.350] split scanning, the plan is from a high level. We want to make sure that we look for secret [19:23.350 --> 19:28.730] patterns, and what that really means is, think about your AWS access key. I don't know if [19:28.730 --> 19:33.830] you've noticed, but it'll often start with A-K-I-A. And what we can do is we can create these [19:33.830 --> 19:40.250] regex strings for identifying these secrets, and we can look for them using the same tools we [19:40.250 --> 19:45.850] have available for malware hunting. So, most virus platforms allow you to search by a Yara [19:45.850 --> 19:52.050] rule. And so what we can do is we can create a Yara rule for these secret patterns, and then we [19:52.050 --> 19:57.810] can search samples uploaded to the platform for whether these patterns exist in them. Now, [19:57.810 --> 20:02.690] one thing interesting that I did in this research was also focused on validating these secrets. [20:02.690 --> 20:07.050] So, I've looked at a lot of past work into leaked secrets, and what I've found is, there's a lot [20:07.050 --> 20:12.270] of theoretical research that discusses things like, oh, we looked for these secret patterns, [20:12.270 --> 20:16.810] and, you know, we found these unique keys, but you read into it a little deeper, and they didn't [20:16.810 --> 20:20.850] even check if those keys are legitimate. And that's something that didn't really make sense to [20:20.850 --> 20:25.870] me. There's going to be thousands and thousands and tens of thousands of keys that match a [20:25.870 --> 20:32.030] specific pattern, but are not active in practice. And so what we did was that I used a platform [20:32.030 --> 20:36.530] to actually validate these keys, at least with basic metadata, and validate that they're [20:36.530 --> 20:43.530] legitimate for our use case. Now, some patterns are going to be really noisy, but if the provider [20:43.530 --> 20:47.490] doesn't make it easy to identify their secrets, you're going to find that you're going to have [20:47.490 --> 20:54.030] to scan thousands and thousands of secret patterns and thousands of thousands of files. So, how [20:54.030 --> 20:58.510] do we deal with this large volume? Well, what I did to do it on my budget, remember, I'm doing [20:58.510 --> 21:05.270] this everything out of pocket, was leverage serverless computing. So, I needed a capacity of [21:05.270 --> 21:10.710] having several physical server racks, but I don't have money to buy several physical server [21:10.710 --> 21:16.550] racks. Instead, I can rent them using the cloud, and what that really means is I made a [21:16.550 --> 21:23.030] serverless function in order to scan these files, and I also made a serverless function to [21:23.030 --> 21:27.710] validate the keys that were found. And this way, I don't actually have to pay that much, [21:27.710 --> 21:33.130] because I only pay for what I use. In practice, my costs were actually fairly reasonable for an [21:33.130 --> 21:39.110] individual. Now, for dangling resources, again, the methodology from a high level was to [21:39.110 --> 21:44.330] reallocate resources over and over and over again, and then it was to cross check them with [21:44.330 --> 21:50.230] passive DNS replication data. Remember, this isn't necessarily new, but what's interesting [21:50.230 --> 21:56.210] about them is that we're going to be talking about bypassing modern deterrents. And what I [21:56.210 --> 22:00.230] mean by that is a lot of cloud providers have implemented these mitigations to make it [22:00.230 --> 22:07.370] harder to do this dangling DNS record enumeration, and we're going to bypass them. So, [22:07.370 --> 22:13.150] from a high level, one thing I want to call out is that earlier note. Remember, it would [22:13.150 --> 22:21.710] appear that AWS began serving Elastic IPs from a small, specific pool similar to GCP. This [22:21.710 --> 22:26.290] severely limits the diversity of addresses received. And so, let me tell you what this [22:26.290 --> 22:32.190] really means in practice. So, what's going on here is that AWS and GCP have a mitigation [22:32.190 --> 22:38.850] where when you are asked to assign me an IP address, whether that be an Elastic IP or in [22:38.850 --> 22:44.530] GCP case, nearly every resource that you can go ahead and allocate that needs an IP, these [22:44.530 --> 22:51.290] cloud providers will only give you a specific set of IPs assigned to a shared pool that's [22:51.290 --> 22:56.410] limited to your account and maybe a few others. And for AWS, this is going to be largely [22:56.410 --> 23:02.770] Elastic IP sharing. So, that means whenever you ask for a dedicated Elastic IP, you'll [23:02.770 --> 23:07.190] notice if you free an Elastic IP and allocate another one, you're going to be assigned the [23:07.190 --> 23:11.310] same one over and over again. Or in general. It's really hard to actually enumerate that [23:11.310 --> 23:18.110] pool using Elastic IPs alone. Now, with AWS, they also introduced a mitigation, I don't [23:18.110 --> 23:23.070] know if intentionally to go against dangling DNS enumeration, but they did introduce a [23:23.070 --> 23:28.990] mitigation in 2024 where every IP address you received was actually had an increased [23:29.590 --> 23:35.630] surcharge. So, now every IP you got allocated cost you extra money. And this deters attacks [23:35.630 --> 23:40.430] by making it more expensive to enumerate their public IP pools and capture these dangling [23:40.430 --> 23:47.070] DNS records. Now for Google Cloud, it's interesting. They actually had quite a lot more than I [23:47.070 --> 23:53.470] expected. So, for project levels, so every account can have about 15, 10 to 15 projects [23:53.470 --> 23:58.330] assigned to them by default. You can request an increase, but you need justification. Now, [23:58.330 --> 24:04.270] IPs are again assigned from a small pool just like AWS. You only have 8 IPs you can use [24:04.270 --> 24:10.150] by default in per region and globally. And with these accounts, you also had something [24:10.150 --> 24:15.530] called a billing account restriction. So, with Google Cloud, every credit card can be [24:15.530 --> 24:19.650] created into a billing account. Now, you can create a few billing accounts based off of [24:19.650 --> 24:23.970] one credit card, but if you try to create more than a few, you'll automatically hit their [24:23.970 --> 24:29.010] suspension and you'll have to go justify why are you creating a 50th, you know, credit [24:29.010 --> 24:34.430] card account or billing account with one credit card. And so, all these deterrents really [24:34.430 --> 24:39.230] make it difficult for attackers to enumerate these dangling domains. In fact, with Google [24:39.230 --> 24:44.550] Cloud, while managed DNS enumeration was always a thing and has been for the past few years, [24:44.550 --> 24:49.670] attackers haven't been able to enumerate Google Cloud's public IP pools for quite some [24:49.670 --> 24:57.190] time, at least none researched that I could find online. So, with those AWS mitigations, [24:57.190 --> 25:01.110] they're actually pretty simple to bypass. Instead of allocating elastic IPs, we can [25:01.110 --> 25:07.150] just restart EC2 instances with ephemeral IPs and we can perform the enumeration by [25:07.150 --> 25:13.750] just restarting, restarting, restarting. And my IP address that my EC2 instance is assigned [25:13.750 --> 25:19.490] will generally rotate a lot faster through unique IPs than if you tried with elastic [25:19.490 --> 25:26.290] IPs. In fact, um, I actually was able to enumerate nearly 2.4 million unique IP addresses in [25:26.430 --> 25:33.530] a span of 6 months by using this methodology. Now, with Google Cloud, again, they had a [25:33.530 --> 25:39.170] harder set of mitigations, but they, those mitigations were deterrents. So, how it worked [25:39.170 --> 25:44.530] was that I used a backend bucket with a load balancer in order to assign IP addresses to [25:44.530 --> 25:49.490] my resources. But this still didn't let me get past these cloud resource restrictions. [25:49.490 --> 25:55.310] How do we do that? Well, once we have this primitive for enumerating cloud IPs, we can [25:55.310 --> 26:00.810] talk about those limitations. But for high level information, we used forwarding rules [26:00.810 --> 26:07.550] instead of virtual machines in order to enumerate these IPs. So, with Google Cloud, [26:07.550 --> 26:13.070] remember all those restrictions? Well, we can actually bypass all of them fairly cheaply. So, [26:13.070 --> 26:17.270] number one, with a billing account, one interesting thing I found was that you can assign [26:17.270 --> 26:21.990] billing accounts across Google accounts. This was a useful primitive where if I could create a [26:21.990 --> 26:26.490] billing account in one account, I can actually assign it across several accounts. And the [26:26.490 --> 26:31.770] reason this is interesting is, well, what about those quotas? Well, with account quotas, [26:31.770 --> 26:35.590] remember you can only create a certain amount of projects. Now, again, you can request an [26:35.590 --> 26:39.650] increase in this limit, but you don't want to have to do this justification. I felt that it [26:39.650 --> 26:43.250] would be inappropriate to assume that an attacker would be able to get this quota increase. [26:43.390 --> 26:47.450] What I found was, though, you can create a Google Workspace environment. So, what that [26:47.450 --> 26:52.610] means is I can create a fakebusiness.com, I can create Google Workspace environment for it, [26:52.610 --> 26:59.470] and I can create practically as many Google accounts as I want for about $6 per account per [26:59.470 --> 27:05.410] month. And this way, each of those accounts gets a dedicated quota limit and allows you to [27:05.410 --> 27:10.990] bypass these quota limits by creating, for example, 10 accounts. Now that's $60, but now [27:10.990 --> 27:16.650] your quota has been 10-timed. And finally, to bypass billing account restrictions, remember [27:16.650 --> 27:21.210] those credit card restrictions, billing accounts can only be associated with a certain number [27:21.210 --> 27:27.110] of projects. Well, we can instead then use virtual credit cards. And I use privacy.com. [27:27.110 --> 27:31.950] That's not a recommendation, it's just one of the easiest that worked for me. And what really [27:31.950 --> 27:38.170] this means is, it's not like they're bypassing KYC practices, they verified my identity, but it [27:38.170 --> 27:42.630] still allows me to create as many credit card numbers as I want and be able to create as many [27:42.630 --> 27:46.650] billing accounts as I want to be able to bypass every single restriction we discussed with [27:46.650 --> 27:52.030] Google Cloud. And so this is what I really want to mention from a high level, is Google Cloud [27:52.030 --> 27:58.670] implemented all these deterrents to try to make sure you can't enumerate their dangling IPs, but [27:58.670 --> 28:03.810] in practice, these deterrents weren't addressing the root cause, which was the fact that the [28:03.810 --> 28:13.060] dangling IPs still existed in the first place. So let's talk about a little bit of the [28:13.060 --> 28:21.260] discovery process and what I was able to find with these techniques. So with dangling [28:21.260 --> 28:27.240] resources, I was able to enumerate over 2 million IP addresses for Google Cloud and AWS. These [28:27.240 --> 28:32.780] are unique IP addresses and they're mostly primitive resources. So these IPs were created [28:32.780 --> 28:40.860] by, remember, restarting an EC2 instance or creating forwarding rules over and over again. As [28:40.860 --> 28:45.280] far as I'm aware, this is one of the first methodologies to successfully bypass every single [28:45.280 --> 28:50.600] Google Cloud deterrent that is intended to stop this type of attack in the first place. I [28:50.600 --> 28:57.280] captured over 60,000 unique fully qualified domain names. And this reflects past research [28:57.280 --> 29:03.060] into this area where researchers found that these FQDNs, there are a lot of different A [29:03.060 --> 29:08.940] records that pointed at IPs that were no longer being controlled. Now out of these 60,000 [29:08.940 --> 29:15.040] FQDNs, there are about 54,000 unique second level domains. And what that really means is that [29:15.040 --> 29:20.320] once you take away the subdomain, let's say A.B.com, we're just focusing on the unique [29:20.320 --> 29:28.620] number of Apex or second level domains. Well, that was over 54,000. And finally, one of- [29:28.620 --> 29:33.560] over 5,000 of the domains that I was able to capture included- were included in the [29:33.560 --> 29:39.520] Tranco top 1 million list. So Tranco is a listing of every domain that they're aware of [29:39.520 --> 29:45.440] within a certain ranking and it allows you to compare what- it's supposed to be an objective [29:45.440 --> 29:51.340] metric for a ranking of a domain based on DNS data. Now, there are a lot of Fortune 500 [29:51.340 --> 29:57.160] companies impacted and what I found really interesting was that with AWS, we had a roughly [29:57.160 --> 30:06.800] 25- a rate of 25 dangling domains per 1,000 IPs. But with Google Cloud, it was nearly 36. And [30:06.800 --> 30:12.820] so what I suspect this discrepancy is as a result of is that Google Cloud hasn't been able [30:12.820 --> 30:20.340] to be enumerated for quite a few years. Now, this talk isn't going to focus on the actual [30:20.340 --> 30:25.720] impact against customers because I promised DEF CON review board I wouldn't get stuck on it. [30:25.720 --> 30:29.540] But you can see that I was able to compromise some of the world's largest organizations [30:30.100 --> 30:37.180] including the Western District Court of Texas, um, the New York Times, uh, the California- [30:37.180 --> 30:43.940] State Government of California, and Dior. And, um, yeah, it was a pretty fun time. There was a [30:43.940 --> 30:49.280] lot more examples here. Again, this isn't intended to cover it. That's, uh, on a separate blog [30:49.280 --> 30:54.980] post as well. I really go into detail about the impact. And for a secret scanning, again, what [30:54.980 --> 31:01.200] was really interesting was that I scanned over 5 million unique files for- from various [31:01.200 --> 31:05.920] platforms, not just VirusTotal, that was just one of them. Um, and I discovered over 15,000 [31:05.920 --> 31:12.860] validated secrets. And out of these secrets, they included over 2,500 unique, again, validated, [31:12.860 --> 31:17.780] these aren't just, you know, may match a pattern, these are validated, to over 2,500 validated [31:17.780 --> 31:25.360] secrets, over 2,400 unique AWS keys, over 2,200 GitHub personal access tokens and fine-grain [31:25.360 --> 31:33.640] tokens, over 600 Google's cloud service accounts, over 460 Stripe accounts, and the rest are [31:33.640 --> 31:38.120] largely from miscellaneous providers added up together that I didn't feel the need to include [31:38.120 --> 31:54.130] in this slide. And, and again, there will be a blog to recap this, but from a high level, it's [31:54.130 --> 31:58.210] some of the largest organizations in the world were impacted. You know, just a fun example a [31:58.210 --> 32:06.090] few months ago was Slack, Stanford's entire Slack workspace, um, Samsung's workspace for [32:06.090 --> 32:12.350] Bixby. I was able to get a bot token for this Samsung Bixby tenant and, which allowed me to [32:12.350 --> 32:17.490] read messages from nearly every channel, every single channel that the bot had access to [32:17.490 --> 32:21.810] because of a default scope that was quite broad. You know, some other interesting things [32:21.810 --> 32:26.970] included the Supreme Court of Nebraska, that was a fun one, where they uploaded a password [32:26.970 --> 32:32.650] list to VirusTotal with like 300 credentials from different, like, I don't know, different [32:32.650 --> 32:37.710] AWS providers, different cloud providers, their security solutions, et cetera. That was a [32:37.710 --> 32:43.090] really fun one. Um, you know, there are database backups with a lot of these AWS keys that had [32:43.090 --> 32:47.810] broad access to S3 buckets. Anyways, you'll be able to read a lot more about this this [32:47.810 --> 32:54.210] following week. So by leveraging a security at scale mindset, we can help protect thousands [32:54.210 --> 33:00.050] of organizations far beyond a limited scope. Remember, instead of starting with a specific [33:00.050 --> 33:06.090] target, by starting with a diverse dataset, we were able to have a much wider impact than any [33:06.090 --> 33:11.830] of past work into leaked secrets. You can read more about some of this impact in an, in an [33:11.830 --> 33:17.510] article that should be released right now, uh, by Matt Burgess from Wired. And I'll be [33:17.510 --> 33:22.530] releasing a detailed technical blog later this week once I figure out whether a certain cloud [33:22.530 --> 33:29.730] provider can actually revoke some of these keys or not. So, bringing it all together. [33:32.530 --> 33:37.010] Hardcoding, hardcoding secrets is the path of least resistance. So remember, these are [33:37.010 --> 33:44.750] customer vulnerabilities, but what enables them is these bad incentives. Think about it, think [33:44.750 --> 33:49.910] about how easy it is to go ahead and generate an AWS access key or generate a Google Cloud [33:49.910 --> 33:55.170] service account and then put that into your executable directly. You know, the libraries for [33:55.170 --> 34:02.070] these different providers allow this direct interface in the first place. Now, the reason [34:02.070 --> 34:06.090] this is really important is because a lot of developers are going to follow the path of least [34:06.090 --> 34:12.950] resistance. Especially from smaller to mid-cap businesses. And with dangling DNS records, the [34:12.950 --> 34:19.930] same problem exists. It's the path of least resistance. I created an AWS EC2 instance, I [34:19.930 --> 34:25.630] put my DNS record pointing at that AWS EC2 instance, and the path of least resistance is [34:25.630 --> 34:31.290] leaving that DNS record even if I deallocate it. And what I think we need to really focus on [34:31.290 --> 34:37.070] is making sure that the path of least resistance is the secure path. And what this really [34:37.070 --> 34:43.630] means is with dangling resources, I think we need to have better ownership of cloud resources [34:43.630 --> 34:49.450] and DNS records. Better association. So for example, some cloud providers have tried to [34:49.990 --> 34:56.590] associate their DNS services with their EC2 resources as one example. Um, and the problem [34:56.590 --> 35:00.610] with this is a lot of different customers are going to use different DNS providers, different [35:00.610 --> 35:06.650] cloud providers. What we really need is an industry wide solution of tracking DNS records and [35:06.650 --> 35:16.080] tracking cloud resources and putting them together. Now, for hard coded secrets, what I [35:16.080 --> 35:21.220] really think we need to focus on is making sure that it's hard to include secrets in your [35:21.220 --> 35:27.380] code. So don't have short access tokens that your library just blindly accepts from a [35:27.380 --> 35:52.390] string. But instead, for- alright, thank you for that. That was a nice wake up call. Um, [35:53.590 --> 35:58.310] alright. Uh, anyways, so yeah, with these hard coded secrets, what I really think we need to [35:58.310 --> 36:04.470] do is make sure to limit the secrets so that they can only be inserted from an environment or [36:04.470 --> 36:09.130] from a file on disk. And make it hard to hard code these secrets inside of an executable in [36:09.130 --> 36:13.290] the first place. Now again, you can have exceptions, you know, you can have it so a [36:13.290 --> 36:17.570] customer can opt out from the secure default. But we need to make sure that the secret [36:18.390 --> 36:26.670] default is secure. So what about remediating these vulnerabilities? Well, remember, for [36:26.670 --> 36:31.870] dangling records at a high level, it's going to be hard to contact every single host of every [36:31.870 --> 36:37.230] 60,000 dangling domain that I was able to discover. What we really need is a way to tie [36:37.230 --> 36:42.010] ownership to DNS records. And we need to do this across the industry because of that [36:42.010 --> 36:50.390] multi-cloud approach. Now for secrets, this is where it gets really interesting. So I went [36:50.390 --> 36:54.470] ahead and asked a bunch of organizations that I found secrets for, including GitHub, [36:54.470 --> 36:59.290] including AWS, including OpenAI, whether I could report secrets to them and they could [36:59.290 --> 37:04.310] revoke them automatically. Now GitHub has that program for scanning secrets on their [37:04.310 --> 37:09.570] platform already. Remember, if you actually go ahead and post a, for example, OpenAI access [37:09.570 --> 37:15.770] key on a public repository, that access key will be revoked within a few minutes. And what I [37:15.770 --> 37:20.630] was curious was, hey GitHub, can I please use this mechanism you already have? Well, [37:20.630 --> 37:27.010] unfortunately they said no. And in fact, several providers said no, like AWS, despite the [37:27.010 --> 37:32.730] fact that they already had given this mechanism to GitHub and despite the fact that an [37:32.730 --> 37:38.730] attacker could access the mechanism by posting a public git or public commit. Now one [37:38.730 --> 37:43.730] exception to this was OpenAI, who immediately responded with an endpoint for reporting [37:43.730 --> 37:49.290] these keys and allowed me to automatically revoke the keys that I discovered in the wild. [37:49.590 --> 37:54.990] But what do we do about everyone else? So the problem with these secret keys is that the [37:54.990 --> 38:01.050] impact is far, far, far greater than dangling DNS records. In fact, we just saw some of the [38:01.050 --> 38:05.610] world's largest organizations and there were several more impacted. I didn't feel [38:05.610 --> 38:09.970] comfortable releasing this work without at least some stopgap until these cloud providers [38:09.970 --> 38:16.470] could take the secure default. So what I actually did was I developed a mechanism that [38:16.470 --> 38:23.650] used GitHub's mechanism anyway for revoking these secrets, because they said no, but I [38:23.650 --> 38:29.330] don't care. But yeah, so what I did was I have this system now where whenever new [38:29.330 --> 38:35.290] secrets are discovered, I'll go ahead and create a gist. And the way I create this gist is [38:35.290 --> 38:41.590] by automating the entire GitHub login process and then just using a UI endpoint for [38:41.590 --> 38:46.770] creating a public gist. And this way it'll actually trigger the GitHub secret scanning [38:46.770 --> 38:57.420] mechanism that they could have given me direct access to anyway. So yeah, anyways. Now [38:57.420 --> 39:01.920] what's really cool about this is that every, almost every secret that you saw listed in the [39:01.920 --> 39:06.080] previous section, a lot of them are going to be revoked. There's an exception to that [39:06.080 --> 39:11.880] though. One of the largest providers which did have leaked secrets was AWS. Now AWS takes [39:11.880 --> 39:17.700] an interesting approach. When you post your AWS access key on a public GitHub commit or [39:17.700 --> 39:24.480] post, what they do is that they'll create a support case for you and restrict write access [39:24.480 --> 39:29.860] using that key. I found that kind of interesting. So what's really happening is AWS is [39:29.860 --> 39:36.200] aware of these secret keys, but they're choosing not to revoke them for some reason. Yeah, [39:36.200 --> 39:42.340] that's an interesting one. So effectively if you find a leaked AWS access key on GitHub, you [39:42.340 --> 39:48.340] can still use that key to read S3 buckets, read RDS database data, to read download files [39:48.340 --> 39:54.400] from S3. You know, I remember I looked at a AWS key last weekend for a casino that was [39:54.990 --> 40:02.460] alleged to deal with over $1 billion of bets a month. And I was like, okay, wait a minute, [40:02.460 --> 40:07.520] was this reported? We should get this revoked. But in reality what happened was AWS created [40:07.520 --> 40:13.700] this support case. The customer never saw it because the support email was sent to their [40:13.700 --> 40:18.180] generic billing account. You know, a lot of people, a lot of enterprises set up an AWS [40:18.180 --> 40:23.060] account and use a generic billing email that no one really looks at. And so the support case [40:23.060 --> 40:28.020] was ignored and this key is still active today. You know, it's disappointing because I don't [40:28.020 --> 40:31.720] know what more I can do for my shoes. You know, I've created a mechanism that can help [40:31.720 --> 40:36.460] automatically revoke most of these keys, but what do we do about keys that the provider [40:36.460 --> 40:41.720] doesn't take action on? And so this is where I really think providers need to switch up is, [40:41.720 --> 40:47.540] number one, if someone's secret key, you have both components, is on the internet and you [40:47.540 --> 40:52.700] know about it, you need to revoke that immediately. I mean, it's crazy to me to think [40:52.700 --> 40:56.600] that even on GitHub, if you post your AWS access key, that's not going to be automatically [40:56.600 --> 41:01.480] revoked. Every other provider I looked at does automatically revoke. Google Cloud revokes, [41:01.480 --> 41:07.240] Slack revokes, OpenAI revokes. The largest cloud provider by market share does not revoke. [41:10.340 --> 41:16.040] Now, if you're interested in starting this sort of research yourself, what I'd focus on is [41:16.040 --> 41:20.480] breaking down the traditional methods of finding vulnerabilities. So with dangling domains, [41:20.480 --> 41:27.460] that was checking if the DNS record is actually pointing at a uncaptured IP address. And with [41:27.460 --> 41:34.000] secrets, it was trying to find those secret patterns in a diverse data source. So in this [41:34.000 --> 41:39.640] case, we used virus scanning platforms, but you can use a similar methodology against a [41:39.640 --> 41:44.900] lot, a larger set of vulnerability classes. And what you really want to do is correlate [41:44.900 --> 41:51.880] those steps with these large data sets, regardless of their intended usage. Thank you so much [41:51.880 --> 42:05.820] for coming out to this talk. What a fun time. We do have a few minutes for questions. Oh, we [42:05.820 --> 42:11.860] apparently don't have microphones. All right, yeah. If you have questions, feel free to come [42:11.860 --> 42:16.680] up and we can have a chat over on stage. Thank you so much for coming out to this talk. What a [42:16.680 --> 42:20.400] fun time. And yeah, I look forward to working with these providers to address these [42:20.400 --> 42:21.280] vulnerabilities.