Practice library / Cloud security basics
Lab · Medium · 2 hoursFree account
Cloud AWS Enumeration
Enumerate AWS with compromised keys: IAM, S3, EC2, Lambda, and Secrets Manager.
On this page 8 sections
Before you start
A stolen AWS access key can turn into a full account takeover if the credentials have the right IAM paths. Breaches at companies such as Capital One and Code Spaces show how a single leaked key can lead to S3 data loss or destroyed infrastructure. Here you configure the AWS CLI with compromised keys, enumerate IAM, S3, EC2 and Lambda, and map privilege escalation paths with Pacu.
Lab Objectives
- Configure AWS CLI with compromised access key credentials
- Enumerate accessible services and resources
- Identify IAM privilege escalation paths using Pacu
- Find exposed S3 buckets and access sensitive data
- Enumerate Lambda functions for hardcoded secrets in environment variables
- Use enumerate-iam for automated permission discovery
Build the target
KaliRange hosts no AWS account, no IAM users and no cloud infrastructure. Run every command below against your own AWS account, with your own access key in place of the example AKIAIOSFODNN7EXAMPLE below.
Your own account needs:
- An IAM user with an access key, holding a policy wider than it should be: enough rights to list IAM users and policies, list S3 buckets, list EC2 instances and read Lambda and Secrets Manager, so the enumeration commands below return results.
- At least one S3 bucket, one EC2 instance with an attached IAM role, and one Lambda function with an environment variable, so the S3, EC2 and Lambda steps have something to find.
- The AWS CLI installed and configured (
aws configure), plus Python 3 forenumerate-iamand Pacu.
Build this on the AWS Free Tier: create a new IAM user in your own account, attach a policy with the read rights the commands below use, and create one small S3 bucket, one EC2 instance and one Lambda function to enumerate. Never use a credential that is not yours, and delete the key and the test resources when you finish.
Authorised account only. Run every command in this lab only against an AWS account that you own. Never point these commands at an account you do not control.
Topics Covered
- AWS CLI setup and credential types (access keys, role credentials)
- IAM enumeration and policy document analysis
- S3 bucket enumeration and data exfiltration
- EC2 enumeration and IMDS exploitation
- Lambda and Secrets Manager enumeration
- IAM privilege escalation via policy attachment and PassRole
Setup
aws configure
# Access Key ID: AKIAIOSFODNN7EXAMPLE
# Secret Access Key: wJalrXUtnFEMI/K7MDENG
# Region: us-east-1
aws sts get-caller-identity # verify which identity you haveSign in to continue
5 more sections are for signed-in members. It is free: sign in with Google.
Related
This lab is extra practice for the course Cloud security basics. Do the lessons first.Open the course