WEBVTT

00:00.660 --> 00:02.160
Hello DEF CON.

00:02.380 --> 00:04.860
So, I'm very happy to be here.

00:04.860 --> 00:09.120
This has been a dream of mine for many, many years.

00:09.240 --> 00:11.540
And thanks for being part of it.

00:11.760 --> 00:19.800
This research is about a cool story about secrets in public cloud resources.

00:19.980 --> 00:29.900
And you know, who thinks we will never run out of customers public, public, sharing secrets in public cloud resources?

00:31.060 --> 00:34.440
Yeah, I think, I think we will never run out of that.

00:34.740 --> 00:38.020
And um, my name is Eduard Agavriluai.

00:38.020 --> 00:42.980
I was a senior penetration tester at KPMG Romania while I've done this research.

00:42.980 --> 00:48.800
A huge shout out to them for supporting the research and trusting this idea.

00:49.080 --> 00:51.500
I was also a contractor at Syncubes.

00:51.500 --> 00:55.880
I mean, I still am and I'm doing offensive cloud projects there.

00:55.880 --> 00:59.780
I also worked one month at CrowdStrike but I resigned on Friday.

00:59.780 --> 01:09.990
So, so I'm open for new opportunities and um, yeah, I'm trying to do some cloud security research.

01:10.730 --> 01:19.330
Now, I started um, a cloud configuration review for a customer of Syncubes.

01:19.610 --> 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.

01:31.130 --> 01:33.490
And um, I checked the report.

01:33.490 --> 01:38.370
I saw the S3 findings, the CloudTrail findings, the YAM findings.

01:38.370 --> 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.

01:45.250 --> 01:48.510
And who knows what an AMI is?

01:49.150 --> 01:50.250
Okay, cool.

01:50.250 --> 01:54.370
And um, who used at least once an EC2 instance?

01:54.590 --> 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.

02:04.690 --> 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?

02:17.670 --> 02:21.190
And then you can start new EC2 instances starting from this AMI.

02:21.190 --> 02:28.750
And you have AWS Marketplace AMI that are official and from trusted vendors which are the recommended ones you can use.

02:28.750 --> 02:33.430
And you can also have community AMIs that are published by anyone.

02:33.890 --> 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.

02:42.390 --> 02:48.610
But in any case, the thing is that an AMI can be public or private.

02:48.610 --> 02:52.610
And by default, they are private and it's actually hard to make one public.

02:52.610 --> 02:55.510
And I think you can see where I'm going with this.

02:55.650 --> 02:57.890
The issue is that they can be public.

02:57.890 --> 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?

03:10.470 --> 03:12.250
And um, they were like, no.

03:12.250 --> 03:14.650
So I regretted I even asked.

03:14.750 --> 03:18.570
But I got this question, what was inside the AMIs?

03:18.570 --> 03:27.010
And this actually gave me the research idea if there are other companies with secrets in public AMIs out there.

03:27.450 --> 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.

03:52.310 --> 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.

04:02.530 --> 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?

04:12.010 --> 04:14.310
He searched public ABS snapshots.

04:14.310 --> 04:18.370
He's Ben and he pointed at someone and it was Ben Morris and he was like, yeah.

04:18.810 --> 04:20.810
And, sorry.

04:22.690 --> 04:25.890
So yeah, I've met Ben Morris.

04:26.110 --> 04:30.410
I've been saying his name a lot rehearsing the presentation.

04:30.410 --> 04:34.650
It was a pleasure to meet him in person.

04:34.650 --> 04:35.790
He's a lovely guy.

04:36.890 --> 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.

04:46.470 --> 04:53.190
We also had a hidden goal to get some bounties and uh, my colleague Matei will tell you more about it.

04:54.550 --> 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.

05:10.710 --> 05:15.330
And if they are deprecated you can find them in the web portal.

05:15.330 --> 05:18.550
Also customers can deprecate their images whenever they want.

05:18.550 --> 05:25.370
So you have to use the CLI and specify the flag include deprecated to make sure you get all the AMIs.

05:25.610 --> 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.

05:41.970 --> 05:47.250
So we removed AMIs from marketplace, that left us with 1.5 million.

05:47.250 --> 05:52.930
We removed AMIs owned by AWS that were not in the marketplace, that left us with 1 million.

05:52.930 --> 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,

06:11.810 --> 06:12.530
right?

06:12.730 --> 06:16.250
And that left us with 27,000 AMIs.

06:16.370 --> 06:26.190
Now we did some sanity filtering because some AMIs had 17 volumes or volumes as big as 20 terabytes.

06:26.410 --> 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.

06:34.450 --> 06:38.550
Now the distribution from our list looks like this.

06:38.550 --> 06:40.850
Obviously the most AMIs were in U.S.

06:40.850 --> 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.

06:53.770 --> 06:59.830
And when I'm saying that we collected the AMIs this is what I mean by it.

06:59.830 --> 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.

07:20.910 --> 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.

07:31.170 --> 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.

07:41.590 --> 07:48.830
So first we tried to copy the snapshot of the AMI in our own AWS account and download it.

07:48.830 --> 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.

07:59.610 --> 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.

08:08.210 --> 08:18.410
But we quickly realized that this would take a lot of time for an ABS snapshot of 100 gigabytes.

08:18.410 --> 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.

08:26.670 --> 08:29.010
So definitely not an option.

08:29.010 --> 08:39.290
But we realized we had to operate as much as possible within the native AWS features to achieve the faster method.

08:39.290 --> 08:47.270
And we tried to start a new EC2 instance based on the target AMI and connect directly to the instance.

08:47.270 --> 08:53.230
But for some reason the instances were not in a state that allowed us to connect to them.

08:53.230 --> 08:58.050
Either through SSH or through SSM features it just didn't work.

08:58.150 --> 09:04.590
But we did a work around and we got to this method.

09:04.590 --> 09:06.810
So we have a secret search instance.

09:07.170 --> 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.

09:14.430 --> 09:15.710
We can connect to it.

09:15.710 --> 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.

09:25.190 --> 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.

09:36.610 --> 09:44.010
And everything is happening within the AWS environment so it was both fast and it was both as reliable as possible.

09:44.470 --> 09:49.810
Now I'll show you a demo on how you can manually access the contents of one AMI.

09:51.630 --> 09:53.850
Let me see if I can start this.

09:55.610 --> 09:58.410
So we can search based on the description.

09:58.410 --> 10:01.610
You can use this to target certain technologies or companies.

10:01.970 --> 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?

10:13.790 --> 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?

10:24.090 --> 10:27.710
But let's stick with our description based search.

10:27.710 --> 10:31.710
So let's try to copy the ABS snapshot as

10:35.150 --> 10:35.730
a first step.

10:35.730 --> 10:35.750
Let's try .

10:36.130 --> 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.

10:44.590 --> 10:48.870
That's because the ABS snapshot is not public only the AMI is.

10:49.350 --> 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.

11:04.050 --> 11:10.730
You need the same availability zone to make sure you have, you can move the volume between the instances.

11:10.790 --> 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.

11:21.210 --> 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.

11:37.230 --> 11:43.490
We use the web portal because it was easier for the demo but you can also connect to SSH.

11:43.610 --> 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.

11:52.250 --> 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.

12:07.930 --> 12:12.330
And now that it's mounted, let's look for some AWS credentials, right?

12:12.350 --> 12:15.430
We found some and now let's check if they are valid.

12:15.430 --> 12:22.790
Because for some older instances, the secrets might not be valid anymore so every time you have to check them.

12:26.280 --> 12:29.080
So, surprise, yes, they are working.

12:29.080 --> 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.

12:41.380 --> 12:44.300
This is the high level architecture we put in place.

12:44.300 --> 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.

13:03.000 --> 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.

13:12.300 --> 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.

13:29.120 --> 13:32.540
And I invite my colleague Matej Josic to tell you more about it.

13:32.680 --> 13:33.960
Thank you.

13:37.140 --> 13:38.260
Cool.

13:38.340 --> 13:41.200
Good morning everybody and thank you so much for being here.

13:41.200 --> 13:46.420
It's actually an absolute pleasure to be on stage at DEF CON 32.

13:46.640 --> 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.

14:00.200 --> 14:02.240
I am Matej Anthony-Josephs.

14:02.240 --> 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.

14:13.120 --> 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.

14:23.200 --> 14:30.280
Now, completely unrelated to this research, I've also set up a company alongside my wife, Alexa.

14:30.340 --> 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.

14:43.420 --> 14:49.280
Similarly, we think that collaboration is probably the most important part of cyber security.

14:50.140 --> 14:56.780
And while I don't know the exact numbers, just looking around DEF CON, I can see why.

14:56.860 --> 14:59.660
There's quite a hive of hackers around here.

15:00.120 --> 15:02.940
That's enough about me, back to Cloud Query.

15:03.360 --> 15:07.860
For our initial strategy, we decided to be as lazy as possible.

15:07.920 --> 15:10.340
And trust me, being lazy is a good thing here.

15:10.520 --> 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.

15:22.760 --> 15:28.980
In fact, the tools which we tried to use were quite slow and produced loads of false positives.

15:29.260 --> 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.

15:49.080 --> 15:54.720
So, with this in mind, we had to pivot and we went back to the Zen of Python.

15:54.720 --> 15:57.740
More specifically, the following section of it.

15:57.740 --> 16:06.520
Simple is better than complex, complex is better than complicated, and special cases aren't special enough to break the rules.

16:06.940 --> 16:12.800
So, with this in mind, we reduced our scope even further and became even lazier.

16:12.800 --> 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.

16:27.640 --> 16:32.840
Now we faced another issue, and that is finding the right tool for this.

16:32.840 --> 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.

16:41.140 --> 16:44.300
The tool had to be quick and simple.

16:44.300 --> 16:46.900
So, you can probably see where I'm going with this.

16:46.900 --> 16:51.460
We ended up using the native Unix utility, find, of course.

16:51.880 --> 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.

17:00.940 --> 17:06.540
We skipped everything about, above 25 megabytes because, well, this is only a proof of concept.

17:06.540 --> 17:09.160
We don't need to find everything really.

17:09.160 --> 17:13.560
And searched for all of these various files and directories.

17:14.040 --> 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.

17:24.100 --> 17:29.180
And one of them was an automation for verifying AWS credentials.

17:29.240 --> 17:32.360
And you'll see in a minute exactly why we needed that.

17:32.720 --> 17:37.580
Secondly, we used Git leaks for checking Git repositories for secrets.

17:38.740 --> 17:46.300
Also, we had to set up a few other automations for verifying API keys and other types of credentials.

17:46.300 --> 17:54.000
And for this we used key hacks, which is a fantastic repository of methods for validating keys and credentials.

17:54.540 --> 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.

18:03.380 --> 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.

18:13.160 --> 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.

18:24.220 --> 18:29.740
So you can probably see why we needed all of these automations for validating the keys and credentials.

18:30.620 --> 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.

18:41.700 --> 18:45.180
Now, I know that this does not seem like a lot.

18:45.180 --> 18:49.980
I mean, what is, 120 out of 100,000 is nothing, right?

18:50.560 --> 18:53.240
But, think about it this way.

18:53.300 --> 19:01.940
These, these keys allowed us to access the AWS accounts of over 100 companies.

19:02.340 --> 19:08.540
So this gave us initial access there, and for 20 of them we had absolute complete control.

19:08.720 --> 19:11.100
So, let that sink in for a bit.

19:12.600 --> 19:17.600
Now, we face another issue, and that is identifying the donors.

19:18.120 --> 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.

19:31.640 --> 19:36.540
So with this in mind, we found something surprising.

19:37.120 --> 19:41.900
And that is, that it's not only small boutique like companies affected by this.

19:41.900 --> 19:45.760
In fact, many of the companies are on the Fortune 500 list.

19:46.300 --> 19:52.380
Some of the most valuable ones were worth 200, respectively 50 billion dollars.

19:52.940 --> 19:57.880
We found three large telecom companies, which you've definitely heard about in the past.

19:57.920 --> 20:03.520
Ten relevant security and tech companies, and several others in consulting, education, health, manufacturing.

20:04.340 --> 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.

20:12.800 --> 20:22.300
Now, you may ask, well, anybody can write whatever they like in the contact information in the AWS account, right?

20:22.300 --> 20:24.280
And you're absolutely right.

20:24.640 --> 20:28.920
And then our efforts for identifying the owners could have been completely in vain.

20:30.160 --> 20:32.820
However, here is where our OSINT came in.

20:32.820 --> 20:38.080
We did quite a bit of OSINT, went on social media, including LinkedIn, and found several of these owners.

20:38.200 --> 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.

20:50.320 --> 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.

20:58.820 --> 21:00.440
So we reported it.

21:00.440 --> 21:06.860
And this way we got our first P1, our first confirmed critical vulnerability on a bug bounty platform.

21:06.920 --> 21:09.100
That was actually fantastic for us.

21:09.320 --> 21:10.540
Oh, thank you.

21:10.540 --> 21:11.400
Thank you.

21:14.250 --> 21:17.570
Now, let's see, how much do you guys think we made out of it?

21:17.570 --> 21:21.470
So who thinks we made between $10,000 and $100,000?

21:21.470 --> 21:22.830
So let's say five digits.

21:23.430 --> 21:25.190
Yeah, only a few hands up.

21:25.190 --> 21:28.150
Maybe four digits, so a thousand and ten thousand.

21:28.650 --> 21:30.130
Right, a few more.

21:30.130 --> 21:35.490
Well, let's say AWS or cloud in general is niche, maybe they don't really care about these accounts.

21:35.490 --> 21:36.850
Maybe three digits?

21:37.990 --> 21:40.210
Okay, yeah, that's pretty low.

21:41.150 --> 21:44.810
Yeah, we made zero dollars out of it, nothing.

21:45.230 --> 21:47.270
Yeah, thank you, absolutely.

21:47.870 --> 21:52.650
Well, to be fair, there's a bit of a catch.

21:52.650 --> 21:57.970
It wasn't a bug bounty program, it was a vulnerability discloser program.

21:58.410 --> 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.

22:04.910 --> 22:09.910
We just wanted to make the internet a safer place, although this sounds a bit cliche.

22:10.370 --> 22:17.550
But still, we quickly forgot about this because we found something else which I think was more interesting than this.

22:17.750 --> 22:22.930
I like to call this story how we earned and lost three million dollars in a week.

22:23.370 --> 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?

22:30.470 --> 22:32.730
Maybe not quite three million dollars.

22:32.730 --> 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.

22:45.910 --> 22:50.990
And for those of you who don't know, Stripe is a payment service not unlike PayPal.

22:51.490 --> 22:57.750
So our first thought was, okay, let's run a balance call to the API and that's what we got.

22:57.750 --> 23:00.510
Seven digits in the USD currency.

23:00.510 --> 23:02.610
So what looked like 3.1 million dollars.

23:02.610 --> 23:03.490
Fantastic.

23:03.650 --> 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?

23:11.930 --> 23:14.150
For research purposes only, trust me.

23:14.150 --> 23:15.450
Only research.

23:15.630 --> 23:21.870
So we went to the documentation and we quickly realized that the amount is in cents.

23:23.670 --> 23:28.010
So what we thought was 3.1 million was actually 31,000.

23:28.290 --> 23:30.510
Of course we were very disappointed.

23:31.390 --> 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.

23:39.730 --> 23:43.530
So if there's any conclusion here, don't read the documentation.

23:44.390 --> 23:46.170
Just joking, of course.

23:46.590 --> 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.

23:55.090 --> 23:57.690
And all we got was radio silence for a few weeks.

23:57.690 --> 23:59.570
It was pretty annoying to be fair.

23:59.630 --> 24:01.810
We thought, well, did we do something wrong?

24:01.810 --> 24:03.270
Didn't we prove impact?

24:03.710 --> 24:06.790
So we thought of proving impact and that's what we did.

24:07.930 --> 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.

24:24.830 --> 24:25.550
Fantastic.

24:25.550 --> 24:30.030
And a second level of validation was that the transaction was reverted.

24:30.030 --> 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.

24:36.810 --> 24:41.330
But now this was a bingo moment for us because we knew that we can talk about money.

24:41.850 --> 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.

24:49.830 --> 24:50.670
And guess what?

24:50.670 --> 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.

24:58.410 --> 25:00.150
And we provided more info.

25:00.550 --> 25:09.230
We gave them a comprehensive report including the finding, the impact of the finding and steps for remediating this.

25:09.770 --> 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.

25:18.730 --> 25:19.630
For now?

25:19.630 --> 25:20.290
What?

25:20.290 --> 25:21.090
For now?

25:21.090 --> 25:21.970
Okay.

25:22.090 --> 25:24.370
And we'll be replacing the keys.

25:25.250 --> 25:27.670
Thanks so much for responsible disclosure.

25:28.570 --> 25:31.410
We took that as a thanks bye.

25:31.990 --> 25:35.710
And yeah, honestly we were a bit disappointed but we had a lot of research to do.

25:35.710 --> 25:41.070
We had to go back to our research and just dig through the 500 gigabytes of data which we already got.

25:41.370 --> 25:46.510
However, one month later I was forced to remember the issue.

25:47.290 --> 25:51.910
I checked my bank account and there's a 999 transaction.

25:51.910 --> 25:57.530
So I was so excited about being able to do the refund that I completely forgot to cancel my subscription.

25:58.730 --> 26:06.850
Well, remember that we are fairly broke so I didn't want to let 999 go by just like that.

26:06.850 --> 26:11.170
So I went back into the API, did the same call again and guess what?

26:11.270 --> 26:13.230
Money was back in my account.

26:14.070 --> 26:15.830
Yes, thank you.

26:16.070 --> 26:17.010
Yep.

26:18.610 --> 26:23.050
Well, we were disappointed initially by the dry response.

26:23.290 --> 26:30.250
But you cannot even imagine our disappointment that the issue was still not fixed one month later.

26:31.150 --> 26:34.130
Now, there's way more impact than just this.

26:34.230 --> 26:35.530
Think about it this way.

26:35.530 --> 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.

26:44.010 --> 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.

26:54.950 --> 27:04.550
Now, a second potential area of impact which I think has a bit more potential, well, AWS based ransomware.

27:04.890 --> 27:07.510
And this way I could have come to DEF CON for free.

27:08.010 --> 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.

27:17.930 --> 27:27.250
Perhaps when we talk about ransomware as a service, they're using 24 7 customer support teams and call centers.

27:27.350 --> 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.

27:51.030 --> 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.

27:57.970 --> 27:59.350
All your files have been stolen.

27:59.350 --> 28:02.310
You must buy us a Romania Las Vegas ticket to get your files.

28:02.310 --> 28:04.290
And honestly, that would have been pretty reasonable.

28:04.290 --> 28:06.750
It's only what, 500, a thousand dollars?

28:06.830 --> 28:08.710
So yeah, pretty decent ransom.

28:08.770 --> 28:13.190
And I need this disclaimer here, this is just a joke.

28:13.230 --> 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?

28:20.350 --> 28:22.830
Now, Edward, want to take over?

28:24.090 --> 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.

28:37.390 --> 28:42.230
So, we looked for contact details and we couldn't find many.

28:42.230 --> 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.

28:56.190 --> 29:01.470
So we sent almost 70 responsible disclosure e-mails and we received less than ten responses.

29:01.610 --> 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.

29:16.230 --> 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.

29:31.430 --> 29:32.990
It's not like that, right?

29:32.990 --> 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.

29:45.650 --> 29:47.570
Here is the proof.

29:48.350 --> 29:49.750
Can you invalidate them?

29:49.750 --> 29:51.390
We have a research we want to publish.

29:51.550 --> 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.

30:02.510 --> 30:07.330
And after a few days after contacting them, more than 60 AWS keys were invalidated.

30:07.330 --> 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.

30:24.070 --> 30:26.630
So, please give them a round of applause.

30:27.590 --> 30:28.850
Thank you.

30:29.690 --> 30:34.810
Now, to discuss a bit about detecting and defending against this and let's start with defending.

30:34.810 --> 30:43.250
So, if your AWS account has this yellow warning signs, you might want to look into it.

30:43.250 --> 30:49.170
So, the settings block public access for AMIs and ABS snapshots should be enabled.

30:49.430 --> 30:50.430
They should look like this.

30:50.430 --> 30:53.430
They should have this green check mark.

30:53.690 --> 30:58.490
You can also use the CLI to validate if you have public AMIs.

30:58.490 --> 31:03.570
Make sure to check every region and make sure to check for deprecated images.

31:03.930 --> 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.

31:13.610 --> 31:20.630
And if that happens to you, you should look in CloudTrail for this event, shared snapshot volume created.

31:20.630 --> 31:26.070
This is the only event you get in CloudTrail if someone accesses your public AMI.

31:26.070 --> 31:28.270
And it doesn't have a lot of information.

31:28.430 --> 31:32.010
As you can see, the IP address is hidden which I get it.

31:32.010 --> 31:37.570
It's protecting the customer that is accessing the AMI.

31:38.350 --> 31:39.430
That is cool.

31:39.550 --> 31:45.170
But the only identifiable information you have is the account ID which you can't do much with it.

31:45.170 --> 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.

31:55.210 --> 32:01.190
Now, we have a lot of data and we did other research with it.

32:01.190 --> 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.

32:14.710 --> 32:17.070
However, it was a good try.

32:17.390 --> 32:21.490
Next, we looked through our 4K unique SSH private keys.

32:21.490 --> 32:27.730
We generated public keys and a figure print and we searched on showdown but nothing came out of it.

32:27.910 --> 32:32.810
One idea was to perform the same scan from within the AWS network.

32:32.810 --> 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.

32:40.050 --> 32:43.690
Another cool idea we had but we haven't started this yet.

32:44.050 --> 32:49.630
So, we collected a lot of private, a lot of repositories and some of them are surely private.

32:49.770 --> 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.

33:13.230 --> 33:15.910
And that on the topic of further research.

33:15.990 --> 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.

33:26.850 --> 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.

33:39.270 --> 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.

33:49.610 --> 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.

34:01.130 --> 34:09.250
And while we didn't dig into all public AMIs, we dug into all public AMIs which we found interesting.

34:09.250 --> 34:11.450
So I'd say that this was achieved.

34:11.970 --> 34:13.590
Also, we aim to have fun.

34:13.590 --> 34:14.830
And, yeah, we did.

34:14.830 --> 34:17.350
We found a lot more stuff than we expected.

34:17.350 --> 34:20.310
It was a roller coaster and thanks, Edward, for this.

34:20.470 --> 34:22.950
Lastly, responsible disclosure.

34:23.690 --> 34:29.030
Well, I was a bit disappointed by the responsible disclosure process in general.

34:29.030 --> 34:34.210
Well, many of the owners didn't respond to us.

34:34.210 --> 34:38.830
Others, well, didn't have any sort of information for us to contact them.

34:39.750 --> 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.

34:52.670 --> 34:58.470
Now that we are approaching the end of this talk, here are our conclusions.

34:59.050 --> 35:03.590
Firstly, the impact of this research is not yet fully uncovered.

35:04.110 --> 35:07.850
There's still way more to find out there.

35:08.190 --> 35:13.250
We have found several secrets already in the data which we collected.

35:13.350 --> 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.

35:20.230 --> 35:26.210
Potentially a nice area of research would be continuously monitoring new AMIs becoming public.

35:26.510 --> 35:30.410
Secondly, security by obscurity is definitely insufficient.

35:31.050 --> 35:36.350
So many developers definitely thought that their Git repositories were safe because they're private, right?

35:36.350 --> 35:39.750
But how is anything private if it's placed in a public resource?

35:41.110 --> 35:45.650
Also, you may be thinking, hey, I won't be a target of this, right?

35:45.650 --> 35:47.910
Nobody cares about my AMIs.

35:48.370 --> 35:49.970
Well, think about it this way.

35:49.970 --> 35:54.470
Edward and I, two cyber security guys from Romania, were able to do this.

35:54.650 --> 35:57.450
Think about what threat actors could do.

35:57.550 --> 36:02.230
So definitely don't make your AMIs public if you don't have to.

36:02.690 --> 36:07.210
Now, AMIs are only the tip of the iceberg here.

36:07.510 --> 36:14.130
There are still a lot of other interesting things to find across several other public cloud providers.

36:14.950 --> 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.

36:23.710 --> 36:27.050
And still we encourage you to do your own research as well.

36:27.050 --> 36:30.550
And please let us know if you have any sort of ideas.

36:30.550 --> 36:32.050
We're happy to help.

36:32.050 --> 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.

36:43.550 --> 36:44.930
So please connect with us.

36:44.930 --> 36:48.370
Let us know if you need any help with any sort of research in the future.

36:48.950 --> 36:51.110
And we'll definitely be happy to help.

36:51.110 --> 36:53.750
This being said, thank you very much everybody.

36:54.030 --> 36:55.710
We appreciate you being here.

37:05.790 --> 37:06.930
Any questions?

37:06.930 --> 37:07.590
Yep.

37:07.810 --> 37:08.410
Sure.

37:08.410 --> 37:09.110
Go ahead.

37:11.210 --> 37:12.650
Is the mic on?

37:16.270 --> 37:16.950
Not yet.

37:16.950 --> 37:18.630
Can we get the question mic on please?

37:25.690 --> 37:27.790
Perhaps just speak really loudly.

37:36.960 --> 37:38.280
We don't know.

37:38.280 --> 37:43.640
So we didn't perform any calls beside the contact information.

37:44.220 --> 37:50.720
So we tried to get security operation and another type of contact details but we didn't check the permissions.

37:50.720 --> 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.

38:04.180 --> 38:10.620
Also please note that just having the S3 ransomware sort of code in my terminal got my adrenaline rushing.

38:10.620 --> 38:13.180
So we didn't try to do anything like that.

38:13.880 --> 38:14.400
Yes.

38:21.860 --> 38:22.920
I didn't have the permission to do anything like that.

38:22.920 --> 38:23.440
So I don't know if you have to.

38:23.440 --> 38:24.560
I wanted to.

38:37.620 --> 38:39.460
I'm looking for new opportunities.

38:39.460 --> 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.

38:47.120 --> 38:48.620
So thanks.

38:52.940 --> 38:53.740
Cool.

38:53.740 --> 38:54.960
Any other questions?

38:57.080 --> 38:58.340
Yes please.

39:02.520 --> 39:05.280
No and to be fair we didn't even expect that.

39:05.300 --> 39:07.300
I mean we had KPMG for that.

39:08.360 --> 39:13.640
So thanks KPMG and uh we are waiting some t-shirts from the companies we disclosed this.

39:13.640 --> 39:14.340
Thank you.

39:18.190 --> 39:19.070
Cool.

39:19.070 --> 39:22.390
Mic's working so if anybody has any questions you can speak in the mic.

39:23.630 --> 39:24.350
Cool.

39:24.350 --> 39:25.810
Doesn't look like any other questions.

39:25.810 --> 39:28.590
We'll just be around here so please let us know guys.

39:28.870 --> 39:29.650
Nice talking to you.

39:29.650 --> 39:30.290
Thank you.

