Public Snapshots
Next we need to provide the Amazon Resource Name (ARN) of the role under our control (i.e. in our own AWS account), as well as a target S3 bucket in the AWS account whose ID we want to enumerate. Here we have created the role and provided it for you.
This reveals the AWS account ID 107513503799
. We can use this information to hunt down public resources that might have been accidently exposed by the account owner, such as public EBS and RDS snapshots.
First, it would be good to know the AWS region that the S3 bucket was created in, as public snapshots are available to all users in the same region that the EBS or RDS snapshot was created in. It's likely that if the S3 bucket was created in a specific region, that other resources will be available there too!
To find the S3 bucket region we can use another trick, this time with cURL.
In the response headers we see that the header x-amz-bucket-region
is set to us-east-1
, which is North Virginia. Next, log into the AWS management console in your own personal AWS account and make sure that the us-east-1
region is selected.
๐ Overview
In this lab, weโll perform basic enumeration against an exposed AWS S3 bucket linked from a public-facing web service. Weโll extract the AWS Account ID that owns the bucket โ a valuable piece of information for cloud pentesting, as it can be used to track down other public AWS resources like EBS and RDS snapshots. Weโll walk through:
Discovering a service and identifying an S3 bucket
Enumerating the AWS Account ID via role assumption
Identifying the S3 bucketโs region
Searching for publicly exposed snapshots owned by that account
Publicly exposed EBS and RDS snapshots can unintentionally leak sensitive data or system configurations if not secured properly (e.g. Capital One breach).
๐ Enumeration
We start by scanning the target IP for open ports:
$ sudo nmap -T4 -p- -open -Pn 54.204.171.32
<SNIP>
PORT STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 280.46 second

Visiting the site's source code reveals some images being loaded from an AWS S3 bucket (Figure 2). By visiting https://mega-big-tech.s3.amazonaws.com
, we can list the bucketโs contents if permissions allow it (Figure 3).


๐ AWS CLI Credentials
Weโre provided with AWS credentials to assume a role for this lab that will allow us to execute commands in a specific user context, in this case, have the s3:GetObject
and s3:ListBucket
permissions.
Assuming a role that's assigned one of these permissions is required for the
s3-account-search
script to work.
# credential configuration
$ aws configure
AWS Access Key ID [None]: AKI<REDACTED>7HK
AWS Secret Access Key [None]: UdU<REDACTED>Hq3
Default region name [None]:
Default output format [None]:
# check the identiry behind the above credentials
$ aws sts get-caller-identity
{
"UserId": "AIDAWHEOTHRF62U7I6AWZ",
"Account": "427648302155",
"Arn": "arn:aws:iam::427648302155:user/s3user"
}
The s3-account-search
script attempts to enumerate the AWS Account ID of the target S3 bucket by using our credentials and a role we control.
$ s3-account-search arn:aws:iam::427648302155:role/LeakyBucket mega-big-tech
Starting search (this can take a while)
found: 1
found: 10
found: 107
found: 1075
found: 10751
found: 107513
found: 1075135
found: 10751350
found: 107513503
found: 1075135037
found: 10751350379
found: 107513503799
This Python script is a cloud enumeration utility designed to brute-forces the AWS account ID of a target S3 bucketโs owner by:
Assuming a provided IAM role in your account.
Incrementally testing IAM policies that allow access only if the resource belongs to an account whose ID starts with specific digits.
Brute-forcing one digit at a time by checking whether access is allowed, using AWSโs
s3:ResourceAccount
condition key.Repeating this until the full 12-digit account ID is discovered.
Assume IAM Role
โ
Test IAM Policy with 1 digit
โ
Access Granted?
โ โ
Yes No
โ โ
Append Try next digit
digit โ
โ
Repeat until 12 digits found
We can use curl
to check which region the bucket resides in. This is crucial because public snapshots are only visible in their home region.
$ curl -I https://mega-big-tech.s3.amazonaws.com
HTTP/1.1 200 OK
x-amz-id-2: Kjoy7MFQr2HIKEnCNtV0Lxb6Qk6Ckp2j+/eFO/YXgfP3eEox3EmC/YJgsm0iJcz40wFhCISO4+PYEp4f17wIbOjdD4Ep4MT9
x-amz-request-id: FWXE4YE6VQMH4T64
Date: Tue, 15 Apr 2025 10:31:21 GMT
x-amz-bucket-region: us-east-1
x-amz-access-point-alias: false
Content-Type: application/xml
Transfer-Encoding: chunked
Server: AmazonS3
๐ Public Snapshots
Now log into your personal AWS account, and in the us-east-1 region (Figure 4.1). Once logged-in:
Go to EC2 โ EBS Snapshots (Figure 4.2 & 4.3)
Select Public Snapshots (Figure 4.4)
In the search bar, type:
Owner = 107513503799
(Figure 4.5)

Once we have the owner's ID, after configuring the region, we can enumerate public snapshots via the CLI.
$ aws configure
AWS Access Key ID [****************P7HK]:
AWS Secret Access Key [****************4Hq3]:
Default region name [None]: us-east-1
Default output format [None]:
$ aws ec2 describe-snapshots --owner-ids 107513503799
{
"Snapshots": [
{
"StorageTier": "standard",
"TransferType": "standard",
"CompletionTime": "2023-06-25T23:10:22.078000+00:00",
"SnapshotId": "snap-08580043db7a923f6",
"VolumeId": "vol-04462a3562c7e6a15",
"State": "completed",
"StartTime": "2023-06-25T23:08:45.155000+00:00",
"Progress": "100%",
"OwnerId": "107513503799",
"Description": "Created by CreateImage(i-089b146125db92ee4) for ami-0676627ee43624fb2",
"VolumeSize": 8,
"Encrypted": false
}
]
}
โ
Summary
In this lab you learned to:
Scan for open services
Identify S3 bucket references in web pages
Interact with AWS CLI and configure credentials
Use Security Token Service (STS) to verify the active identity
Enumerate a bucket ownerโs AWS Account ID
Identify a bucketโs region using HTTP headers
Search for public AWS resources (like EBS snapshots) associated with that account
๐ Key AWS Concepts
S3 Bucket
Cloud-based object storage container
AWS Account ID
Unique 12-digit AWS account identifier
Role
Temporary credentials allowing users/services to assume permissions
Security Token Service
API to retrieve details about the current identity
Public Snapshot
An EBS/RDS snapshot marked public and accessible by anyone in its region
Last updated
Was this helpful?