[00:00.660 --> 00:08.200] Hello DEF CON. So, I'm very happy to be here. This has been a dream of mine for many, many [00:08.200 --> 00:18.080] years. And thanks for being part of it. This research is about a cool story about secrets in [00:18.080 --> 00:25.020] public cloud resources. And you know, who thinks we will never run out of customers [00:25.020 --> 00:32.880] public, public, sharing secrets in public cloud resources? Yeah, I think, I think we will [00:32.880 --> 00:39.440] never run out of that. And um, my name is Eduard Agavriluai. I was a senior penetration [00:39.440 --> 00:45.200] tester at KPMG Romania while I've done this research. A huge shout out to them for [00:45.200 --> 00:52.360] supporting the research and trusting this idea. I was also a contractor at Syncubes. I mean, [00:52.360 --> 00:57.160] I still am and I'm doing offensive cloud projects there. I also worked one month at [00:57.160 --> 01:07.330] CrowdStrike but I resigned on Friday. So, so I'm open for new opportunities and um, yeah, I'm [01:07.330 --> 01:15.650] trying to do some cloud security research. Now, I started um, a cloud configuration [01:15.650 --> 01:24.570] review for a customer of Syncubes. And um, I got the initial access um, and I started using [01:24.590 --> 01:34.810] uh, Scoutsuite as I uh, always uh, as I always do. And um, I checked the report. I saw the S3 [01:34.810 --> 01:39.890] findings, the CloudTrail findings, the YAM findings. And when I looked at the EC2 [01:39.890 --> 01:46.770] dashboard, I saw for the first time, the critical finding AMI is set to public. And who [01:46.770 --> 01:54.370] knows what an AMI is? Okay, cool. And um, who used at least once an EC2 instance? [01:54.590 --> 02:01.030] Okay, so if you used an EC2 instance, you kind of know what an AMI is because every time you [02:01.030 --> 02:08.490] start an EC2 instance, you are using an AMI. It's like a snapshot of a virtual machine and you [02:08.490 --> 02:17.230] can pre-configure an AMI to contain your applications, secrets, um, so to have a baseline [02:17.230 --> 02:22.410] right? And then you can start new EC2 instances starting from this AMI. And you have AWS [02:22.410 --> 02:28.050] Marketplace AMI that are official and from trusted vendors which are the recommended ones [02:28.050 --> 02:34.450] you can use. And you can also have community AMIs that are published by anyone. And you [02:34.450 --> 02:39.710] have to be careful with uh, with them because if you don't trust the publisher, you might [02:39.710 --> 02:47.170] have some back doors, malware and so on. But in any case, the thing is that an AMI can be [02:47.170 --> 02:51.830] public or private. And by default, they are private and it's actually hard to make one [02:51.830 --> 02:57.110] public. And I think you can see where I'm going with this. The issue is that they can be [02:57.110 --> 03:04.990] public. And this customer had five public AMIs um, exposed for multiple years and when I [03:04.990 --> 03:11.090] asked them, hey, can I take a look inside the AMIs to see what's inside of them? And um, [03:11.090 --> 03:17.830] they were like, no. So I regretted I even asked. But I got this question, what was inside [03:17.830 --> 03:23.630] the AMIs? And this actually gave me the research idea if there are other companies with [03:24.190 --> 03:35.030] secrets in public AMIs out there. So um, first we wanted to do this research so bad that we [03:35.030 --> 03:40.610] haven't checked any previous work but when we are, when we were in the middle of it, we [03:40.610 --> 03:45.590] discovered the work done by Dolev Farhi who scanned based on keywords AMIs in a single [03:45.590 --> 03:53.090] AWS region which was fine but it was not enough from our perspective. And also the work [03:53.090 --> 03:58.450] done by Ben Morris who searched secrets in public ABS snapshots but we will see shortly [03:58.990 --> 04:06.650] that there is very little overlap between his work. And funny story, last day I was talking [04:06.650 --> 04:11.490] about the research with someone and he was like, hey, you know who did something similar? [04:12.010 --> 04:16.890] He searched public ABS snapshots. He's Ben and he pointed at someone and it was Ben Morris [04:16.890 --> 04:27.410] and he was like, yeah. And, sorry. So yeah, I've met Ben Morris. I've been saying his name a [04:29.010 --> 04:35.790] lot rehearsing the presentation. It was a pleasure to meet him in person. He's a lovely guy. [04:36.890 --> 04:42.490] Now, uh, we set some goals for the research to dig for secrets in every public AMI across all [04:42.490 --> 04:49.350] AWS regions to have some fun and do some responsible disclosure. We also had a hidden goal [04:49.350 --> 04:55.230] to get some bounties and uh, my colleague Matei will tell you more about it. Starting the [04:55.230 --> 05:01.070] research we had to collect every public AMI across all AWS regions and to do that you have [05:01.070 --> 05:08.090] to, you have to use the CLI because AWS automatically deprecates images after two years [05:08.090 --> 05:15.330] after they were published. And if they are deprecated you can find them in the web portal. [05:15.330 --> 05:21.170] Also customers can deprecate their images whenever they want. So you have to use the CLI and [05:21.170 --> 05:27.290] specify the flag include deprecated to make sure you get all the AMIs. And we did that and [05:27.290 --> 05:34.910] we got 3.1 million AMIs and uh, we were sure that this was too much for us to scan all of them [05:34.910 --> 05:42.870] and we started asking if we can remove AMIs based on the chances of having secrets. So we [05:42.870 --> 05:49.330] removed AMIs from marketplace, that left us with 1.5 million. We removed AMIs owned by AWS [05:49.330 --> 05:55.910] that were not in the marketplace, that left us with 1 million. And we went further and we [05:55.910 --> 06:01.850] removed the owners that had more than 50 public AMIs because honestly if you are a company [06:01.850 --> 06:07.610] and you have more than 50 public AMIs security wise you are in a point of no return or you [06:07.610 --> 06:15.130] are an official publisher, an unofficial publisher, right? And that left us with 27,000 [06:15.130 --> 06:24.730] AMIs. Now we did some sanity filtering because some AMIs had 17 volumes or volumes as big as [06:24.730 --> 06:29.990] 20 terabytes. Obviously I'm very curious what's inside of them but for our budget we had to [06:29.990 --> 06:37.870] remove them and that left us with 26,000 AMIs. Now the distribution from our list looks like [06:37.870 --> 06:45.030] this. Obviously the most AMIs were in U.S. East 1 and the region with the smallest number of [06:45.030 --> 06:54.710] AMIs was IL Central 1, Israel Central 1 with only 30 public AMIs after our filtering. And when [06:54.710 --> 07:02.010] I'm saying that we collected the AMIs this is what I mean by it. So we got the JSON [07:02.010 --> 07:07.550] definition for each AMI and you have a lot of information like the ones highlighted, the [07:07.550 --> 07:12.970] image ID, the information about the snapshot but you also have other important information [07:12.970 --> 07:21.470] like description, title and the owner of the AMI and we'll see how we can use that shortly. Now [07:21.470 --> 07:27.510] that we had our list we need a way to access the contents of the AMI and this should be time [07:27.510 --> 07:34.390] and cost effective, automated and as reliable as possible. And we looked for various methods [07:34.390 --> 07:40.150] some of them might work in certain situations but only the fourth option was the right one [07:40.150 --> 07:47.830] for us. So first we tried to copy the snapshot of the AMI in our own AWS account and [07:47.830 --> 07:54.890] download it. But even if the AMI is public the ABS snapshot is not by default and that's why [07:54.890 --> 08:00.950] it's very little overlap between our work and the work done by Ben Morris. Next we tried to [08:00.950 --> 08:07.370] start an EC2 instance based on the target AMI, create an ABS snapshot of its volume and [08:07.370 --> 08:15.910] download it. But we quickly realized that this would take a lot of time for an ABS snapshot [08:15.910 --> 08:22.790] of 100 gigabytes. It took around 20, 30 minutes to download and we were sure that AWS will [08:22.790 --> 08:30.330] block our IP since we are downloading terabytes of data. So definitely not an option. But we [08:30.330 --> 08:37.010] realized we had to operate as much as possible within the native AWS features to achieve the [08:37.010 --> 08:45.650] faster method. And we tried to start a new EC2 instance based on the target AMI and connect [08:45.650 --> 08:52.210] directly to the instance. But for some reason the instances were not in a state that allowed [08:52.210 --> 08:58.450] us to connect to them. Either through SSH or through SSM features it just didn't work. But [08:58.450 --> 09:07.750] we did a work around and we got to this method. So we have a secret search instance. We call it [09:07.750 --> 09:13.970] like this because it's an instance that we already have in our own AWS account and it's [09:13.970 --> 09:19.190] working. We can connect to it. And next we start an EC2 instance based on the target AMI, [09:19.190 --> 09:24.110] detach its volume and reattach it to our secret search instance where we can connect and [09:24.110 --> 09:30.410] analyze the data. It's like having a working laptop and someone brought a laptop that [09:30.410 --> 09:34.670] doesn't work but you can get out the hard disk and connect it to your laptop and basically [09:34.670 --> 09:39.010] that's how you can access the data. And everything is happening within the AWS environment [09:39.010 --> 09:45.850] so it was both fast and it was both as reliable as possible. Now I'll show you a demo on how [09:45.850 --> 09:56.530] you can manually access the contents of one AMI. Let me see if I can start this. So we can [09:56.530 --> 10:00.670] search based on the description. You can use this to target certain technologies or [10:00.670 --> 10:05.750] companies. You have to mention the right region because otherwise you will not find the [10:05.750 --> 10:12.310] AMI and you also have to specify the flag include deprecated to make sure you get all the [10:12.310 --> 10:19.030] images, right? If you know the AWS account ID, you can try to find all the images owned by [10:19.030 --> 10:25.790] that account so that might be useful for bug counter, right? But let's stick with our [10:25.790 --> 10:35.730] description based search. So let's try to copy the ABS snapshot as a first step. Let's [10:35.750 --> 10:41.750] try. So you will see that if you try to copy the snapshot in our own AWS account, we will [10:41.750 --> 10:46.670] get the error message source snapshot is not found. That's because the ABS snapshot is not [10:46.670 --> 10:53.890] public only the AMI is. Now we will do the method with the secret searcher instance so we [10:53.890 --> 10:58.230] have our instance that it's running and now we will start a new instance based on the target [10:58.230 --> 11:04.270] AMI and we will place it in the same availability zone as our secret searcher instance. You [11:04.270 --> 11:09.710] need the same availability zone to make sure you have, you can move the volume between the [11:09.710 --> 11:17.050] instances. Now, the instance is running, we will stop it and we will detach the volume and [11:17.050 --> 11:23.930] we will reattach it to the secret searcher instance. After you detach the volume, you can [11:23.930 --> 11:33.090] delete the EC2 instance that is based on the AMI if you want to reduce some cost but in any [11:33.090 --> 11:38.770] case, you can just attach the volume and then you can connect to it. We use the web portal [11:38.770 --> 11:44.730] because it was easier for the demo but you can also connect to SSH. A common error that we [11:44.730 --> 11:50.230] encountered was an ID collision between the new volume and the root volume that was [11:50.230 --> 11:56.650] attached to the instance. And we have to use all kinds of weird tools I have never heard [11:56.650 --> 12:04.050] about in order to fix this issue but once that is done, you will be able to mount the volume [12:04.050 --> 12:10.030] and connect, to mount the volume and access the files. And now that it's mounted, let's look [12:10.030 --> 12:15.870] for some AWS credentials, right? We found some and now let's check if they are valid. Because [12:15.870 --> 12:21.850] for some older instances, the secrets might not be valid anymore so every time you have to [12:21.850 --> 12:31.320] check them. So, surprise, yes, they are working. And that's exactly how we felt when we [12:31.320 --> 12:37.700] found our first AWS access keys and the same day we found ten other valid access keys so we [12:37.700 --> 12:43.780] realized that this was a big issue indeed. This is the high level architecture we put in [12:43.780 --> 12:51.560] place. We had a master EC2 instance where we ran our big script and in each region we started [12:51.560 --> 13:00.180] the secret searcher instance and then we started batches of 20 instances based on AMIs to make [13:00.180 --> 13:06.180] sure we reduced the time. And for each instance we detached the volume, we reattached it to [13:06.180 --> 13:12.920] the secret searcher instance where we will search for secrets and sensitive files. And after [13:14.420 --> 13:21.200] writing 1.2K lines of code, 14 days of scanning time and a bill of 450 dollars, we [13:21.200 --> 13:28.580] collected 500 gigabytes of carefully selected files and data um, that we had now to, to [13:28.580 --> 13:33.960] analyze. And I invite my colleague Matej Josic to tell you more about it. Thank you. [13:37.140 --> 13:42.460] Cool. Good morning everybody and thank you so much for being here. It's actually an absolute [13:42.460 --> 13:50.900] pleasure to be on stage at DEF CON 32. This is the secret searcher section where I'm going to [13:50.900 --> 13:57.520] talk about how we search for secrets, what sorts of secrets we found and what we were able to [13:57.520 --> 14:05.380] do with them. I am Matej Anthony-Josephs. I've been with KPMG for about a year and a half [14:05.380 --> 14:11.300] and I'd like to take this opportunity to thank them for the time and the budget for this [14:11.300 --> 14:16.320] project right here. Other than that I'm a senior security researcher with experience in [14:16.320 --> 14:21.960] pen testing, threat hunting, vulnerability management and a bit of people management as well. [14:23.200 --> 14:29.400] Now, completely unrelated to this research, I've also set up a company alongside my wife, [14:29.400 --> 14:34.380] Alexa. Our company is called Hivehack because we're absolutely fascinated by the [14:34.380 --> 14:40.520] collaborative trace of bees whereby up to 60,000 bees work together in a colony for the greater [14:40.520 --> 14:47.140] good of the community. Similarly, we think that collaboration is probably the most important [14:47.140 --> 14:55.640] part of cyber security. And while I don't know the exact numbers, just looking around DEF CON, I [14:55.640 --> 15:01.900] can see why. There's quite a hive of hackers around here. That's enough about me, back to [15:01.900 --> 15:08.480] Cloud Query. For our initial strategy, we decided to be as lazy as possible. And trust me, [15:08.480 --> 15:14.180] being lazy is a good thing here. We wanted to avoid reinventing the wheel and wanted to use [15:14.180 --> 15:20.640] known tools as much as possible, such as Truffle Hog, but we quickly realized that this was not [15:20.640 --> 15:27.860] going to work. In fact, the tools which we tried to use were quite slow and produced loads of [15:27.860 --> 15:33.140] false positives. And while we could have worked through the false positives, the fact that [15:33.140 --> 15:37.960] the tools were slow was the main issue because slow scanning times meant that our EC2 [15:37.960 --> 15:43.580] instances ran longer, which in turn meant that our AWS bill would have been way higher, [15:43.580 --> 15:52.400] leaving us broke and lazy rather than just lazy. So, with this in mind, we had to pivot and we [15:52.400 --> 15:58.780] went back to the Zen of Python. More specifically, the following section of it. Simple is [15:58.780 --> 16:04.660] better than complex, complex is better than complicated, and special cases aren't special [16:04.660 --> 16:11.460] enough to break the rules. So, with this in mind, we reduced our scope even further and became [16:11.460 --> 16:18.640] even lazier. We ended up only looking for specific types of files or directories, such as, [16:18.640 --> 16:23.900] uh, well, environment secrets, secrets leaked within Git repositories, AWS credentials, [16:23.900 --> 16:31.780] private keys, and a few others. Now we faced another issue, and that is finding the right [16:31.780 --> 16:37.900] tool for this. We had to find a tool which allowed us to search for files and directories on [16:37.900 --> 16:44.760] the file system based on their names. The tool had to be quick and simple. So, you can [16:44.760 --> 16:50.700] probably see where I'm going with this. We ended up using the native Unix utility, find, of [16:50.700 --> 16:57.580] course. So, uh, we, we skipped the Windows directory, program files directories because [16:57.580 --> 17:03.360] they're full of junk and slow down our scans. We skipped everything about, above 25 [17:03.360 --> 17:08.300] megabytes because, well, this is only a proof of concept. We don't need to find everything [17:08.300 --> 17:15.720] really. And searched for all of these various files and directories. So, besides our, well, [17:15.720 --> 17:20.900] proprietary and very complex use of find, and I'm only joking as well, it's not that complex, [17:20.900 --> 17:27.320] we had to set up a few other things. And one of them was an automation for verifying [17:27.320 --> 17:33.940] AWS credentials. And you'll see in a minute exactly why we needed that. Secondly, we used [17:33.940 --> 17:41.400] Git leaks for checking Git repositories for secrets. Also, we had to set up a few other [17:41.400 --> 17:47.220] automations for verifying API keys and other types of credentials. And for this we used [17:47.220 --> 17:54.000] key hacks, which is a fantastic repository of methods for validating keys and credentials. [17:54.540 --> 18:00.780] However, even if we had all of these automations set up, we're still left with, well, a [18:00.780 --> 18:07.680] shit load of manual work to be fair. So, following our data collection phase, we were left [18:07.680 --> 18:14.900] with 2 million generic API keys, and of course many of them are false positives. Over 100,000 [18:14.900 --> 18:21.980] potential AWS credentials, several private keys, you can see some slack tokens, Stripe, [18:21.980 --> 18:26.520] Telegram, and so on and so forth. So you can probably see why we needed all of these [18:26.520 --> 18:34.180] automations for validating the keys and credentials. So, out of the about 100,000 AWS [18:34.180 --> 18:42.940] credentials, only about 120 of them were valid, out of which 20 were root. Now, I know that [18:42.940 --> 18:51.620] this does not seem like a lot. I mean, what is, 120 out of 100,000 is nothing, right? But, [18:51.620 --> 19:00.760] think about it this way. These, these keys allowed us to access the AWS accounts of over 100 [19:00.760 --> 19:07.540] companies. So this gave us initial access there, and for 20 of them we had absolute complete [19:07.540 --> 19:16.760] control. So, let that sink in for a bit. Now, we face another issue, and that is identifying the [19:16.760 --> 19:23.820] donors. And for this, we used the get contact information call, which gave us, well, the [19:23.820 --> 19:29.780] company name, in some cases the name of the contact, phone number, email address, and so on [19:29.780 --> 19:38.200] and so forth. So with this in mind, we found something surprising. And that is, that it's [19:38.200 --> 19:43.700] not only small boutique like companies affected by this. In fact, many of the companies are [19:43.700 --> 19:50.920] on the Fortune 500 list. Some of the most valuable ones were worth 200, respectively 50 [19:50.920 --> 19:56.480] billion dollars. We found three large telecom companies, which you've definitely heard [19:56.480 --> 20:00.700] about in the past. Ten relevant security and tech companies, and several others in [20:00.700 --> 20:07.260] consulting, education, health, manufacturing. Now, unfortunately, we cannot disclose much [20:07.260 --> 20:11.440] more about the companies at the moment, but maybe in the coming weeks or months we will be [20:11.440 --> 20:19.080] able to do so. Now, you may ask, well, anybody can write whatever they like in the contact [20:19.080 --> 20:25.700] information in the AWS account, right? And you're absolutely right. And then our efforts [20:25.700 --> 20:31.720] for identifying the owners could have been completely in vain. However, here is where our [20:31.720 --> 20:36.140] OSINT came in. We did quite a bit of OSINT, went on social media, including LinkedIn, and [20:36.140 --> 20:40.800] found several of these owners. Funnily enough, many of them had several AWS [20:40.800 --> 20:45.720] certifications on their accounts, suggesting that they are security aware and know how to [20:45.720 --> 20:54.040] properly configure their AWS accounts. Now, one of these companies, which was and still is [20:54.040 --> 21:01.340] actually on the Fortune 500 list, had a program on bug crowd. So we reported it. And this way [21:01.340 --> 21:06.860] we got our first P1, our first confirmed critical vulnerability on a bug bounty platform. [21:06.920 --> 21:16.350] That was actually fantastic for us. Oh, thank you. Thank you. Now, let's see, how much do you [21:16.350 --> 21:21.710] guys think we made out of it? So who thinks we made between $10,000 and $100,000? So let's [21:21.710 --> 21:27.310] say five digits. Yeah, only a few hands up. Maybe four digits, so a thousand and ten [21:27.310 --> 21:33.650] thousand. Right, a few more. Well, let's say AWS or cloud in general is niche, maybe they [21:33.650 --> 21:40.210] don't really care about these accounts. Maybe three digits? Okay, yeah, that's pretty low. [21:41.150 --> 21:50.230] Yeah, we made zero dollars out of it, nothing. Yeah, thank you, absolutely. Well, to be [21:50.230 --> 21:56.110] fair, there's a bit of a catch. It wasn't a bug bounty program, it was a vulnerability [21:56.110 --> 22:02.710] discloser program. And we weren't too disappointed, to be fair, because we didn't really aim to [22:02.710 --> 22:08.270] make money out of this research. We just wanted to make the internet a safer place, although [22:08.270 --> 22:14.390] this sounds a bit cliche. But still, we quickly forgot about this because we found something [22:14.390 --> 22:20.710] else which I think was more interesting than this. I like to call this story how we earned and [22:20.710 --> 22:25.950] lost three million dollars in a week. And, well, we're in Vegas right now, we all know a [22:25.950 --> 22:31.890] thing or two about losing and earning money quickly, right? Maybe not quite three million [22:31.890 --> 22:38.230] dollars. For a bit of context, we found this company which had a public AMI, there was a [22:38.230 --> 22:46.530] Git repository within that AMI, and within the Git repository we found a Stripe API key. And for [22:46.530 --> 22:52.170] those of you who don't know, Stripe is a payment service not unlike PayPal. So our first [22:52.170 --> 22:59.010] thought was, okay, let's run a balance call to the API and that's what we got. Seven digits in [22:59.010 --> 23:04.890] the USD currency. So what looked like 3.1 million dollars. Fantastic. So our first thought, [23:04.890 --> 23:11.270] of course, was, well, how would a threat actor go about transferring these funds into their own [23:11.270 --> 23:16.430] account? For research purposes only, trust me. Only research. So we went to the [23:16.430 --> 23:25.090] documentation and we quickly realized that the amount is in cents. So what we thought was [23:25.090 --> 23:32.710] 3.1 million was actually 31,000. Of course we were very disappointed. We had to get over the [23:32.710 --> 23:38.550] disappointment that our net worth reduced from 3.1 million to 31,000 by simply reading the [23:38.550 --> 23:44.970] documentation. So if there's any conclusion here, don't read the documentation. Just [23:44.970 --> 23:50.190] joking, of course. So we wrote an e-mail to their security contact, let them know what's up [23:50.830 --> 23:58.030] and waited and waited and waited. And all we got was radio silence for a few weeks. It was [23:58.030 --> 24:02.350] pretty annoying to be fair. We thought, well, did we do something wrong? Didn't we prove [24:02.350 --> 24:11.510] impact? So we thought of proving impact and that's what we did. We, or I, registered to their [24:11.510 --> 24:22.210] cheapest plan which was 9.99 per month, confirmed the transaction from the API and did a [24:22.210 --> 24:28.990] refund call which was successful. Fantastic. And a second level of validation was that the [24:28.990 --> 24:33.410] transaction was reverted. So my money was back in my account and I could still use their [24:33.410 --> 24:38.370] services which I didn't do because I didn't need their services. But now this was a bingo [24:38.370 --> 24:43.810] moment for us because we knew that we can talk about money. So we contacted the CEO but for [24:43.810 --> 24:48.750] this we had to go on LinkedIn, found the CEO, do a bit of OSINT, get their e-mail address and [24:48.750 --> 24:54.130] write to them. And guess what? Within a couple of hours we got a response where he also [24:54.130 --> 25:02.270] cc'd the CTO and asked us for more info. And we provided more info. We gave them a comprehensive [25:02.270 --> 25:10.370] report including the finding, the impact of the finding and steps for remediating this. And [25:10.370 --> 25:15.950] what we got in response was a pretty dry message from the CTO saying, thanks for sharing the [25:15.950 --> 25:22.710] relevant information, we have made the AMI private. For now? What? For now? Okay. And we'll [25:22.710 --> 25:30.590] be replacing the keys. Thanks so much for responsible disclosure. We took that as a thanks [25:30.590 --> 25:35.930] bye. And yeah, honestly we were a bit disappointed but we had a lot of research to do. We had [25:35.930 --> 25:40.290] to go back to our research and just dig through the 500 gigabytes of data which we already [25:40.290 --> 25:48.550] got. However, one month later I was forced to remember the issue. I checked my bank account [25:49.710 --> 25:54.690] and there's a 999 transaction. So I was so excited about being able to do the refund that I [25:54.690 --> 26:04.130] completely forgot to cancel my subscription. Well, remember that we are fairly broke so I [26:04.130 --> 26:09.390] didn't want to let 999 go by just like that. So I went back into the API, did the same call [26:09.390 --> 26:20.430] again and guess what? Money was back in my account. Yes, thank you. Yep. Well, we were [26:20.430 --> 26:25.510] disappointed initially by the dry response. But you cannot even imagine our disappointment [26:25.510 --> 26:33.210] that the issue was still not fixed one month later. Now, there's way more impact than just [26:33.210 --> 26:39.050] this. Think about it this way. We had to spawn several EC2 instances in our account, we got a [26:39.050 --> 26:47.250] bill of 500 dollars which, well, I'd have preferred to avoid. So yeah, if we weren't ethical, we [26:47.250 --> 26:54.350] could have went and used the victim, so to speak, AWS accounts to do this research for free. [26:54.950 --> 27:03.130] Now, a second potential area of impact which I think has a bit more potential, well, AWS [27:03.130 --> 27:09.890] based ransomware. And this way I could have come to DEF CON for free. So typically when we [27:09.890 --> 27:16.150] think about ransomware, we think about these teams of developers working 24 7, working on [27:16.150 --> 27:21.650] evasion and stuff like that. Perhaps when we talk about ransomware as a service, they're [27:21.650 --> 27:30.490] using 24 7 customer support teams and call centers. Well, in here, with access to the [27:30.490 --> 27:37.590] profiles, to the accounts, we could have used this, well, one liner or four liner, depends how [27:37.590 --> 27:46.130] you write it, to list every S3 bucket within the accounts, copy all of the data to the [27:46.150 --> 27:53.810] local systems and then remove all the data. Now, instead of the data which they expect to [27:53.810 --> 27:58.250] have on their accounts, they could find something along these lines, a ransom note. All your [27:58.250 --> 28:02.470] files have been stolen. You must buy us a Romania Las Vegas ticket to get your files. And [28:02.470 --> 28:06.990] honestly, that would have been pretty reasonable. It's only what, 500, a thousand dollars? So [28:06.990 --> 28:14.630] yeah, pretty decent ransom. And I need this disclaimer here, this is just a joke. We didn't do [28:14.630 --> 28:21.010] this and we wouldn't do this, but it's pretty cool that we could have done this, right? Now, [28:21.010 --> 28:28.050] Edward, want to take over? So, the research was done, we collected the data, we found [28:28.050 --> 28:35.050] secrets, we validated them, but we wanted to bring down the impact of the affected companies [28:35.050 --> 28:41.690] before we published the research. So, we looked for contact details and we couldn't find [28:41.690 --> 28:47.650] many. We had to search for websites to go find their contact information, give some [28:47.650 --> 28:54.650] generic e-mail just to make sure we don't give out too much information to someone that [28:54.650 --> 28:59.590] doesn't need to know it. So we sent almost 70 responsible disclosure e-mails and we [28:59.590 --> 29:04.470] received less than ten responses. We had to do some weird things like contacting the [29:04.470 --> 29:09.070] national search for one company, scheduled a sales call just to tell them about the [29:09.070 --> 29:15.170] vulnerability, and 90 days later after we did all this, only ten AWS keys were [29:15.170 --> 29:24.090] invalidated. So, that sucked and it's like companies are using AWS and they are ignoring [29:24.090 --> 29:28.210] responsible disclosure, they don't have contact details, they never wrote access keys and [29:28.210 --> 29:33.710] they are like, man, this cloud thing is so unsafe. It's not like that, right? And in a [29:33.710 --> 29:39.710] desperate attempt to invalidate more keys, we notified AWS security team and we were [29:39.710 --> 29:47.570] like, I know this is weird but we got 120 access keys that are valid. Here is the proof. [29:48.350 --> 29:54.410] Can you invalidate them? We have a research we want to publish. And the AWS security team, [29:54.410 --> 30:00.830] the most amazing team we worked with, they made me rethink about the whole responsible [30:00.830 --> 30:06.210] disclosure process. And after a few days after contacting them, more than 60 AWS keys were [30:06.210 --> 30:11.850] invalidated. We had a meeting about the research, we provided some ideas, we discussed fixes [30:11.850 --> 30:19.130] and it was overall an amazing experience and I want to give a huge shout out to Christian [30:19.130 --> 30:25.550] Sever from AWS security team and AWS security outreach team. So, please give them a round of [30:25.550 --> 30:33.450] applause. Thank you. Now, to discuss a bit about detecting and defending against this and [30:33.450 --> 30:40.570] let's start with defending. So, if your AWS account has this yellow warning signs, you [30:41.390 --> 30:47.590] might want to look into it. So, the settings block public access for AMIs and ABS snapshots [30:47.590 --> 30:53.830] should be enabled. They should look like this. They should have this green check mark. You [30:53.830 --> 30:59.850] can also use the CLI to validate if you have public AMIs. Make sure to check every region [31:00.450 --> 31:06.430] and make sure to check for deprecated images. You have to be careful about this because one [31:06.430 --> 31:11.930] technique attackers are using to exfiltrate data is by making AMIs public and accessing them [31:11.930 --> 31:17.870] from their account. And if that happens to you, you should look in CloudTrail for this [31:17.870 --> 31:23.610] event, shared snapshot volume created. This is the only event you get in CloudTrail if someone [31:23.610 --> 31:29.690] accesses your public AMI. And it doesn't have a lot of information. As you can see, the IP [31:29.690 --> 31:38.490] address is hidden which I get it. It's protecting the customer that is accessing the AMI. That [31:38.490 --> 31:43.810] is cool. But the only identifiable information you have is the account ID which you can't do [31:43.810 --> 31:50.310] much with it. So, better be careful, better protect your account and enable the settings if [31:50.310 --> 31:59.210] you don't plan to publish AMIs or ABS snapshots. Now, we have a lot of data and we did other [31:59.210 --> 32:07.450] research with it. And one idea we had was, so we had 20K JSON web tokens and we looked if [32:07.450 --> 32:12.370] there are any tokens that were not expired, maybe they had some secrets in them, any other [32:12.370 --> 32:18.330] misconfigurations but nothing came out of it. However, it was a good try. Next, we looked [32:18.330 --> 32:24.130] through our 4K unique SSH private keys. We generated public keys and a figure print and we [32:24.130 --> 32:30.550] searched on showdown but nothing came out of it. One idea was to perform the same scan from [32:30.550 --> 32:36.710] within the AWS network. Maybe that's how we might find some servers but that was just too [32:36.710 --> 32:44.510] much work and it wasn't worth it. Another cool idea we had but we haven't started this yet. So, [32:44.510 --> 32:49.630] we collected a lot of private, a lot of repositories and some of them are surely private. [32:49.770 --> 32:54.810] We wanted to identify the private repositories to identify the deployed web application in [32:54.810 --> 33:01.390] the wild and then perform source code review in order to find some vulnerabilities, get some [33:01.390 --> 33:13.890] CVs, get some bounties, but that is a lot of work and we are keeping it for later. And that [33:13.890 --> 33:19.930] on the topic of further research. Well, we still have about 500 gigabytes of potential [33:19.930 --> 33:25.450] secrets and we tried our best to dig through that data but there's definitely way more to [33:25.450 --> 33:31.850] find. Moreover, our colleague from KPMG Romania, Stefan Tito, worked on some similar [33:31.850 --> 33:38.050] research on Azure and we are looking forward to his research being published as well in the [33:38.050 --> 33:45.630] near future. Also, we will soon make a word list public with all the files which we found in [33:45.630 --> 33:53.130] all these public AMIs which we scanned. Now, going back to the research objectives formulated [33:53.130 --> 33:58.850] by Edward at the beginning of this talk, we aim to dig for secrets in every public AMI across [33:58.850 --> 34:07.870] all AWS regions. And while we didn't dig into all public AMIs, we dug into all public AMIs which [34:07.870 --> 34:13.930] we found interesting. So I'd say that this was achieved. Also, we aim to have fun. And, [34:13.930 --> 34:18.770] yeah, we did. We found a lot more stuff than we expected. It was a roller coaster and [34:18.770 --> 34:26.670] thanks, Edward, for this. Lastly, responsible disclosure. Well, I was a bit disappointed by [34:26.670 --> 34:33.330] the responsible disclosure process in general. Well, many of the owners didn't respond to [34:33.330 --> 34:41.610] us. Others, well, didn't have any sort of information for us to contact them. However, the [34:41.610 --> 34:47.550] experience of responsibly disclosing this to the AWS team definitely made up for all of the [34:47.550 --> 34:53.910] less pleasant experiences, so this was definitely achieved as well. Now that we are [34:53.910 --> 35:00.630] approaching the end of this talk, here are our conclusions. Firstly, the impact of this [35:00.630 --> 35:09.370] research is not yet fully uncovered. There's still way more to find out there. We have found [35:09.370 --> 35:14.810] several secrets already in the data which we collected. There's definitely more in the [35:14.810 --> 35:18.690] data which we already collected, but there's definitely way more out there which we did not [35:18.690 --> 35:24.390] collect yet. Potentially a nice area of research would be continuously monitoring new [35:24.390 --> 35:31.370] AMIs becoming public. Secondly, security by obscurity is definitely insufficient. So many [35:31.370 --> 35:35.990] developers definitely thought that their Git repositories were safe because they're private, [35:35.990 --> 35:42.330] right? But how is anything private if it's placed in a public resource? Also, you may be [35:42.330 --> 35:48.870] thinking, hey, I won't be a target of this, right? Nobody cares about my AMIs. Well, think [35:48.870 --> 35:54.470] about it this way. Edward and I, two cyber security guys from Romania, were able to do this. [35:54.650 --> 36:00.730] Think about what threat actors could do. So definitely don't make your AMIs public if you [36:00.730 --> 36:09.330] don't have to. Now, AMIs are only the tip of the iceberg here. There are still a lot of other [36:09.330 --> 36:15.650] interesting things to find across several other public cloud providers. Who knows, maybe [36:15.650 --> 36:21.850] next year we'll be back here talking about how we dug for secrets in a different cloud [36:21.850 --> 36:28.310] resource. And still we encourage you to do your own research as well. And please let us know if [36:28.310 --> 36:35.090] you have any sort of ideas. We're happy to help. Actually, going back to my initial point [36:35.090 --> 36:42.110] within the secret searcher section, collaboration is definitely the most important aspect of [36:42.110 --> 36:47.010] cyber security. So please connect with us. Let us know if you need any help with any sort of [36:47.010 --> 36:52.630] research in the future. And we'll definitely be happy to help. This being said, thank you [36:52.630 --> 37:11.650] very much everybody. We appreciate you being here. Any questions? Yep. Sure. Go ahead. Is [37:11.650 --> 37:18.630] the mic on? Not yet. Can we get the question mic on please? [37:25.690 --> 37:42.160] Perhaps just speak really loudly. We don't know. So we didn't perform any calls beside the [37:42.160 --> 37:48.200] contact information. So we tried to get security operation and another type of contact [37:48.200 --> 37:52.940] details but we didn't check the permissions. I'm sure for some of them we surely could [37:52.940 --> 37:59.680] have but that was too much because surely there was some automation based on the access [37:59.680 --> 38:07.900] keys and we might have broken something. Also please note that just having the S3 ransomware [38:07.900 --> 38:12.300] sort of code in my terminal got my adrenaline rushing. So we didn't try to do anything like [38:12.300 --> 38:22.920] that. Yes. I didn't have the permission to do anything like that. So I don't know if you [38:22.940 --> 38:40.720] have to. I wanted to. I'm looking for new opportunities. If you have something in mind in [38:40.720 --> 38:45.900] the offensive security, cloud research or cloud security, just give me a message and I'll [38:45.900 --> 38:54.960] start applying next week. So thanks. Cool. Any other questions? [38:57.080 --> 39:08.820] Yes please. No and to be fair we didn't even expect that. I mean we had KPMG for that. So [39:08.820 --> 39:13.780] thanks KPMG and uh we are waiting some t-shirts from the companies we disclosed this. Thank [39:13.780 --> 39:24.350] you. Cool. Mic's working so if anybody has any questions you can speak in the mic. Cool. [39:24.350 --> 39:27.910] Doesn't look like any other questions. We'll just be around here so please let us know [39:27.910 --> 39:30.290] guys. Nice talking to you. Thank you.