Day 17
Last updated
Last updated
S3 is the Amazon Web Service used for data storage, but for our purposes it might as well stand for Stealing Secrets Sneakily. The benefits of the cloud - massive amounts of data available anywhere - can quickly become a security nightmare if you don't know how to properly secure it. But that's what we're here to help with.
Somehow, the Grinch has managed to get hold of all the Elves' names and email addresses. How could this have happened? Given the scope of the breach, McSkidy believes someone in HR must be involved. You know that HR recently launched a new portal site using WordPress. You also know that HR didn't request any infrastructure from IT to deploy this portal site. Where is that portal hosted?
We'll be using the AWS CLI tool to explore the Best Festival Company's cloud infrastructure and see what sort of information is exposed.
What is the name of the S3 Bucket used to host the HR Website announcement?
To find out what S3 bucket they're using, let's check the website assets and see what URLs they're using. Scrolling up and checking out the tree on the right in today's challenge description, we see an interesting url.
Therefore the bucket is "images.bestfestivalcompany.com".
Now we can start looking at the bucket from the outside.
We're already seeing some juicy stuff. Onto our next question:
What is the message left in the flag.txt object from that bucket?
Let's download it:
And then cat
it out:
What other file in that bucket looks interesting to you?
If your eyes were drawn to wp-backup.zip, you're already a Super-A Class Hacker. We know the HR department launched a WordPress site, so if this is a backup of the site after it was configured, we should find some useful creds.
What is the AWS Access Key ID in that file?
The first port of call when you've got access to a WordPress directory is wp-config.php. cat
this out and we get what we need:
What is the AWS Account ID that access-key works for?
Now that we have some keys, let's configure a local AWS profile for them:
I called the profile "bfc" for Best Festival Company but you might prefer a more descriptive title.
Now we can use the access key to look up the account ID:
"STS" is the AWS Security Token Service and this part of the API exposes a few methods for identity and access management. You can read more about it here.
What is the Username for that access-key?
We can run the following command and it'll look at the access key we've configured for this profile and return some more user info:
We get "ElfMcHR@bfc.com".
There is an EC2 Instance in this account. Under the TAGs, what is the Name of the instance?
In the same way that we can access STS-related methods via the STS API, we can access EC2 related methods via the EC2 API. Wow, AWS sure does make it easy for us huh?
To list all the EC2 instances running, we can do:
But that gives us a whole bunch of info we don't need, so let's pare it down:
We get a much more manageable result:
What is the database password stored in Secrets Manager?
Secrets Manager is yet another Amazon Web Service with its own methods. First let's list the secrets out:
Now that we've got the name of the secret, we can look it up. The API reference for get-secret-value says we can give it either a friendly name or the ARN. Let's use the friendly name.
Ah! Fooled again. We find this disappointment:
A "region" in AWS terms is a part of the world where AWS has a bunch of data centres. Each region (e.g. us-east-1, which is what we're looking at right now and which is predictably on the US east coast) includes multiple Availability Zones, which are redundant data centres. This setup makes AWS extremely resilient. For most AWS services, you set them up in a region, and there are a bunch of implications for which region you choose and whether you want the services in one to interact with services in another.
Looking at a map of AWS regions, it looks like the northernmost region is in Europe. There's a region called "eu-north-1" so let's try that.
First let's list our profile details:
Now let's change the region for our profile:
If you run the list
command again, you'll see it says "eu-north-1" instead of "us-east-1" now.
Now let's list our secrets again:
Aha! We see new secrets. We must be on the right track. This one is also called HR-Password but the description this time says "Employee DB Password". We can use the same command we did last time to get the secret:
This time, we see something much more valuable:
Too easy. That's why it's so important to lock down your cloud.