Skip to content

Lesson 2 of 9 · 22m

Exposure Inventory: Finding the Cloud You Actually Have

Inventory accounts, regions, public resources, secrets, and trust relationships before exploitation — the attack surface is mostly configuration drift.

In cloud estates, shadow infrastructure is normal. A proof-of-concept bucket becomes production, a developer account still trusts an old CI role, and the logging bucket nobody remembers has public read disabled but public write enabled by mistake. Before you attack anything, build the map. Most high-impact cloud findings are discovered by patient inventory, then confirmed with one carefully chosen API call.

Start with accounts and regions

for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
  echo "== $r =="
  aws ec2 describe-instances --region "$r"     --query 'Reservations[].Instances[].{id:InstanceId,state:State.Name,public:PublicIpAddress}'     --output table
done

Do the same shape of enumeration for load balancers, RDS instances, Lambda functions, EKS clusters, and CloudFront distributions. Cloud assets are regional, while identity is mostly global. A "clean" account in us-east-1 can be wide open in ap-southeast-2.

Public exposure has more than one meaning

Public can mean internet-routable, publicly resolvable, cross-account accessible, or exposed through a service-specific policy. These are different failure modes:

{
  "Effect": "Allow",
  "Principal": "*",
  "Action": "s3:GetObject",
  "Resource": "arn:aws:s3:::customer-exports/*"
}

That is intentionally public object access. But this one is cross-account exposure that often slips past review:

{
  "Effect": "Allow",
  "Principal": {"AWS": "arn:aws:iam::123456789012:root"},
  "Action": "sts:AssumeRole",
  "Resource": "*"
}

root in a trust policy does not mean only the root user. It means the account, including any identity there that can pass the role trust and has permission to assume it.

Secrets live everywhere

Search configuration artifacts, not just application code: user data, Lambda environment variables, ECS task definitions, pipeline variables, Terraform state, container images, and CloudFormation parameters. Useful defensive validation commands include:

aws lambda list-functions --query 'Functions[].{name:FunctionName,env:Environment.Variables}'
aws ec2 describe-instances --query 'Reservations[].Instances[].UserData'
aws ssm describe-parameters --query 'Parameters[].Name'

Do not print secret values in a report. Record location, type, blast radius, rotation status, and proof of access without disclosing the credential.

A useful inventory row records the asset, trust boundary, likely sensitivity, reachable identities, and the least invasive next validation.

Field notes

  • Tagging lies. Environment=prod is a hint, not evidence; ownership, data, and network reachability decide criticality.
  • Missing regions are a governance smell. Attackers do not care that central IT only uses two.
  • Prefer service-native export APIs and existing scanners over custom brute force enumeration; rate limits and cost are real.
  • Always distinguish "publicly exposed" from "publicly exploitable." One is reachability, the other requires a working path.

Was this lesson helpful?

Sign in to rate