1 00:00:00,660 --> 00:00:02,160 Hello DEF CON. 2 00:00:02,380 --> 00:00:04,860 So, I'm very happy to be here. 3 00:00:04,860 --> 00:00:09,120 This has been a dream of mine for many, many years. 4 00:00:09,240 --> 00:00:11,540 And thanks for being part of it. 5 00:00:11,760 --> 00:00:19,800 This research is about a cool story about secrets in public cloud resources. 6 00:00:19,980 --> 00:00:29,900 And you know, who thinks we will never run out of customers public, public, sharing secrets in public cloud resources? 7 00:00:31,060 --> 00:00:34,440 Yeah, I think, I think we will never run out of that. 8 00:00:34,740 --> 00:00:38,020 And um, my name is Eduard Agavriluai. 9 00:00:38,020 --> 00:00:42,980 I was a senior penetration tester at KPMG Romania while I've done this research. 10 00:00:42,980 --> 00:00:48,800 A huge shout out to them for supporting the research and trusting this idea. 11 00:00:49,080 --> 00:00:51,500 I was also a contractor at Syncubes. 12 00:00:51,500 --> 00:00:55,880 I mean, I still am and I'm doing offensive cloud projects there. 13 00:00:55,880 --> 00:00:59,780 I also worked one month at CrowdStrike but I resigned on Friday. 14 00:00:59,780 --> 00:01:09,990 So, so I'm open for new opportunities and um, yeah, I'm trying to do some cloud security research. 15 00:01:10,730 --> 00:01:19,330 Now, I started um, a cloud configuration review for a customer of Syncubes. 16 00:01:19,610 --> 00:01:31,130 And um, I got the initial access um, and I started using uh, Scoutsuite as I uh, always uh, as I always do. 17 00:01:31,130 --> 00:01:33,490 And um, I checked the report. 18 00:01:33,490 --> 00:01:38,370 I saw the S3 findings, the CloudTrail findings, the YAM findings. 19 00:01:38,370 --> 00:01:45,250 And when I looked at the EC2 dashboard, I saw for the first time, the critical finding AMI is set to public. 20 00:01:45,250 --> 00:01:48,510 And who knows what an AMI is? 21 00:01:49,150 --> 00:01:50,250 Okay, cool. 22 00:01:50,250 --> 00:01:54,370 And um, who used at least once an EC2 instance? 23 00:01:54,590 --> 00:02:04,690 Okay, so if you used an EC2 instance, you kind of know what an AMI is because every time you start an EC2 instance, you are using an AMI. 24 00:02:04,690 --> 00:02:17,670 It's like a snapshot of a virtual machine and you can pre-configure an AMI to contain your applications, secrets, um, so to have a baseline right? 25 00:02:17,670 --> 00:02:21,190 And then you can start new EC2 instances starting from this AMI. 26 00:02:21,190 --> 00:02:28,750 And you have AWS Marketplace AMI that are official and from trusted vendors which are the recommended ones you can use. 27 00:02:28,750 --> 00:02:33,430 And you can also have community AMIs that are published by anyone. 28 00:02:33,890 --> 00:02:42,390 And you have to be careful with uh, with them because if you don't trust the publisher, you might have some back doors, malware and so on. 29 00:02:42,390 --> 00:02:48,610 But in any case, the thing is that an AMI can be public or private. 30 00:02:48,610 --> 00:02:52,610 And by default, they are private and it's actually hard to make one public. 31 00:02:52,610 --> 00:02:55,510 And I think you can see where I'm going with this. 32 00:02:55,650 --> 00:02:57,890 The issue is that they can be public. 33 00:02:57,890 --> 00:03:10,470 And this customer had five public AMIs um, exposed for multiple years and when I asked them, hey, can I take a look inside the AMIs to see what's inside of them? 34 00:03:10,470 --> 00:03:12,250 And um, they were like, no. 35 00:03:12,250 --> 00:03:14,650 So I regretted I even asked. 36 00:03:14,750 --> 00:03:18,570 But I got this question, what was inside the AMIs? 37 00:03:18,570 --> 00:03:27,010 And this actually gave me the research idea if there are other companies with secrets in public AMIs out there. 38 00:03:27,450 --> 00:03:52,190 So um, first we wanted to do this research so bad that we haven't checked any previous work but when we are, when we were in the middle of it, we discovered the work done by Dolev Farhi who scanned based on keywords AMIs in a single AWS region which was fine but it was not enough from our perspective. 39 00:03:52,310 --> 00:04:02,530 And also the work done by Ben Morris who searched secrets in public ABS snapshots but we will see shortly that there is very little overlap between his work. 40 00:04:02,530 --> 00:04:11,490 And funny story, last day I was talking about the research with someone and he was like, hey, you know who did something similar? 41 00:04:12,010 --> 00:04:14,310 He searched public ABS snapshots. 42 00:04:14,310 --> 00:04:18,370 He's Ben and he pointed at someone and it was Ben Morris and he was like, yeah. 43 00:04:18,810 --> 00:04:20,810 And, sorry. 44 00:04:22,690 --> 00:04:25,890 So yeah, I've met Ben Morris. 45 00:04:26,110 --> 00:04:30,410 I've been saying his name a lot rehearsing the presentation. 46 00:04:30,410 --> 00:04:34,650 It was a pleasure to meet him in person. 47 00:04:34,650 --> 00:04:35,790 He's a lovely guy. 48 00:04:36,890 --> 00:04:46,470 Now, uh, we set some goals for the research to dig for secrets in every public AMI across all AWS regions to have some fun and do some responsible disclosure. 49 00:04:46,470 --> 00:04:53,190 We also had a hidden goal to get some bounties and uh, my colleague Matei will tell you more about it. 50 00:04:54,550 --> 00:05:10,290 Starting the research we had to collect every public AMI across all AWS regions and to do that you have to, you have to use the CLI because AWS automatically deprecates images after two years after they were published. 51 00:05:10,710 --> 00:05:15,330 And if they are deprecated you can find them in the web portal. 52 00:05:15,330 --> 00:05:18,550 Also customers can deprecate their images whenever they want. 53 00:05:18,550 --> 00:05:25,370 So you have to use the CLI and specify the flag include deprecated to make sure you get all the AMIs. 54 00:05:25,610 --> 00:05:41,970 And we did that and we got 3.1 million AMIs and uh, we were sure that this was too much for us to scan all of them and we started asking if we can remove AMIs based on the chances of having secrets. 55 00:05:41,970 --> 00:05:47,250 So we removed AMIs from marketplace, that left us with 1.5 million. 56 00:05:47,250 --> 00:05:52,930 We removed AMIs owned by AWS that were not in the marketplace, that left us with 1 million. 57 00:05:52,930 --> 00:06:11,810 And we went further and we removed the owners that had more than 50 public AMIs because honestly if you are a company and you have more than 50 public AMIs security wise you are in a point of no return or you are an official publisher, an unofficial publisher, 58 00:06:11,810 --> 00:06:12,530 right? 59 00:06:12,730 --> 00:06:16,250 And that left us with 27,000 AMIs. 60 00:06:16,370 --> 00:06:26,190 Now we did some sanity filtering because some AMIs had 17 volumes or volumes as big as 20 terabytes. 61 00:06:26,410 --> 00:06:34,170 Obviously I'm very curious what's inside of them but for our budget we had to remove them and that left us with 26,000 AMIs. 62 00:06:34,450 --> 00:06:38,550 Now the distribution from our list looks like this. 63 00:06:38,550 --> 00:06:40,850 Obviously the most AMIs were in U.S. 64 00:06:40,850 --> 00:06:53,430 East 1 and the region with the smallest number of AMIs was IL Central 1, Israel Central 1 with only 30 public AMIs after our filtering. 65 00:06:53,770 --> 00:06:59,830 And when I'm saying that we collected the AMIs this is what I mean by it. 66 00:06:59,830 --> 00:07:19,770 So we got the JSON definition for each AMI and you have a lot of information like the ones highlighted, the image ID, the information about the snapshot but you also have other important information like description, title and the owner of the AMI and we'll see how we can use that shortly. 67 00:07:20,910 --> 00:07:31,170 Now that we had our list we need a way to access the contents of the AMI and this should be time and cost effective, automated and as reliable as possible. 68 00:07:31,170 --> 00:07:41,270 And we looked for various methods some of them might work in certain situations but only the fourth option was the right one for us. 69 00:07:41,590 --> 00:07:48,830 So first we tried to copy the snapshot of the AMI in our own AWS account and download it. 70 00:07:48,830 --> 00:07:59,150 But even if the AMI is public the ABS snapshot is not by default and that's why it's very little overlap between our work and the work done by Ben Morris. 71 00:07:59,610 --> 00:08:08,210 Next we tried to start an EC2 instance based on the target AMI, create an ABS snapshot of its volume and download it. 72 00:08:08,210 --> 00:08:18,410 But we quickly realized that this would take a lot of time for an ABS snapshot of 100 gigabytes. 73 00:08:18,410 --> 00:08:26,670 It took around 20, 30 minutes to download and we were sure that AWS will block our IP since we are downloading terabytes of data. 74 00:08:26,670 --> 00:08:29,010 So definitely not an option. 75 00:08:29,010 --> 00:08:39,290 But we realized we had to operate as much as possible within the native AWS features to achieve the faster method. 76 00:08:39,290 --> 00:08:47,270 And we tried to start a new EC2 instance based on the target AMI and connect directly to the instance. 77 00:08:47,270 --> 00:08:53,230 But for some reason the instances were not in a state that allowed us to connect to them. 78 00:08:53,230 --> 00:08:58,050 Either through SSH or through SSM features it just didn't work. 79 00:08:58,150 --> 00:09:04,590 But we did a work around and we got to this method. 80 00:09:04,590 --> 00:09:06,810 So we have a secret search instance. 81 00:09:07,170 --> 00:09:14,430 We call it like this because it's an instance that we already have in our own AWS account and it's working. 82 00:09:14,430 --> 00:09:15,710 We can connect to it. 83 00:09:15,710 --> 00:09:25,190 And next we start an EC2 instance based on the target AMI, detach its volume and reattach it to our secret search instance where we can connect and analyze the data. 84 00:09:25,190 --> 00:09:36,610 It's like having a working laptop and someone brought a laptop that doesn't work but you can get out the hard disk and connect it to your laptop and basically that's how you can access the data. 85 00:09:36,610 --> 00:09:44,010 And everything is happening within the AWS environment so it was both fast and it was both as reliable as possible. 86 00:09:44,470 --> 00:09:49,810 Now I'll show you a demo on how you can manually access the contents of one AMI. 87 00:09:51,630 --> 00:09:53,850 Let me see if I can start this. 88 00:09:55,610 --> 00:09:58,410 So we can search based on the description. 89 00:09:58,410 --> 00:10:01,610 You can use this to target certain technologies or companies. 90 00:10:01,970 --> 00:10:13,510 You have to mention the right region because otherwise you will not find the AMI and you also have to specify the flag include deprecated to make sure you get all the images, right? 91 00:10:13,790 --> 00:10:23,670 If you know the AWS account ID, you can try to find all the images owned by that account so that might be useful for bug counter, right? 92 00:10:24,090 --> 00:10:27,710 But let's stick with our description based search. 93 00:10:27,710 --> 00:10:31,710 So let's try to copy the ABS snapshot as 94 00:10:35,150 --> 00:10:35,730 a first step. 95 00:10:35,730 --> 00:10:35,750 Let's try . 96 00:10:36,130 --> 00:10:44,590 So you will see that if you try to copy the snapshot in our own AWS account, we will get the error message source snapshot is not found. 97 00:10:44,590 --> 00:10:48,870 That's because the ABS snapshot is not public only the AMI is. 98 00:10:49,350 --> 00:11:04,050 Now we will do the method with the secret searcher instance so we have our instance that it's running and now we will start a new instance based on the target AMI and we will place it in the same availability zone as our secret searcher instance. 99 00:11:04,050 --> 00:11:10,730 You need the same availability zone to make sure you have, you can move the volume between the instances. 100 00:11:10,790 --> 00:11:20,130 Now, the instance is running, we will stop it and we will detach the volume and we will reattach it to the secret searcher instance. 101 00:11:21,210 --> 00:11:37,230 After you detach the volume, you can delete the EC2 instance that is based on the AMI if you want to reduce some cost but in any case, you can just attach the volume and then you can connect to it. 102 00:11:37,230 --> 00:11:43,490 We use the web portal because it was easier for the demo but you can also connect to SSH. 103 00:11:43,610 --> 00:11:52,050 A common error that we encountered was an ID collision between the new volume and the root volume that was attached to the instance. 104 00:11:52,250 --> 00:12:07,930 And we have to use all kinds of weird tools I have never heard about in order to fix this issue but once that is done, you will be able to mount the volume and connect, to mount the volume and access the files. 105 00:12:07,930 --> 00:12:12,330 And now that it's mounted, let's look for some AWS credentials, right? 106 00:12:12,350 --> 00:12:15,430 We found some and now let's check if they are valid. 107 00:12:15,430 --> 00:12:22,790 Because for some older instances, the secrets might not be valid anymore so every time you have to check them. 108 00:12:26,280 --> 00:12:29,080 So, surprise, yes, they are working. 109 00:12:29,080 --> 00:12:40,780 And that's exactly how we felt when we found our first AWS access keys and the same day we found ten other valid access keys so we realized that this was a big issue indeed. 110 00:12:41,380 --> 00:12:44,300 This is the high level architecture we put in place. 111 00:12:44,300 --> 00:13:02,820 We had a master EC2 instance where we ran our big script and in each region we started the secret searcher instance and then we started batches of 20 instances based on AMIs to make sure we reduced the time. 112 00:13:03,000 --> 00:13:11,540 And for each instance we detached the volume, we reattached it to the secret searcher instance where we will search for secrets and sensitive files. 113 00:13:12,300 --> 00:13:29,120 And after writing 1.2K lines of code, 14 days of scanning time and a bill of 450 dollars, we collected 500 gigabytes of carefully selected files and data um, that we had now to, to analyze. 114 00:13:29,120 --> 00:13:32,540 And I invite my colleague Matej Josic to tell you more about it. 115 00:13:32,680 --> 00:13:33,960 Thank you. 116 00:13:37,140 --> 00:13:38,260 Cool. 117 00:13:38,340 --> 00:13:41,200 Good morning everybody and thank you so much for being here. 118 00:13:41,200 --> 00:13:46,420 It's actually an absolute pleasure to be on stage at DEF CON 32. 119 00:13:46,640 --> 00:13:58,740 This is the secret searcher section where I'm going to talk about how we search for secrets, what sorts of secrets we found and what we were able to do with them. 120 00:14:00,200 --> 00:14:02,240 I am Matej Anthony-Josephs. 121 00:14:02,240 --> 00:14:12,640 I've been with KPMG for about a year and a half and I'd like to take this opportunity to thank them for the time and the budget for this project right here. 122 00:14:13,120 --> 00:14:21,960 Other than that I'm a senior security researcher with experience in pen testing, threat hunting, vulnerability management and a bit of people management as well. 123 00:14:23,200 --> 00:14:30,280 Now, completely unrelated to this research, I've also set up a company alongside my wife, Alexa. 124 00:14:30,340 --> 00:14:42,460 Our company is called Hivehack because we're absolutely fascinated by the collaborative trace of bees whereby up to 60,000 bees work together in a colony for the greater good of the community. 125 00:14:43,420 --> 00:14:49,280 Similarly, we think that collaboration is probably the most important part of cyber security. 126 00:14:50,140 --> 00:14:56,780 And while I don't know the exact numbers, just looking around DEF CON, I can see why. 127 00:14:56,860 --> 00:14:59,660 There's quite a hive of hackers around here. 128 00:15:00,120 --> 00:15:02,940 That's enough about me, back to Cloud Query. 129 00:15:03,360 --> 00:15:07,860 For our initial strategy, we decided to be as lazy as possible. 130 00:15:07,920 --> 00:15:10,340 And trust me, being lazy is a good thing here. 131 00:15:10,520 --> 00:15:21,780 We wanted to avoid reinventing the wheel and wanted to use known tools as much as possible, such as Truffle Hog, but we quickly realized that this was not going to work. 132 00:15:22,760 --> 00:15:28,980 In fact, the tools which we tried to use were quite slow and produced loads of false positives. 133 00:15:29,260 --> 00:15:46,940 And while we could have worked through the false positives, the fact that the tools were slow was the main issue because slow scanning times meant that our EC2 instances ran longer, which in turn meant that our AWS bill would have been way higher, leaving us broke and lazy rather than just lazy. 134 00:15:49,080 --> 00:15:54,720 So, with this in mind, we had to pivot and we went back to the Zen of Python. 135 00:15:54,720 --> 00:15:57,740 More specifically, the following section of it. 136 00:15:57,740 --> 00:16:06,520 Simple is better than complex, complex is better than complicated, and special cases aren't special enough to break the rules. 137 00:16:06,940 --> 00:16:12,800 So, with this in mind, we reduced our scope even further and became even lazier. 138 00:16:12,800 --> 00:16:26,600 We ended up only looking for specific types of files or directories, such as, uh, well, environment secrets, secrets leaked within Git repositories, AWS credentials, private keys, and a few others. 139 00:16:27,640 --> 00:16:32,840 Now we faced another issue, and that is finding the right tool for this. 140 00:16:32,840 --> 00:16:40,940 We had to find a tool which allowed us to search for files and directories on the file system based on their names. 141 00:16:41,140 --> 00:16:44,300 The tool had to be quick and simple. 142 00:16:44,300 --> 00:16:46,900 So, you can probably see where I'm going with this. 143 00:16:46,900 --> 00:16:51,460 We ended up using the native Unix utility, find, of course. 144 00:16:51,880 --> 00:17:00,900 So, uh, we, we skipped the Windows directory, program files directories because they're full of junk and slow down our scans. 145 00:17:00,940 --> 00:17:06,540 We skipped everything about, above 25 megabytes because, well, this is only a proof of concept. 146 00:17:06,540 --> 00:17:09,160 We don't need to find everything really. 147 00:17:09,160 --> 00:17:13,560 And searched for all of these various files and directories. 148 00:17:14,040 --> 00:17:24,100 So, besides our, well, proprietary and very complex use of find, and I'm only joking as well, it's not that complex, we had to set up a few other things. 149 00:17:24,100 --> 00:17:29,180 And one of them was an automation for verifying AWS credentials. 150 00:17:29,240 --> 00:17:32,360 And you'll see in a minute exactly why we needed that. 151 00:17:32,720 --> 00:17:37,580 Secondly, we used Git leaks for checking Git repositories for secrets. 152 00:17:38,740 --> 00:17:46,300 Also, we had to set up a few other automations for verifying API keys and other types of credentials. 153 00:17:46,300 --> 00:17:54,000 And for this we used key hacks, which is a fantastic repository of methods for validating keys and credentials. 154 00:17:54,540 --> 00:18:02,680 However, even if we had all of these automations set up, we're still left with, well, a shit load of manual work to be fair. 155 00:18:03,380 --> 00:18:12,900 So, following our data collection phase, we were left with 2 million generic API keys, and of course many of them are false positives. 156 00:18:13,160 --> 00:18:24,160 Over 100,000 potential AWS credentials, several private keys, you can see some slack tokens, Stripe, Telegram, and so on and so forth. 157 00:18:24,220 --> 00:18:29,740 So you can probably see why we needed all of these automations for validating the keys and credentials. 158 00:18:30,620 --> 00:18:41,300 So, out of the about 100,000 AWS credentials, only about 120 of them were valid, out of which 20 were root. 159 00:18:41,700 --> 00:18:45,180 Now, I know that this does not seem like a lot. 160 00:18:45,180 --> 00:18:49,980 I mean, what is, 120 out of 100,000 is nothing, right? 161 00:18:50,560 --> 00:18:53,240 But, think about it this way. 162 00:18:53,300 --> 00:19:01,940 These, these keys allowed us to access the AWS accounts of over 100 companies. 163 00:19:02,340 --> 00:19:08,540 So this gave us initial access there, and for 20 of them we had absolute complete control. 164 00:19:08,720 --> 00:19:11,100 So, let that sink in for a bit. 165 00:19:12,600 --> 00:19:17,600 Now, we face another issue, and that is identifying the donors. 166 00:19:18,120 --> 00:19:30,960 And for this, we used the get contact information call, which gave us, well, the company name, in some cases the name of the contact, phone number, email address, and so on and so forth. 167 00:19:31,640 --> 00:19:36,540 So with this in mind, we found something surprising. 168 00:19:37,120 --> 00:19:41,900 And that is, that it's not only small boutique like companies affected by this. 169 00:19:41,900 --> 00:19:45,760 In fact, many of the companies are on the Fortune 500 list. 170 00:19:46,300 --> 00:19:52,380 Some of the most valuable ones were worth 200, respectively 50 billion dollars. 171 00:19:52,940 --> 00:19:57,880 We found three large telecom companies, which you've definitely heard about in the past. 172 00:19:57,920 --> 00:20:03,520 Ten relevant security and tech companies, and several others in consulting, education, health, manufacturing. 173 00:20:04,340 --> 00:20:12,680 Now, unfortunately, we cannot disclose much more about the companies at the moment, but maybe in the coming weeks or months we will be able to do so. 174 00:20:12,800 --> 00:20:22,300 Now, you may ask, well, anybody can write whatever they like in the contact information in the AWS account, right? 175 00:20:22,300 --> 00:20:24,280 And you're absolutely right. 176 00:20:24,640 --> 00:20:28,920 And then our efforts for identifying the owners could have been completely in vain. 177 00:20:30,160 --> 00:20:32,820 However, here is where our OSINT came in. 178 00:20:32,820 --> 00:20:38,080 We did quite a bit of OSINT, went on social media, including LinkedIn, and found several of these owners. 179 00:20:38,200 --> 00:20:49,100 Funnily enough, many of them had several AWS certifications on their accounts, suggesting that they are security aware and know how to properly configure their AWS accounts. 180 00:20:50,320 --> 00:20:58,540 Now, one of these companies, which was and still is actually on the Fortune 500 list, had a program on bug crowd. 181 00:20:58,820 --> 00:21:00,440 So we reported it. 182 00:21:00,440 --> 00:21:06,860 And this way we got our first P1, our first confirmed critical vulnerability on a bug bounty platform. 183 00:21:06,920 --> 00:21:09,100 That was actually fantastic for us. 184 00:21:09,320 --> 00:21:10,540 Oh, thank you. 185 00:21:10,540 --> 00:21:11,400 Thank you. 186 00:21:14,250 --> 00:21:17,570 Now, let's see, how much do you guys think we made out of it? 187 00:21:17,570 --> 00:21:21,470 So who thinks we made between $10,000 and $100,000? 188 00:21:21,470 --> 00:21:22,830 So let's say five digits. 189 00:21:23,430 --> 00:21:25,190 Yeah, only a few hands up. 190 00:21:25,190 --> 00:21:28,150 Maybe four digits, so a thousand and ten thousand. 191 00:21:28,650 --> 00:21:30,130 Right, a few more. 192 00:21:30,130 --> 00:21:35,490 Well, let's say AWS or cloud in general is niche, maybe they don't really care about these accounts. 193 00:21:35,490 --> 00:21:36,850 Maybe three digits? 194 00:21:37,990 --> 00:21:40,210 Okay, yeah, that's pretty low. 195 00:21:41,150 --> 00:21:44,810 Yeah, we made zero dollars out of it, nothing. 196 00:21:45,230 --> 00:21:47,270 Yeah, thank you, absolutely. 197 00:21:47,870 --> 00:21:52,650 Well, to be fair, there's a bit of a catch. 198 00:21:52,650 --> 00:21:57,970 It wasn't a bug bounty program, it was a vulnerability discloser program. 199 00:21:58,410 --> 00:22:04,910 And we weren't too disappointed, to be fair, because we didn't really aim to make money out of this research. 200 00:22:04,910 --> 00:22:09,910 We just wanted to make the internet a safer place, although this sounds a bit cliche. 201 00:22:10,370 --> 00:22:17,550 But still, we quickly forgot about this because we found something else which I think was more interesting than this. 202 00:22:17,750 --> 00:22:22,930 I like to call this story how we earned and lost three million dollars in a week. 203 00:22:23,370 --> 00:22:29,370 And, well, we're in Vegas right now, we all know a thing or two about losing and earning money quickly, right? 204 00:22:30,470 --> 00:22:32,730 Maybe not quite three million dollars. 205 00:22:32,730 --> 00:22:45,670 For a bit of context, we found this company which had a public AMI, there was a Git repository within that AMI, and within the Git repository we found a Stripe API key. 206 00:22:45,910 --> 00:22:50,990 And for those of you who don't know, Stripe is a payment service not unlike PayPal. 207 00:22:51,490 --> 00:22:57,750 So our first thought was, okay, let's run a balance call to the API and that's what we got. 208 00:22:57,750 --> 00:23:00,510 Seven digits in the USD currency. 209 00:23:00,510 --> 00:23:02,610 So what looked like 3.1 million dollars. 210 00:23:02,610 --> 00:23:03,490 Fantastic. 211 00:23:03,650 --> 00:23:11,930 So our first thought, of course, was, well, how would a threat actor go about transferring these funds into their own account? 212 00:23:11,930 --> 00:23:14,150 For research purposes only, trust me. 213 00:23:14,150 --> 00:23:15,450 Only research. 214 00:23:15,630 --> 00:23:21,870 So we went to the documentation and we quickly realized that the amount is in cents. 215 00:23:23,670 --> 00:23:28,010 So what we thought was 3.1 million was actually 31,000. 216 00:23:28,290 --> 00:23:30,510 Of course we were very disappointed. 217 00:23:31,390 --> 00:23:39,670 We had to get over the disappointment that our net worth reduced from 3.1 million to 31,000 by simply reading the documentation. 218 00:23:39,730 --> 00:23:43,530 So if there's any conclusion here, don't read the documentation. 219 00:23:44,390 --> 00:23:46,170 Just joking, of course. 220 00:23:46,590 --> 00:23:54,130 So we wrote an e-mail to their security contact, let them know what's up and waited and waited and waited. 221 00:23:55,090 --> 00:23:57,690 And all we got was radio silence for a few weeks. 222 00:23:57,690 --> 00:23:59,570 It was pretty annoying to be fair. 223 00:23:59,630 --> 00:24:01,810 We thought, well, did we do something wrong? 224 00:24:01,810 --> 00:24:03,270 Didn't we prove impact? 225 00:24:03,710 --> 00:24:06,790 So we thought of proving impact and that's what we did. 226 00:24:07,930 --> 00:24:24,290 We, or I, registered to their cheapest plan which was 9.99 per month, confirmed the transaction from the API and did a refund call which was successful. 227 00:24:24,830 --> 00:24:25,550 Fantastic. 228 00:24:25,550 --> 00:24:30,030 And a second level of validation was that the transaction was reverted. 229 00:24:30,030 --> 00:24:36,690 So my money was back in my account and I could still use their services which I didn't do because I didn't need their services. 230 00:24:36,810 --> 00:24:41,330 But now this was a bingo moment for us because we knew that we can talk about money. 231 00:24:41,850 --> 00:24:49,630 So we contacted the CEO but for this we had to go on LinkedIn, found the CEO, do a bit of OSINT, get their e-mail address and write to them. 232 00:24:49,830 --> 00:24:50,670 And guess what? 233 00:24:50,670 --> 00:24:57,950 Within a couple of hours we got a response where he also cc'd the CTO and asked us for more info. 234 00:24:58,410 --> 00:25:00,150 And we provided more info. 235 00:25:00,550 --> 00:25:09,230 We gave them a comprehensive report including the finding, the impact of the finding and steps for remediating this. 236 00:25:09,770 --> 00:25:18,730 And what we got in response was a pretty dry message from the CTO saying, thanks for sharing the relevant information, we have made the AMI private. 237 00:25:18,730 --> 00:25:19,630 For now? 238 00:25:19,630 --> 00:25:20,290 What? 239 00:25:20,290 --> 00:25:21,090 For now? 240 00:25:21,090 --> 00:25:21,970 Okay. 241 00:25:22,090 --> 00:25:24,370 And we'll be replacing the keys. 242 00:25:25,250 --> 00:25:27,670 Thanks so much for responsible disclosure. 243 00:25:28,570 --> 00:25:31,410 We took that as a thanks bye. 244 00:25:31,990 --> 00:25:35,710 And yeah, honestly we were a bit disappointed but we had a lot of research to do. 245 00:25:35,710 --> 00:25:41,070 We had to go back to our research and just dig through the 500 gigabytes of data which we already got. 246 00:25:41,370 --> 00:25:46,510 However, one month later I was forced to remember the issue. 247 00:25:47,290 --> 00:25:51,910 I checked my bank account and there's a 999 transaction. 248 00:25:51,910 --> 00:25:57,530 So I was so excited about being able to do the refund that I completely forgot to cancel my subscription. 249 00:25:58,730 --> 00:26:06,850 Well, remember that we are fairly broke so I didn't want to let 999 go by just like that. 250 00:26:06,850 --> 00:26:11,170 So I went back into the API, did the same call again and guess what? 251 00:26:11,270 --> 00:26:13,230 Money was back in my account. 252 00:26:14,070 --> 00:26:15,830 Yes, thank you. 253 00:26:16,070 --> 00:26:17,010 Yep. 254 00:26:18,610 --> 00:26:23,050 Well, we were disappointed initially by the dry response. 255 00:26:23,290 --> 00:26:30,250 But you cannot even imagine our disappointment that the issue was still not fixed one month later. 256 00:26:31,150 --> 00:26:34,130 Now, there's way more impact than just this. 257 00:26:34,230 --> 00:26:35,530 Think about it this way. 258 00:26:35,530 --> 00:26:43,830 We had to spawn several EC2 instances in our account, we got a bill of 500 dollars which, well, I'd have preferred to avoid. 259 00:26:44,010 --> 00:26:54,350 So yeah, if we weren't ethical, we could have went and used the victim, so to speak, AWS accounts to do this research for free. 260 00:26:54,950 --> 00:27:04,550 Now, a second potential area of impact which I think has a bit more potential, well, AWS based ransomware. 261 00:27:04,890 --> 00:27:07,510 And this way I could have come to DEF CON for free. 262 00:27:08,010 --> 00:27:17,930 So typically when we think about ransomware, we think about these teams of developers working 24 7, working on evasion and stuff like that. 263 00:27:17,930 --> 00:27:27,250 Perhaps when we talk about ransomware as a service, they're using 24 7 customer support teams and call centers. 264 00:27:27,350 --> 00:27:50,210 Well, in here, with access to the profiles, to the accounts, we could have used this, well, one liner or four liner, depends how you write it, to list every S3 bucket within the accounts, copy all of the data to the local systems and then remove all the data. 265 00:27:51,030 --> 00:27:57,970 Now, instead of the data which they expect to have on their accounts, they could find something along these lines, a ransom note. 266 00:27:57,970 --> 00:27:59,350 All your files have been stolen. 267 00:27:59,350 --> 00:28:02,310 You must buy us a Romania Las Vegas ticket to get your files. 268 00:28:02,310 --> 00:28:04,290 And honestly, that would have been pretty reasonable. 269 00:28:04,290 --> 00:28:06,750 It's only what, 500, a thousand dollars? 270 00:28:06,830 --> 00:28:08,710 So yeah, pretty decent ransom. 271 00:28:08,770 --> 00:28:13,190 And I need this disclaimer here, this is just a joke. 272 00:28:13,230 --> 00:28:19,350 We didn't do this and we wouldn't do this, but it's pretty cool that we could have done this, right? 273 00:28:20,350 --> 00:28:22,830 Now, Edward, want to take over? 274 00:28:24,090 --> 00:28:37,390 So, the research was done, we collected the data, we found secrets, we validated them, but we wanted to bring down the impact of the affected companies before we published the research. 275 00:28:37,390 --> 00:28:42,230 So, we looked for contact details and we couldn't find many. 276 00:28:42,230 --> 00:28:56,190 We had to search for websites to go find their contact information, give some generic e-mail just to make sure we don't give out too much information to someone that doesn't need to know it. 277 00:28:56,190 --> 00:29:01,470 So we sent almost 70 responsible disclosure e-mails and we received less than ten responses. 278 00:29:01,610 --> 00:29:16,230 We had to do some weird things like contacting the national search for one company, scheduled a sales call just to tell them about the vulnerability, and 90 days later after we did all this, only ten AWS keys were invalidated. 279 00:29:16,230 --> 00:29:31,030 So, that sucked and it's like companies are using AWS and they are ignoring responsible disclosure, they don't have contact details, they never wrote access keys and they are like, man, this cloud thing is so unsafe. 280 00:29:31,430 --> 00:29:32,990 It's not like that, right? 281 00:29:32,990 --> 00:29:45,650 And in a desperate attempt to invalidate more keys, we notified AWS security team and we were like, I know this is weird but we got 120 access keys that are valid. 282 00:29:45,650 --> 00:29:47,570 Here is the proof. 283 00:29:48,350 --> 00:29:49,750 Can you invalidate them? 284 00:29:49,750 --> 00:29:51,390 We have a research we want to publish. 285 00:29:51,550 --> 00:30:02,390 And the AWS security team, the most amazing team we worked with, they made me rethink about the whole responsible disclosure process. 286 00:30:02,510 --> 00:30:07,330 And after a few days after contacting them, more than 60 AWS keys were invalidated. 287 00:30:07,330 --> 00:30:24,070 We had a meeting about the research, we provided some ideas, we discussed fixes and it was overall an amazing experience and I want to give a huge shout out to Christian Sever from AWS security team and AWS security outreach team. 288 00:30:24,070 --> 00:30:26,630 So, please give them a round of applause. 289 00:30:27,590 --> 00:30:28,850 Thank you. 290 00:30:29,690 --> 00:30:34,810 Now, to discuss a bit about detecting and defending against this and let's start with defending. 291 00:30:34,810 --> 00:30:43,250 So, if your AWS account has this yellow warning signs, you might want to look into it. 292 00:30:43,250 --> 00:30:49,170 So, the settings block public access for AMIs and ABS snapshots should be enabled. 293 00:30:49,430 --> 00:30:50,430 They should look like this. 294 00:30:50,430 --> 00:30:53,430 They should have this green check mark. 295 00:30:53,690 --> 00:30:58,490 You can also use the CLI to validate if you have public AMIs. 296 00:30:58,490 --> 00:31:03,570 Make sure to check every region and make sure to check for deprecated images. 297 00:31:03,930 --> 00:31:13,530 You have to be careful about this because one technique attackers are using to exfiltrate data is by making AMIs public and accessing them from their account. 298 00:31:13,610 --> 00:31:20,630 And if that happens to you, you should look in CloudTrail for this event, shared snapshot volume created. 299 00:31:20,630 --> 00:31:26,070 This is the only event you get in CloudTrail if someone accesses your public AMI. 300 00:31:26,070 --> 00:31:28,270 And it doesn't have a lot of information. 301 00:31:28,430 --> 00:31:32,010 As you can see, the IP address is hidden which I get it. 302 00:31:32,010 --> 00:31:37,570 It's protecting the customer that is accessing the AMI. 303 00:31:38,350 --> 00:31:39,430 That is cool. 304 00:31:39,550 --> 00:31:45,170 But the only identifiable information you have is the account ID which you can't do much with it. 305 00:31:45,170 --> 00:31:55,210 So, better be careful, better protect your account and enable the settings if you don't plan to publish AMIs or ABS snapshots. 306 00:31:55,210 --> 00:32:01,190 Now, we have a lot of data and we did other research with it. 307 00:32:01,190 --> 00:32:14,710 And one idea we had was, so we had 20K JSON web tokens and we looked if there are any tokens that were not expired, maybe they had some secrets in them, any other misconfigurations but nothing came out of it. 308 00:32:14,710 --> 00:32:17,070 However, it was a good try. 309 00:32:17,390 --> 00:32:21,490 Next, we looked through our 4K unique SSH private keys. 310 00:32:21,490 --> 00:32:27,730 We generated public keys and a figure print and we searched on showdown but nothing came out of it. 311 00:32:27,910 --> 00:32:32,810 One idea was to perform the same scan from within the AWS network. 312 00:32:32,810 --> 00:32:39,530 Maybe that's how we might find some servers but that was just too much work and it wasn't worth it. 313 00:32:40,050 --> 00:32:43,690 Another cool idea we had but we haven't started this yet. 314 00:32:44,050 --> 00:32:49,630 So, we collected a lot of private, a lot of repositories and some of them are surely private. 315 00:32:49,770 --> 00:33:08,670 We wanted to identify the private repositories to identify the deployed web application in the wild and then perform source code review in order to find some vulnerabilities, get some CVs, get some bounties, but that is a lot of work and we are keeping it for later. 316 00:33:13,230 --> 00:33:15,910 And that on the topic of further research. 317 00:33:15,990 --> 00:33:26,470 Well, we still have about 500 gigabytes of potential secrets and we tried our best to dig through that data but there's definitely way more to find. 318 00:33:26,850 --> 00:33:39,270 Moreover, our colleague from KPMG Romania, Stefan Tito, worked on some similar research on Azure and we are looking forward to his research being published as well in the near future. 319 00:33:39,270 --> 00:33:49,290 Also, we will soon make a word list public with all the files which we found in all these public AMIs which we scanned. 320 00:33:49,610 --> 00:34:00,850 Now, going back to the research objectives formulated by Edward at the beginning of this talk, we aim to dig for secrets in every public AMI across all AWS regions. 321 00:34:01,130 --> 00:34:09,250 And while we didn't dig into all public AMIs, we dug into all public AMIs which we found interesting. 322 00:34:09,250 --> 00:34:11,450 So I'd say that this was achieved. 323 00:34:11,970 --> 00:34:13,590 Also, we aim to have fun. 324 00:34:13,590 --> 00:34:14,830 And, yeah, we did. 325 00:34:14,830 --> 00:34:17,350 We found a lot more stuff than we expected. 326 00:34:17,350 --> 00:34:20,310 It was a roller coaster and thanks, Edward, for this. 327 00:34:20,470 --> 00:34:22,950 Lastly, responsible disclosure. 328 00:34:23,690 --> 00:34:29,030 Well, I was a bit disappointed by the responsible disclosure process in general. 329 00:34:29,030 --> 00:34:34,210 Well, many of the owners didn't respond to us. 330 00:34:34,210 --> 00:34:38,830 Others, well, didn't have any sort of information for us to contact them. 331 00:34:39,750 --> 00:34:52,430 However, the experience of responsibly disclosing this to the AWS team definitely made up for all of the less pleasant experiences, so this was definitely achieved as well. 332 00:34:52,670 --> 00:34:58,470 Now that we are approaching the end of this talk, here are our conclusions. 333 00:34:59,050 --> 00:35:03,590 Firstly, the impact of this research is not yet fully uncovered. 334 00:35:04,110 --> 00:35:07,850 There's still way more to find out there. 335 00:35:08,190 --> 00:35:13,250 We have found several secrets already in the data which we collected. 336 00:35:13,350 --> 00:35:19,970 There's definitely more in the data which we already collected, but there's definitely way more out there which we did not collect yet. 337 00:35:20,230 --> 00:35:26,210 Potentially a nice area of research would be continuously monitoring new AMIs becoming public. 338 00:35:26,510 --> 00:35:30,410 Secondly, security by obscurity is definitely insufficient. 339 00:35:31,050 --> 00:35:36,350 So many developers definitely thought that their Git repositories were safe because they're private, right? 340 00:35:36,350 --> 00:35:39,750 But how is anything private if it's placed in a public resource? 341 00:35:41,110 --> 00:35:45,650 Also, you may be thinking, hey, I won't be a target of this, right? 342 00:35:45,650 --> 00:35:47,910 Nobody cares about my AMIs. 343 00:35:48,370 --> 00:35:49,970 Well, think about it this way. 344 00:35:49,970 --> 00:35:54,470 Edward and I, two cyber security guys from Romania, were able to do this. 345 00:35:54,650 --> 00:35:57,450 Think about what threat actors could do. 346 00:35:57,550 --> 00:36:02,230 So definitely don't make your AMIs public if you don't have to. 347 00:36:02,690 --> 00:36:07,210 Now, AMIs are only the tip of the iceberg here. 348 00:36:07,510 --> 00:36:14,130 There are still a lot of other interesting things to find across several other public cloud providers. 349 00:36:14,950 --> 00:36:22,870 Who knows, maybe next year we'll be back here talking about how we dug for secrets in a different cloud resource. 350 00:36:23,710 --> 00:36:27,050 And still we encourage you to do your own research as well. 351 00:36:27,050 --> 00:36:30,550 And please let us know if you have any sort of ideas. 352 00:36:30,550 --> 00:36:32,050 We're happy to help. 353 00:36:32,050 --> 00:36:43,330 Actually, going back to my initial point within the secret searcher section, collaboration is definitely the most important aspect of cyber security. 354 00:36:43,550 --> 00:36:44,930 So please connect with us. 355 00:36:44,930 --> 00:36:48,370 Let us know if you need any help with any sort of research in the future. 356 00:36:48,950 --> 00:36:51,110 And we'll definitely be happy to help. 357 00:36:51,110 --> 00:36:53,750 This being said, thank you very much everybody. 358 00:36:54,030 --> 00:36:55,710 We appreciate you being here. 359 00:37:05,790 --> 00:37:06,930 Any questions? 360 00:37:06,930 --> 00:37:07,590 Yep. 361 00:37:07,810 --> 00:37:08,410 Sure. 362 00:37:08,410 --> 00:37:09,110 Go ahead. 363 00:37:11,210 --> 00:37:12,650 Is the mic on? 364 00:37:16,270 --> 00:37:16,950 Not yet. 365 00:37:16,950 --> 00:37:18,630 Can we get the question mic on please? 366 00:37:25,690 --> 00:37:27,790 Perhaps just speak really loudly. 367 00:37:36,960 --> 00:37:38,280 We don't know. 368 00:37:38,280 --> 00:37:43,640 So we didn't perform any calls beside the contact information. 369 00:37:44,220 --> 00:37:50,720 So we tried to get security operation and another type of contact details but we didn't check the permissions. 370 00:37:50,720 --> 00:38:03,240 I'm sure for some of them we surely could have but that was too much because surely there was some automation based on the access keys and we might have broken something. 371 00:38:04,180 --> 00:38:10,620 Also please note that just having the S3 ransomware sort of code in my terminal got my adrenaline rushing. 372 00:38:10,620 --> 00:38:13,180 So we didn't try to do anything like that. 373 00:38:13,880 --> 00:38:14,400 Yes. 374 00:38:21,860 --> 00:38:22,920 I didn't have the permission to do anything like that. 375 00:38:22,920 --> 00:38:23,440 So I don't know if you have to. 376 00:38:23,440 --> 00:38:24,560 I wanted to. 377 00:38:37,620 --> 00:38:39,460 I'm looking for new opportunities. 378 00:38:39,460 --> 00:38:47,120 If you have something in mind in the offensive security, cloud research or cloud security, just give me a message and I'll start applying next week. 379 00:38:47,120 --> 00:38:48,620 So thanks. 380 00:38:52,940 --> 00:38:53,740 Cool. 381 00:38:53,740 --> 00:38:54,960 Any other questions? 382 00:38:57,080 --> 00:38:58,340 Yes please. 383 00:39:02,520 --> 00:39:05,280 No and to be fair we didn't even expect that. 384 00:39:05,300 --> 00:39:07,300 I mean we had KPMG for that. 385 00:39:08,360 --> 00:39:13,640 So thanks KPMG and uh we are waiting some t-shirts from the companies we disclosed this. 386 00:39:13,640 --> 00:39:14,340 Thank you. 387 00:39:18,190 --> 00:39:19,070 Cool. 388 00:39:19,070 --> 00:39:22,390 Mic's working so if anybody has any questions you can speak in the mic. 389 00:39:23,630 --> 00:39:24,350 Cool. 390 00:39:24,350 --> 00:39:25,810 Doesn't look like any other questions. 391 00:39:25,810 --> 00:39:28,590 We'll just be around here so please let us know guys. 392 00:39:28,870 --> 00:39:29,650 Nice talking to you. 393 00:39:29,650 --> 00:39:30,290 Thank you.