WEBVTT

00:04.220 --> 00:06.040
So, hello everybody.

00:06.200 --> 00:09.200
We are very excited to be here.

00:09.200 --> 00:13.840
And welcome to the session Breaching AWS Accounts Through Shadow Resources.

00:14.080 --> 00:18.740
And in this session we will demonstrate several vulnerabilities that we found on AWS.

00:18.960 --> 00:24.500
The most severe of these vulnerabilities could allow an attacker to add an admin role to another account.

00:24.500 --> 00:25.460
So let's start.

00:27.100 --> 00:34.460
Let's start by discussing the most debatable topic on AWS which is AWS account ID.

00:34.620 --> 00:39.960
So, each AWS account has a unique identifier associated with it.

00:40.380 --> 00:50.880
This identifier consists of 12 digits and the most important thing about this is that some treat it as a secret and some don't.

00:51.220 --> 00:57.460
And along the history of AWS we have many different opinion whether it is a secret or not.

00:58.340 --> 01:07.540
Although AWS in their documentation states that this account ID should be shared carefully, they do not consider this a secret.

01:07.640 --> 01:16.160
But we as security practitioners, security researchers, know that attacker could achieve problematic things only by knowing this account ID.

01:16.500 --> 01:18.960
So, what is the right answer?

01:19.120 --> 01:22.640
Are AWS account IDs secret or not?

01:22.640 --> 01:27.720
We hope that by the end of this session we will have more solid opinion about this.

01:28.200 --> 01:31.060
So, let us introduce ourselves.

01:31.060 --> 01:37.820
My name is Yakir Kotkoda and here with me are Michael Kaczynski and Ofik Itach.

01:37.820 --> 01:46.120
We are all security researchers from Aqua Security and we are focusing in our daily on cloud vulnerabilities, open source vulnerabilities and more.

01:46.540 --> 01:48.800
Let me go over the agenda.

01:48.800 --> 02:03.180
We will introduce something that's called shadow resources and what they are, then several vulnerabilities that we found on AWS and an open source tool that we developed during our research that helped us to find more vulnerabilities.

02:03.900 --> 02:16.300
After this we will introduce a new technique called bucket monopoly that help us emphasize the risk of our findings and we will end our session by suggesting some mitigations and recommendation.

02:17.200 --> 02:21.280
So, let's first talk how our journey began.

02:21.480 --> 02:38.480
While we worked with the AWS management console, which is the GUI of AWS, we noticed that when a user use the cloud formation service and upload a template file, AWS behind the scenes creates an S3 bucket for the user.

02:38.860 --> 02:45.500
Although the user did not explicitly ask AWS to do so, this is how the service operates.

02:45.560 --> 02:52.700
We have decided to name this kind of resources that spawned automatically without the user intervention a shadow resource.

02:52.700 --> 02:55.140
So, let's explain this term.

02:55.240 --> 03:04.660
When we refer to shadow resources, we are mainly first to resources that generated automatically or semi-automatically by AWS.

03:05.260 --> 03:13.060
Most of the time they spawn without user intervention and they might go unnoticed by the account owner.

03:13.200 --> 03:20.220
And the great example for this is just the S3 bucket that we saw that the cloud formation service creates for the user.

03:21.440 --> 03:29.640
Now, let's align some first, some common knowledge about S3 bucket, which is one of the first services by AWS.

03:30.420 --> 03:33.420
This service has some special uniqueness.

03:33.420 --> 03:38.900
First of all, S3 bucket name must be globally unique across all AWS.

03:39.660 --> 03:47.260
For example, if you create an S3 bucket called coolbucket1, no one else on AWS could claim this name.

03:47.260 --> 03:49.960
It will be available only under your account.

03:50.440 --> 03:55.100
So, let's set up a view and talk about our first vulnerability on cloud formation.

03:55.760 --> 03:58.120
So, first of all, what is cloud formation?

03:58.480 --> 04:04.780
Cloud formation is an infrastructure as code service by AWS similar to the telephone project.

04:04.940 --> 04:09.220
A user will define a template file that contain AWS resources.

04:09.280 --> 04:14.940
Then the user store this template file locally or in S3 bucket.

04:15.040 --> 04:27.920
And then the user will create a stack based on this template file and when the user will deploy this stack, the cloud formation service deploys the resources that exist under this template file.

04:28.760 --> 04:34.540
Now, I want us to understand what's happened behind the scenes when the user upload the template file to this service.

04:34.540 --> 04:41.420
So, first, the user clicks on the upload template file under the GUI.

04:41.500 --> 04:48.060
And we need to remember that every operation on AWS is eventually an API request.

04:48.060 --> 04:52.300
So, the create upload bucket API request will be invoked.

04:52.380 --> 04:56.420
The cloud formation service will try to create an S3 bucket.

04:56.540 --> 04:59.160
Then it will return the bucket name.

04:59.160 --> 05:06.860
And then the put object API request will upload the template file to the cloud formation service.

05:06.860 --> 05:10.100
Then we will have a lot of API requests.

05:10.240 --> 05:20.140
But in the end, the user will submit the stack which will cause the cloud formation service to deploy all the AWS resources that exist under this template file.

05:20.620 --> 05:25.880
Now, I want us to focus on the bucket naming pattern of this S3 bucket.

05:26.380 --> 05:29.520
So, it will consist of three different parts.

05:29.520 --> 05:35.260
The first one is a prefix, which is a constant string and it will remain the same.

05:35.320 --> 05:38.300
In this case, it is CF template.

05:38.300 --> 05:43.540
Then we have the hash, which is a unique identifier per account.

05:43.540 --> 05:49.980
And then a region, which will be related to where the user initiate the cloud formation service.

05:49.980 --> 05:51.940
So, now let's visualize this.

05:51.940 --> 06:01.940
So, basically, when a user uses the cloud formation service via the AWS GUI, AWS behind the scenes creates an S3 bucket with this pattern.

06:02.100 --> 06:15.860
And when the user will try to create another cloud formation service in a new region for the first time, the cloud formation service creates an S3 bucket with the same prefix, with the same hash, but with a different region.

06:15.920 --> 06:20.360
So, we have here a semi -predictable bucket name.

06:21.340 --> 06:27.400
So, what if an attacker open or claim this bucket before the user?

06:28.100 --> 06:35.940
So, if a user, if an attacker does so, this technique is called bucket name squatting or bucket sniping.

06:35.940 --> 06:39.380
You can read a great blog by Oren McKay about this technique.

06:39.600 --> 06:41.180
Now, let's explain this.

06:41.180 --> 06:45.440
So, we have here the user with the cloud formation service on a specific region.

06:45.740 --> 06:49.420
And then the, an attacker on a new region.

06:49.500 --> 06:55.560
And what the attacker did here is that he creates a bucket under his account with the hash of the user.

06:55.560 --> 06:56.900
We will talk about this later.

06:56.900 --> 06:58.600
The prefix and the region.

06:58.900 --> 07:09.920
So, whenever the user will try to use the cloud formation service in this region for the first time, the cloud formation service will try to interact with the attacker claim bucket.

07:10.300 --> 07:12.780
But, it will receive an error.

07:12.820 --> 07:25.500
So, basically, we have here a way to prevent the other user from using the cloud formation service on a specific region which can be considered as a DOS scenario.

07:26.560 --> 07:31.420
And a DOS scenario is fine, but it isn't enough for a DEF concession.

07:31.420 --> 07:33.440
So, let's escalate it.

07:34.220 --> 07:38.420
What if an attacker opened a bucket for public access?

07:39.800 --> 07:48.760
So, the reason why the cloud formation service got an error before is because the attacker needs still to define some settings on their S3 bucket.

07:48.760 --> 07:54.840
First of all, the attacker needs to allow public access because it's blocked by default.

07:55.220 --> 08:03.940
And then, in order to allow cross-account access, the attacker needs to define a resource-based policy.

08:04.120 --> 08:13.800
In this case, we have a very permissive bucket policy that allows any principal on AWS to perform any action on the S3 bucket of the attacker.

08:13.800 --> 08:17.560
Of course, this is just a POC and this is very, very dangerous.

08:18.020 --> 08:22.940
So, after the attacker does so, now an interesting thing will happen.

08:23.060 --> 08:28.720
The cloud formation service of the victim will succeed interact with the attacker claim bucket.

08:28.720 --> 08:34.700
So, whenever the user upload a template file, it will be dropped to the attacker S3 bucket.

08:34.980 --> 08:41.660
So, we have here a way to enumerate different secrets and resources that the user wrote in their template file.

08:41.720 --> 08:45.360
So, this is an information disclosure scenario.

08:47.560 --> 08:54.740
But, if an attacker already has access to this template file, what if an attacker modified it?

08:55.720 --> 09:09.240
So, if an attacker does so, this is called resource injection in cloud formation templates and it's a great technique that's published already by Rhinolab and also credited to Matthew Filler about this.

09:09.240 --> 09:25.560
And all the idea behind this technique is some time of check, time of issue behavior that the cloud formation service has by default that allow an attacker a windows of opportunity to modify templates file before the cloud formation service try to deploy them.

09:25.560 --> 09:34.980
So, it's possible for attacker to modify this template file and actually do it manually or with Lambda that will backdoor this template automatically.

09:35.300 --> 09:37.520
So, now let's visualize this.

09:39.020 --> 09:41.760
Here we have the user and the attacker account.

09:41.760 --> 09:49.500
The attacker is in external account and the attacker create an S3 bucket that the cloud formation service of the victim will try to use.

09:49.500 --> 09:54.020
And a Lambda that will backdoor any file that dropped to this S3 bucket.

09:54.020 --> 10:03.320
So, whenever the user creates a stack, the cloud formation service uploads the victim template to the attacker S3 bucket.

10:03.320 --> 10:11.460
Then the Lambda will be triggered and gets the template file from the attacker claim bucket.

10:11.820 --> 10:17.860
Then the Lambda will perform a resource injection and here we have a new resource.

10:17.860 --> 10:21.660
It's an admin role that can be assumed by the attacker.

10:22.340 --> 10:29.220
Then the Lambda will inject this backdoor template file to the S3 bucket.

10:29.340 --> 10:32.960
And as I said before, we have here some time of check, time of use issue.

10:32.960 --> 10:36.720
So, the user needs to deploy the template file.

10:36.720 --> 10:39.160
So, the user click on the submit stack.

10:39.160 --> 10:50.840
And then the previously vulnerable cloud formation service will attempt to get the backdoor template file from the attacker S3 bucket and deploy this malicious role under the victim account.

10:51.000 --> 10:56.100
So, we have here an admin role from external accounts that the attacker can claim.

10:56.100 --> 11:00.300
So, actually it's, which, which means an account takeover.

11:03.130 --> 11:04.250
Okay.

11:06.390 --> 11:09.350
But there are some important point to mention.

11:10.110 --> 11:23.310
In order to add or inject an admin role to another account, the initiator of the cloud formation service, which is an AWS user or a service role, needs to have some, needs to have some high privilege.

11:23.630 --> 11:29.530
And we can assume that user that use the cloud formation service via the GUI have such privilege.

11:29.630 --> 11:36.070
And even if they do not have high privilege, it's still possible to modify what exists in the template file.

11:36.910 --> 11:44.610
And of course, the attacker needs to wait for the victim to use the cloud formation service in a new region for the first time.

11:44.830 --> 11:47.630
So, now let's see a really quick POC of this.

11:48.550 --> 11:55.210
Here we have the victim account that try to use the cloud formation service via the GUI and upload the template file.

11:55.210 --> 12:03.450
Behind the scenes, the cloud, the template file already dropped to the attacker claim bucket and the user still needs to define stack name, privilege and more.

12:03.450 --> 12:06.450
And this is what caused the time of check time of use issue.

12:06.950 --> 12:13.830
As we can see here, we have the attacker S3 bucket with the template file of the user and the attacker can modify it.

12:13.950 --> 12:23.890
Meanwhile, the attacker deploys the stack and we can see that we have under this deployment an attacker user which is a really privileged role, an admin role.

12:23.890 --> 12:28.130
And we can see also that this all can be assumed from external account.

12:28.130 --> 12:31.230
In this case, the attacker account.

12:31.270 --> 12:41.990
So, all attacker needs to do is to assume this role, find the related account ID of the user on the CloudWatch logs and then the attacker has an admin role on the victim account.

12:41.990 --> 12:46.070
Which is one of the most severe thing that we can receive in the cloud, right?

12:52.920 --> 12:56.560
Thank you Akir for showing us such a cool technique.

12:56.620 --> 13:01.340
But before we continue, let's not ignore the elephant in the room.

13:02.100 --> 13:18.400
Akir showed us previously a way to, sorry, a way to previously Akir showed us a way to, he showed us that the bucket name needs to be predictable.

13:18.400 --> 13:23.000
But when we look at the bucket name, it's definitely not predictable, right?

13:23.000 --> 13:25.120
It's due to the hash in the middle.

13:25.380 --> 13:27.700
So, we knew we had to address this problem.

13:28.500 --> 13:37.320
The first attempt that we did was actually trying to enumerate and calculate every possible hash.

13:37.440 --> 13:43.060
But we quickly realized it's just not doable to the amount of option that we had.

13:43.880 --> 13:48.760
Then we thought maybe we can reverse the hash or something like that.

13:48.760 --> 13:51.540
Akir said that the hash is unique per account.

13:51.740 --> 13:57.180
So, maybe it's based on the account ID or other unique identifier in the account.

13:57.480 --> 14:03.660
But after many unsuccessful attempts, we left that technique.

14:04.640 --> 14:07.940
Then we decided to turn to open source.

14:08.360 --> 14:12.380
In open source, we saw this code.

14:12.380 --> 14:20.120
And in this code we saw that there is some cases, there is a code that shows that the bucket is actually randomized.

14:20.120 --> 14:21.780
The hash is actually randomized.

14:22.280 --> 14:31.320
And what that actually means is it's, we can't predict the hash.

14:31.620 --> 14:37.200
So, our technique is not going to work in the real world.

14:37.740 --> 14:53.100
But as good researchers, we were sad about this because we know that our technique is not going to work and we had to rethink about everything that we came so far.

14:53.100 --> 14:54.860
We have a really nice technique.

14:54.940 --> 14:58.200
We managed to remote account takeover.

14:58.940 --> 15:02.980
But we don't have how to use it in the real world.

15:02.980 --> 15:07.760
But as good researchers, we thought about a solution.

15:07.760 --> 15:14.140
We used the greatest tool known to us, which is the search tool.

15:14.140 --> 15:22.680
We used GitHub search and we used source graph search and we managed to find over a thousand buckets.

15:22.680 --> 15:25.840
Some of them with the hash that we mentioned.

15:25.840 --> 15:27.800
All of them with the hash that we mentioned.

15:27.800 --> 15:33.840
And it gave us the ability to hack, like, a couple of big organizations.

15:34.780 --> 15:36.820
But we didn't stop there.

15:37.180 --> 15:50.240
Doing our searches, we actually find that there is cases where the account, where the bucket name of some services is actually created by just using account ID.

15:50.500 --> 16:14.040
So, we thought about maybe instead of trying to find a mysterious hash or trying to understand this randomized string, maybe we can just use the account ID instead and find new vulnerability that the bucket name actually contains the account ID.

16:14.080 --> 16:23.020
So, we decided to shift our whole research and turn to find more bucket patterns.

16:23.600 --> 16:27.880
We used the open source and look for more bucket patterns.

16:27.880 --> 16:31.340
We used AWS documentation and SDK.

16:31.520 --> 16:37.320
We even started calling and trying to press nearly every possible button in AWS GUI.

16:37.320 --> 16:45.480
And we even created a tool, an open source tool that you can all play with it after this talk.

16:45.480 --> 16:52.140
It lets you debug AWS like you're debugging network buckets.

16:52.220 --> 16:58.840
And it shows the inner API calls made by AWS which is kind of nice.

16:58.840 --> 17:01.420
So, let's see how it works.

17:01.420 --> 17:05.320
In one screen, we initiate an API call.

17:05.320 --> 17:12.520
This API call in this scenario is the upload template that Kir talked about before.

17:13.100 --> 17:17.820
In the other screen, we use Wireshark with our plug-in.

17:17.820 --> 17:20.120
We wrote a plug-in for Wireshark.

17:20.440 --> 17:26.460
And we just starting to capture API calls that we made.

17:26.460 --> 17:36.160
And what is interesting about what we seen using this tool is actually when we initiate the API call in the GUI, it's actually one API call.

17:36.280 --> 17:40.680
But this API call is undocumented.

17:40.960 --> 17:49.140
And the equivalent to that API call is actually five different API calls made by the inner services of AWS.

17:49.240 --> 17:54.280
One of them is the create bucket that Kir told you before and it also calculates the hash.

17:54.280 --> 17:58.820
So, we have here an undocumented API call used by AWS to create buckets.

17:59.720 --> 18:10.400
So, all of the techniques that I mentioned before gave us around hundreds of buckets and we understand that we have tons of work to do.

18:10.420 --> 18:16.720
Because as a reminder, some of the buckets came from open source projects.

18:16.720 --> 18:20.220
So, we need to understand which bucket is related to what service.

18:20.220 --> 18:25.500
And we also need to understand if any of the services is exploitable.

18:26.580 --> 18:31.660
So, you are probably wondering what is the answer for those questions.

18:31.660 --> 18:37.840
And the answer was, we managed to find five different vulnerabilities within AWS.

18:38.100 --> 18:41.180
Some of them by just using the account ID.

18:43.080 --> 18:51.600
So, let's talk about the common steps that we need to take that is common to all the vulnerabilities that we found.

18:52.220 --> 18:56.080
As Kir said before, we need to create a bucket name before the user.

18:56.080 --> 19:02.720
We also need to open the bucket to the world and we need to put lambda or something to monitor the bucket.

19:02.820 --> 19:06.380
And when a file is dropped to the bucket, we can change it.

19:06.380 --> 19:08.060
It's the same technique.

19:09.440 --> 19:12.320
So, let's explore our second vulnerability for today.

19:12.320 --> 19:13.860
In AWS glue.

19:13.860 --> 19:16.120
This one is really strong.

19:16.120 --> 19:22.540
Because you only need the account ID to exploit a remote account.

19:23.760 --> 19:28.880
And just a reminder, account ID is not a secret by AWS, right?

19:29.860 --> 19:32.860
So, what is AWS glue?

19:32.920 --> 19:36.460
AWS glue is a service for data engineers.

19:36.560 --> 19:39.940
This is basically used for data manipulation.

19:40.360 --> 19:44.600
To trigger the vulnerability, the user needs to create a job in glue.

19:44.680 --> 19:50.020
When you do so, a bucket is automatically configured with a predictable name.

19:50.060 --> 19:52.820
There, files of glue will be stored.

19:53.780 --> 19:58.580
So, if a bucket is predictable, we can take it before the user.

19:59.360 --> 20:01.480
And that's exactly what we did.

20:01.800 --> 20:04.180
Our user creates a job.

20:04.180 --> 20:07.760
When he creates a job, a script is dropped to our bucket.

20:07.760 --> 20:10.400
We have our lambda that changes the file.

20:11.020 --> 20:16.140
And when the user runs the job, he gets the modified script.

20:16.260 --> 20:17.700
And voila.

20:17.700 --> 20:21.320
We have a remote code execution on the remote account.

20:24.790 --> 20:32.250
So, you are probably wondering, what are the privileges of the AWS glue service?

20:32.250 --> 20:38.910
So, it's actually configured by the user that triggers the job.

20:39.390 --> 20:47.810
Most of the time, it will be a default service role that you get when you use AWS glue for the first time.

20:48.410 --> 20:51.390
And that role is pretty interesting.

20:51.390 --> 20:59.450
Because it has a lot of enumeration potential on the account and also it has some write potential in the account.

20:59.450 --> 21:03.910
So, you could probably escalate from here.

21:03.910 --> 21:06.790
But it's not the topic for our talk.

21:06.890 --> 21:11.910
Another cool anecdote about this vulnerability is actually invisible.

21:12.010 --> 21:13.470
And I will explain.

21:14.630 --> 21:22.210
When the user tries to get the script and look at the script, he actually gets the original script.

21:22.210 --> 21:24.490
Even though it's already modified.

21:24.490 --> 21:28.470
And when he runs it, he actually runs the modified script.

21:28.470 --> 21:31.750
This is just due to a bug in the AWS glue.

21:31.750 --> 21:33.270
But it's still cool.

21:34.430 --> 21:36.590
So, let's see the full POC.

21:36.590 --> 21:38.870
We recorded that on February.

21:39.030 --> 21:43.770
Here you can see a user creating a glue job.

21:44.590 --> 21:50.910
When you press the save button, the files are dropped to the attacker bucket.

21:50.910 --> 21:55.610
And that's what also gives us the time to modify the script.

21:55.610 --> 22:03.810
Because if we are automating this, the Lambda takes just a couple of milliseconds to modify the to inject the code there.

22:04.110 --> 22:10.770
In this POC, we just put a print for POC purposes.

22:11.630 --> 22:16.990
And as you can see, when the user tries to get the script, he gets the original script.

22:16.990 --> 22:31.090
And when he runs the script, if we look at the logs, you can see that the script is actually modified and we got remote code execution.

22:36.260 --> 22:47.100
So, now let's explore the third vulnerability for today in EMR, which is another service of AWS.

22:47.100 --> 22:53.220
This one is also kind of cool because it, again, it's only the account ID.

22:53.220 --> 22:55.020
That's what we were looking for.

22:55.020 --> 22:59.440
And it has a cool post exploitation technique.

23:00.580 --> 23:06.500
So, EMR, it's a service for data consumption used by data scientists.

23:06.500 --> 23:08.260
Another data service.

23:09.140 --> 23:13.280
To trigger the vulnerability, the user needs to create a studio .

23:13.460 --> 23:17.360
And when you do so, a bucket is automatically configured.

23:17.400 --> 23:19.300
And that's where we come to the picture.

23:19.300 --> 23:22.360
Again, we open the bucket before the user.

23:22.360 --> 23:28.060
When the user creates a studio, he actually stores Jupyter notebooks to our bucket.

23:28.240 --> 23:32.860
And in our bucket, we have our Lambda that changes the code.

23:32.860 --> 23:37.980
And in Jupyter notebook, you can inject JavaScript.

23:38.160 --> 23:43.700
So, we decided to inject JavaScript here and it acts like stored XSS.

23:43.960 --> 24:00.180
When the user tried to open his EMR, his service, he gets the modified Jupyter notebook and every time he will go to the notebook, he will be redirected to a fake login page created by us.

24:02.700 --> 24:04.960
A quick disclaimer about this vulnerability.

24:05.520 --> 24:07.120
It's not a zero shot.

24:07.120 --> 24:16.780
It means that the vulnerability, when the user configures the page, he actually needs to do some changes because he gets an error.

24:16.780 --> 24:18.820
But the error is really vague.

24:18.980 --> 24:24.080
And when I see an error like this as a user, I do one of two things.

24:24.080 --> 24:31.160
Either I change the role or I use the policy that is recommended by AWS.

24:31.520 --> 24:35.240
In both cases, the vulnerability is going to work.

24:35.380 --> 24:38.900
This is due to inconsistent in AWS.

24:38.980 --> 24:48.300
The policy that they recommend is actually lacking a string condition that's supposed to protect you from such an attack.

24:48.320 --> 24:50.160
But they forgot it.

24:50.640 --> 24:58.880
Now Michael will show you a couple of more vulnerabilities and will show you how our technique applies on open source projects.

24:58.880 --> 24:59.800
Thank you.

25:05.870 --> 25:07.010
All right.

25:07.010 --> 25:09.090
So, thank you Ofek.

25:09.130 --> 25:12.290
So nowadays everyone loves AI and machine learning.

25:12.290 --> 25:15.410
And we could not miss a chance to talk about this on our lecture.

25:15.490 --> 25:19.610
Let's discuss the rest of the vulnerabilities and start from AWS SageMaker.

25:19.990 --> 25:26.390
So SageMaker is a tool in AWS that is designed to build, train and deploy machine learning models.

25:27.030 --> 25:35.450
Canvas is part of the AWS SageMaker ecosystem and it's a very cool no code drag and drop interface.

25:35.510 --> 25:52.250
We discovered that when a user creates a Canvas instance for the first time on a specific region, then a bucket with the name SageMaker dash region dash account ID is created and the S3 bucket will store files that are utilized by the service.

25:52.850 --> 25:55.090
So let's go over the full attack scenario.

25:55.910 --> 26:05.030
So the attacker has claimed the bucket before the user and then the user opens Canvas and it will create a data set and uploads the files.

26:05.270 --> 26:13.950
On the background the files will be uploaded to the attacker controller S3 bucket and then the attacker could get the data set and we will have data leakage.

26:14.070 --> 26:23.670
But if that's not enough, the attacker could also manipulate the data set and then SageMaker will use the manipulated data set and we have data manipulation.

26:24.250 --> 26:31.470
So it may lead to inaccurate models and all of this can happen without the user even knowing that something has changed.

26:32.550 --> 26:35.990
And to our next vulnerability on AWS is on CodeStar.

26:36.270 --> 26:43.550
So CodeStar is a tool that provides a unified user interface to easily manage software development activities.

26:43.870 --> 27:04.430
So the service was deprecated just I think two weeks ago and in this scenario the attacker has claimed the bucket again before the user and when a user tries to create a CodeStar project on a region, then CodeStar on the background will try to create a bucket and it will fail and it will return the user an error.

27:04.550 --> 27:11.610
So this is essentially a denial of service attack since the attacker prevents the user from using CodeStar on a specific region.

27:13.170 --> 27:16.370
And there's one more vulnerability on service catalog.

27:16.370 --> 27:22.370
We won't elaborate about it right now but we're going to publish a blog in the next few hours so you could see it there.

27:24.510 --> 27:35.510
So after we talked about the vulnerabilities in AWS, on our research we also identified that this attack vector affects many open source projects as well apparently.

27:36.030 --> 27:51.990
And many open source projects create S3 buckets as part of functionality and the consequences change depending on the project but some projects are vulnerable and could allow an attacker to gain full access to all of the files in the bucket.

27:52.090 --> 27:58.390
So here you can see an example of a project that checks if the bucket exists.

27:58.570 --> 28:09.810
And this check is wrong since an attacker could claim the bucket and the project will print to the screen that the bucket already exists but it will continue running without any problems.

28:10.770 --> 28:18.290
And there's another example of a project that tries to verify that the bucket exists and it tries to list the bucket.

28:18.290 --> 28:38.650
But this check is also wrong since an attacker could claim the bucket, open it for public access, set permissive policy and by doing so it will allow the victim to list using the AWS S3LS command to list the bucket and again the script will continue running without any failure.

28:40.250 --> 28:46.350
And also as part of our investigation we found services that could be vulnerable in the past.

28:46.350 --> 28:48.970
These services created predictable bucket names.

28:48.970 --> 28:57.850
For instance Athena once created a bucket with the name AWS Athena query results dash account ID dash region.

28:57.970 --> 29:08.410
This bucket is not created anymore and when we encountered it Athena did not seem to be vulnerable and now this bucket is created by the user specification.

29:09.710 --> 29:10.250
All right.

29:10.250 --> 29:14.710
So we discussed vulnerabilities in AWS services and open source projects as well.

29:14.710 --> 29:19.070
Now let's explore how we can elevate what we've learned so far to the next level.

29:19.790 --> 29:23.770
So we wanted to increase the chances of a victim to be compromised.

29:24.210 --> 29:32.270
It would be important to us to show that this attack vector is not just theoretical but it's also practical and effective on real world scenarios.

29:32.290 --> 29:37.290
And we are proud to produce uh, to introduce a new technique we named bucket monopoly.

29:37.830 --> 29:41.930
So in previous vulnerabilities we targeted specific regions of other accounts.

29:41.930 --> 29:47.370
We could check if a bucket already, already exists and if not we could claim it before the victim.

29:47.510 --> 29:50.910
However as you all know AWS has multiple regions.

29:51.110 --> 29:56.890
So instead of focusing on a single region we could claim all possible regions that the user has not claimed yet.

29:57.470 --> 30:04.030
This strategy increases the likelihood of an unsuspecting victim interacting with an attacker on S3 bucket.

30:04.770 --> 30:11.310
But since we have several vulnerable services let's create all of the buckets in all of the possible services.

30:11.970 --> 30:14.050
This is practically a land mine.

30:14.050 --> 30:18.290
The victim is surrounded by malicious buckets belonging to different services.

30:19.210 --> 30:28.030
Whenever the victim will use a new service from uh, the six services we presented on any new region it will be immediately compromised.

30:30.310 --> 30:34.110
Let's explain step by step how to perform this kind of attack.

30:34.690 --> 30:38.450
First of all we must identify predictable bucket name.

30:38.510 --> 30:44.810
After finding these buckets we need to verify that the associated services that create these kinds of buckets are indeed vulnerable.

30:45.370 --> 30:48.510
Secondly we must recognize what is the unique identifier.

30:48.990 --> 30:54.130
And the last step which is the easy one we need to claim all the bucket names across all regions.

30:55.170 --> 30:58.230
So we showed you several ways how to find these kinds of buckets.

30:58.530 --> 31:07.830
We start reconnaissance by looking for bucket names that contains a prefix or a postfix alongside with an identifier like account ID or a hash.

31:08.610 --> 31:11.590
And it could be achieved by using the GitHub regex search.

31:11.590 --> 31:13.990
We could read AWS documentation as well.

31:14.070 --> 31:19.990
And we could use, we could crawl AWS services with tools like TrailShark that Ofig just showed you before.

31:20.530 --> 31:25.890
Next the second step is to understand what is the unique identifier inside the bucket name.

31:26.310 --> 31:30.270
It might be a random hash and it will require further instigation.

31:30.950 --> 31:34.730
It could also be account ID or some kind of other public metadata information.

31:35.530 --> 31:41.990
If it's a hash we could search on GitHub and on source graph to find leaked hashes and then target them.

31:42.150 --> 31:45.150
And if it's an account ID there are multiple ways to find them.

31:45.350 --> 31:47.630
So the first method is to use GitHub.

31:47.990 --> 31:51.430
We could search the GitHub regex search for specific patterns.

31:51.690 --> 32:00.830
We could also leverage the gray head warfare platform which is a platform that collects publicly accessible S3 buckets and then we could extract the account ID out of the bucket.

32:00.910 --> 32:07.290
So Jerome Brown did it and he extracted nearly 197 thousand unique account IDs.

32:07.750 --> 32:11.410
We could also extract the account ID out of the AWS access key ID.

32:11.410 --> 32:14.090
Nice article by Tal Berry who showed how to do it.

32:14.670 --> 32:22.970
And lastly there are valuable lists out there of known AWS accounts which includes account IDs of numerous large organizations and vendors.

32:23.750 --> 32:25.850
And the last step is to monopolize.

32:25.850 --> 32:37.930
So attacker utilize the understanding of naming conventions and account IDs to strategically create S3 buckets with predictable names across all AWS regions where these buckets do not exist yet.

32:37.930 --> 32:49.050
Then the attacker will open the bucket for public access, set permissive policy and by doing so they position themselves to intercept the victim future interactions with these buckets.

32:50.270 --> 32:53.150
Now let's talk a little bit about disclosure and timeline.

32:53.370 --> 32:58.690
So we reported these vulnerabilities at the middle of February and AWS immediately started fixing them.

32:59.210 --> 33:07.190
We got a final confirmation that the vulnerabilities were fixed at the end of June and the general approach here was consistent.

33:07.230 --> 33:20.690
So AWS will either add some kind of a random sequence or a number to the bucket and then create it or they will prompt the user to choose a new bucket name thereby they will ignore the already claimed bucket.

33:20.990 --> 33:29.690
AWS also indicated that they confirmed the results of each team investigation and they will contact customers directly in the event that they were affected.

33:30.390 --> 33:33.170
So to conclude what we've seen up until now.

33:33.170 --> 33:39.150
We have identified six vulnerabilities in AWS that might enable an attacker to exploit organization.

33:39.330 --> 33:47.690
We explained how these vulnerabilities occur and we presented a new attack vector called shadow resources as well as the technique we named bucket monopoly.

33:47.690 --> 33:59.270
While the vulnerabilities we mentioned were already mitigated by AWS this attack vector can still be applicable to other AWS services and many, many open source projects as you just saw.

33:59.430 --> 34:09.170
So to prevent an entity that assumes a role accessing a bucket you do not trust you can define a scoped policy that contains the AWS resource account condition.

34:09.250 --> 34:18.530
So this approach will prevent the user in your account to access and write data to buckets that are located on accounts you do not trust.

34:19.610 --> 34:31.530
We also recommend verifying that the owner of the S3 bucket using the expected bucket owner header to ensure that the buckets that are used by your services are indeed under your account.

34:31.570 --> 34:32.670
It's very simple.

34:32.670 --> 34:41.730
You can just take each one of your buckets, the cloud formation, the glue, the EMR and the rest of them and for each region check that no one has claimed your bucket.

34:41.730 --> 34:46.710
It's a simple solution and it's great to check if you haven't been exploited.

34:48.570 --> 34:49.770
Sorry, this command.

34:49.950 --> 34:57.250
And the expected bucket owner header is also valuable for open source projects as well to verify that no one has claimed the bucket.

34:58.770 --> 35:10.030
And lastly, name your S3 bucket with some kind of a random number or a string making the bucket name less predictable.

35:13.370 --> 35:19.230
So, after everything we've demonstrated, do you still believe account ID is not a secret?

35:19.790 --> 35:20.410
Thank you.

35:20.410 --> 35:23.770
We have short time for questions and you're welcome to follow us on Twitter.

35:26.630 --> 35:27.950
All right.

35:36.380 --> 35:38.420
Questions anyone?

35:39.480 --> 35:40.760
All right.

35:47.080 --> 35:48.280
We can.

35:54.300 --> 36:02.000
So, do I policy to prevent a lot of these attacks?

36:02.000 --> 36:03.980
So, you can use them.

36:04.100 --> 36:13.600
As I showed you before, the, sorry, the, thank you.

36:13.700 --> 36:15.880
So, you should, we showed you several ways.

36:15.880 --> 36:25.660
I think the resource account condition should be fine to prevent all your roles and users that are assuming this role from accessing buckets you do not trust.

36:25.660 --> 36:46.120
I mean, for specific roles that need to access some kinds of buckets, you just, I mean, by default, I recommend adding these like section to making sure that the buckets you try to access or your services, et cetera, will not access buckets that you do not own or maybe someone else owns.

36:46.120 --> 36:47.020
Right.

36:47.020 --> 36:52.260
Because you might also delete the bucket and then someone can create it.

36:52.260 --> 36:55.420
So, it's like a dangling resource as well.

36:55.720 --> 36:56.220
All right.

36:56.220 --> 36:59.560
Yeah, I think I'm going to have to go back through and double check my... Thank you.

36:59.560 --> 37:01.240
My deny policies.

37:01.240 --> 37:01.880
Right.

37:02.680 --> 37:04.240
All right.

37:04.520 --> 37:06.380
Thank you very much for attending.

