Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 38 ยท Web, Network and Cloud Testing

Cloud Penetration Testing

Learn the rules for testing cloud environments, the shared responsibility model, and how to audit IAM policies, storage exposure and metadata services without harming the tenant.

Moving to the cloud changes what a penetration test looks like. There is less to scan at the network layer and much more to review in identity and configuration: who may do what, which storage is public, which services are exposed, and which keys have leaked. In cloud incidents the usual root cause is not a zero-day but a permission that was too broad, a storage bucket left open, or an access key committed to a repository.

This lesson covers the rules for cloud testing and the main areas to review. The cloud CLIs and consoles cannot run on this site, so the commands are shown read-only, and the audits run as Python stand-ins on invented policy documents. For deeper coverage of the platforms themselves, see the cloud security course.

Rules first: provider and tenant

  • Every major provider publishes a penetration testing policy. Most allow testing of your own resources for common services without prior approval, but forbid denial-of-service, attacks on the provider's own infrastructure and on other customers. Policies change: read the current one before each engagement.
  • The client, not you, owns the account. Get written authorization from the account owner, the account or subscription IDs in scope and a list of off-limits services.
  • Use a dedicated test identity with the permissions agreed for the test, and record which credentials you used. Cloud logs (CloudTrail, Activity Log and similar) will show your actions, so tell the client's security team when you test.
  • Be careful with anything billable: creating many resources or running heavy scans costs real money.

The shared responsibility model

The provider secures the cloud itself (data centres, hardware, hypervisors). The customer secures everything they put in it (identities, data, configuration, applications). A penetration tester almost always works on the customer's side of that line.

Layer Who is responsible (IaaS example)
Physical data centre Provider
Hypervisor and core services Provider
Operating system on a virtual machine Customer
Network rules and security groups Customer
Identity, roles and keys Customer
Data and its encryption settings Customer

Main areas to test

Cloud test areas

Identity (IAM) Roles, policies, keys
Storage Buckets and blobs
Compute VMs, containers, functions
Network Security groups, endpoints

Identity is the new perimeter.

1 / 2

Identity and access management (IAM)

Policies decide who may do what to which resource. The classic weaknesses:

  • "Action": "*" with "Resource": "*" (full administrator) attached to ordinary users or services.
  • Wildcards on sensitive services (for example all iam:* actions), which let a user grant themselves more rights, so any identity that may edit policies or pass roles can usually become an administrator.
  • Long-lived access keys that never rotate, and keys for the root or owner account.
  • Missing MFA for console users and for privileged actions.
  • Roles that any account can assume because the trust policy is too wide.
Python Audit IAM policy documents

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Each flagged policy has a clear fix: split broad roles into narrow ones, replace * with the exact actions and resources needed, add conditions (source network, MFA), and remove the permissions that let identities edit their own rights.

Storage exposure

Object storage (S3, Azure Blob, Google Cloud Storage) is a frequent source of leaks. Check public access settings at the account and bucket level, bucket and object ACLs, resource policies with Principal: *, whether encryption and versioning are enabled, whether access logging is on, and whether sensitive files (backups, .env, database dumps) are stored there at all. Read-only commands for your own account look like this:

TEXT
aws s3api get-public-access-block --bucket reports-prod
aws s3api get-bucket-policy-status --bucket reports-prod
az storage account show --name reportsprod --query allowBlobPublicAccess
Python Audit storage bucket settings

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A public bucket holding customer exports is a high-severity finding even when nobody has noticed it, because search tools index open buckets continuously. The public web-assets bucket is expected to be public, so a tester checks its content rather than reporting it as a vulnerability.

Compute, containers and metadata

Virtual machines and containers inherit the usual OS and application risks. The cloud-specific one is the instance metadata service, a local address (169.254.169.254) that gives a workload temporary credentials for its role. If an application has a server-side request forgery (SSRF) flaw, an attacker may make it fetch those credentials. Defenses: enforce the newer token-based metadata version (IMDSv2 on AWS), give workloads minimal roles, and block SSRF in the application. Also review security groups for admin ports open to the internet, public database endpoints, containers running as root or privileged, container registries with public images and exposed Kubernetes dashboards.

Secrets and CI/CD

Search repositories and build logs (those you are authorized to read) for access keys, tokens and passwords. Review who can change pipeline definitions, because a pipeline with deploy rights is effectively an admin account. Recommend short-lived federated credentials (OIDC) instead of stored long-term keys.

Reporting cloud findings

State the account or subscription, the resource ID, the exact setting or policy and the blast radius: "this role is attached to 14 instances and allows reading all customer data." Remediation should reference the provider's own tooling: IAM Access Analyzer, Security Hub, Defender for Cloud or Security Command Center, plus infrastructure-as-code scanning so the fix survives the next deployment.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Under the shared responsibility model, who is normally responsible for IAM policies and storage settings?

    Identity, data and configuration are on the customer's side, which is why they are the main test targets.
  2. 2. Which statement is the strongest finding in an IAM review?

    Action * on Resource * is full administrator access.
  3. 3. Why is the instance metadata service important to protect?

    Requiring token-based metadata access and using minimal roles reduce the impact of SSRF.
  4. 4. Before a cloud test, what should you check about the provider?

    Policies forbid some tests, such as denial-of-service and attacks on other customers or the platform itself.

Summary

  • Cloud tests focus on identity, storage, configuration and secrets more than on the network layer.
  • Read the provider's testing policy, test only the client's accounts with a dedicated test identity, and watch costs.
  • Audit IAM for wildcards, privilege-escalation permissions, long-lived keys and missing MFA.
  • Check storage for public access, encryption, versioning and logging; protect the metadata service.
  • Report resource IDs and blast radius, and recommend IaC scanning and provider security tools.

Next: Risk rating and evidence