CloudGoat (cloud_breach_s3) Walkthrough

In this CloudGoat scenario (cloud_breach_s3), the objective is to exfiltrate confidential files from an S3 bucket. We’re provided with an EC2 instance IP address and the AWS account number. The EC2 instance is acting as a reverse proxy, which becomes the pivot point for the attack. Knowing this, I started by attempting to access the EC2 instance metadata. Using a simple curl request, I was able to query the metadata service. The instance was configured with IMDSv1, which allows unauthenticated access from inside the instance or via SSRF. Through this, I was able to retrieve a temporary access key and session token. With these credentials, I configured my AWS CLI and successfully enumerated and accessed the S3 buckets. I then downloaded the cardholder data files to my local machine.


What is Instance Metadata?

The Instance Metadata Service (IMDS) is how EC2 instances obtain identity and configuration information about themselves, including temporary IAM credentials. These credentials allow the instance to interact with other AWS services securely without hardcoding secrets in the code or environment. When misconfigured, however, IMDS can be a serious security risk. With IMDSv1, any process or attacker with access to the instance (or a vulnerable reverse proxy) can query metadata without authentication, leading to credential theft. To mitigate this, AWS introduced IMDSv2, which requires a session token to access metadata helping block SSRF attacks and reduce the attack surface.


What is S3?

Amazon S3 (Simple Storage Service) is like a cloud-based hard drive that lets you store and retrieve files over the internet. Think of it like Dropbox, Google Drive, or OneDrive but more flexible and integrated into cloud applications. Files in S3 are stored in buckets, which can be public or private. Misconfigured buckets are one of the most common causes of cloud data leaks, exposing sensitive data like credentials, logs, or even customer data. When working with S3, always follow the principle of least privilege only grant access to people or services that absolutely need it, and avoid public access unless absolutely required.


Detailed Steps:

Initial Access

Curl request to enumerate EC2 reverse proxy

  • We were able to query the meta-data and find a temp token

Caller Identity

Enumerating S3 buckets

We found the confidential files.

  • Downloading the files with sync command
  • Files seem to contain Social, Name, Password, Email, Sex, and IP

Leave a Reply

Your email address will not be published. Required fields are marked *