Skip to content
Back to Blog
·9 min read·technology

Cloud Penetration Testing: AWS Attack Techniques Explained

Learn AWS penetration testing methodology: IAM privilege escalation, SSRF-to-IMDS credential theft, S3 exposure, and the defences that stop real cloud attacks.

BR

Bachao.AI Research Team

Cybersecurity Research

Scan Your Attack Surface

Security exposure this creates

Unpatched vulnerabilities in your tech stack are the #1 entry point for breaches targeting Indian businesses. Here's what to watch.

AWS penetration testing is authorised security testing that simulates how a real attacker would compromise an AWS environment — starting with IAM enumeration, moving through misconfiguration discovery and privilege escalation, and ending in data access or lateral movement. Unlike a misconfiguration checklist, it follows actual attacker methodology: enumerate identities, abuse SSRF to steal instance credentials from the metadata service, exploit permissive policies, and pivot through Lambda or EC2 roles. For Indian cloud teams running production on AWS, understanding this attack chain — not just the settings to fix — separates a real security assessment from a compliance checkbox.

What Cloud Penetration Testing Actually Tests

Cloud penetration testing differs fundamentally from testing an on-premises network. There's no perimeter firewall to breach — the attack surface is IAM, API permissions, and the trust relationships between services. A misconfigured IAM policy, an SSRF-vulnerable web application, or an overly permissive Lambda role can hand an attacker the same access a stolen root password once did, without touching a traditional network boundary.

This matters because the shared responsibility model puts configuration security on the customer. AWS secures the infrastructure; the customer secures everything built on top of it — identities, policies, network configuration, application code. Most real-world AWS compromises exploit exactly this layer, not a flaw in AWS's own infrastructure.

ℹ️
INFO
AWS publishes an explicit penetration testing policy permitting customers to test their own AWS-owned resources without prior approval, within permitted services, excluding activities like DNS zone walking, DDoS simulation, or testing another customer's infrastructure. Confirm current in-scope services before testing — the list changes.

AWS Penetration Testing Rules: What's Actually Authorised

Before any technique below is used, scope has to be nailed down. AWS's self-service pentest policy authorises testing resources you own across a defined set of in-scope services — EC2, RDS, CloudFront, Lambda, API Gateway, and more — but prohibits certain activities regardless of ownership: DNS zone walking via Route 53, denial-of-service testing, and anything affecting other customers' resources. A multi-account organisation also requires each account owner's authorisation, not just the payer account's.

    1. Confirm the account tested is one you own, with written authorisation if performed for a client.
    2. Cross-reference AWS's current permitted-services list — testing an unlisted service can trigger AWS's abuse response process.
    3. Never test shared or multi-tenant resources without isolating scope first.
    4. Log every action taken — this becomes remediation evidence and your defence if AWS's monitoring flags it.
⚠️
WARNING
Testing outside AWS's authorised scope — even a scan that accidentally touches a third-party SaaS integration in the same VPC — can be treated as unauthorised access under AWS's terms of service. Document scope precisely before the first command runs.

Phase 1: IAM Enumeration and Reconnaissance

Every real-world AWS attack chain starts with identity enumeration, because IAM is the control plane for everything else. An attacker who gains even low-privilege credentials — via a leaked access key in a public GitHub repo, a phished developer, or a compromised CI/CD pipeline — begins by mapping what that identity can actually do.

Tools built for this, such as Pacu and ScoutSuite, automate calls like iam:ListUsers, iam:ListRoles, and iam:ListPolicies to build the account's identity graph: which users exist, which roles trust which principals, and which policies attach where. Many of these calls succeed even for low-privilege identities, so this phase is often near-silent. The output is a permissions graph that turns the next phase, privilege escalation, into pattern-matching rather than guesswork.

Know your vulnerabilities before attackers do

Run a free VAPT scan — takes 5 minutes, no signup required.

Book Your Free Scan

Privilege Escalation Through Misconfigured IAM Policies

Once an attacker holds a permissions graph, they search it for known IAM privilege-escalation patterns — documented, repeatable paths where a low-privilege identity can grant itself higher privilege through a policy the account owner didn't intend to be exploitable. These patterns are consistently found in real environments, particularly where policies were written broadly at setup and never tightened.

Escalation pathHow it worksTypical root cause
iam:PassRole + lambda:CreateFunctionCreates a Lambda function, passes it a high-privilege role, then invokes itBroad PassRole scope not restricted to specific roles
iam:CreatePolicyVersionAdds a new, permissive version to a policy already modifiablePolicy edit permission not scoped to non-privileged policies
iam:AttachUserPolicyAttaches AdministratorAccess or similar to own userMissing restriction on self-attachable policies
sts:AssumeRole on trusting roleTrust policy allows assumption by a broader principal set than intendedWildcard principal in trust policy
ec2:RunInstances + instance profileLaunches an instance with a high-privilege profile, then reads its credentialsInstance profile not scoped to least privilege
graph TD A[Enumerate IAM] -->|List users roles policies| B[Find Misconfig] B -->|Wildcard or broad policy| C[Escalate Privileges] C -->|Assume higher role| D[Access Data] D -->|Exfiltrate or pivot| E[Remediate] style A fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style B fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style C fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style D fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style E fill:#1e3d2f,stroke:#10B981,color:#e2e8f0

Every one of these paths is exploitable without any AWS vulnerability — they're consequences of policy design. That's why cloud pentesting has to test the permission logic, not just scan for public resources.

SSRF to IMDS: Stealing Instance Credentials

Server-side request forgery (SSRF) is one of the most consequential web vulnerabilities in an AWS context, because of what sits behind it: the Instance Metadata Service (IMDS). Every EC2 instance can query a well-known internal address for metadata about itself — including the temporary credentials attached to its IAM instance role.

If a web application on that instance has an SSRF flaw — say, a "fetch URL for preview" feature that doesn't validate the target — an attacker can direct that request at the metadata endpoint instead of an external URL. The application, running with the instance's network access, fetches the role's temporary access key, secret key, and session token and returns them in the response. The attacker now has valid AWS credentials with whatever permissions that role holds, usable from outside the network.

🛡️
SECURITY
This exact technique was central to one of the highest-profile cloud breaches on record, where an SSRF flaw was used to reach the metadata service and pull role credentials later used to exfiltrate stored data at scale. It is precisely why IMDSv2 exists.

IMDSv2 closes this hole by requiring a session token — a PUT request first, then a GET that includes it in a header — rather than the original simple GET-only IMDSv1 protocol. Most SSRF payloads can trivially perform a GET but not the two-step sequence, which is why enforcing IMDSv2 account-wide meaningfully reduces this attack path.

S3 Bucket Exposure and Overly Permissive Policies

S3 misconfiguration remains one of the most consistently exploited AWS weaknesses, largely because bucket policies, ACLs, and account-level Block Public Access settings interact in ways that are easy to get wrong. A bucket policy granting s3:GetObject to Principal: "*" makes every object world-readable regardless of what the console UI implies, and older buckets can carry forward public settings nobody remembers configuring.

This phase is largely enumeration-driven: tools brute-force likely bucket names, check s3:GetBucketAcl and s3:GetBucketPolicy where credentials are already held, and attempt anonymous reads against discovered buckets. What's exposed varies enormously — from harmless static assets to customer data exports, database backups, or source code with embedded credentials.

💡
TIP
Enable S3 Block Public Access at the account level as a default-deny baseline, and require an explicit, reviewed exception for any bucket that genuinely needs public objects. Pair this with S3 Access Analyzer, which flags buckets accessible from outside the account automatically.

Lambda and Role Abuse

Lambda functions frequently run with execution roles broader than the function needs, because it's easier to attach one wide role than to scope permissions per-function. An attacker who compromises a function — via a vulnerable dependency, an injection flaw, or a leaked deployment package — inherits its execution role's full permission set, including cross-service access the function itself never uses.

A related risk sits in environment variables: database credentials and API keys are commonly stored there in plaintext rather than Secrets Manager, and any principal with lambda:GetFunctionConfiguration permission can read them directly, without compromising the function's code at all.

pie title Cloud Attack Technique Distribution in AWS Pentests "IAM Misconfiguration and Escalation" : 30 "SSRF to Metadata Credential Theft" : 20 "S3 and Storage Exposure" : 20 "Lambda and Role Abuse" : 15 "Network and Security Group Gaps" : 15

Defence in Depth: The Controls That Actually Close These Paths

Every technique above has a specific, well-documented control. The gap between "known best practice" and "actually enforced" is where most real breaches happen — these controls are rarely secret, just inconsistently applied across fast-growing environments.

Attack techniquePrimary defence
IAM enumeration and privilege escalationLeast-privilege policies, scoped PassRole, regular IAM Access Analyzer review
SSRF to IMDS credential theftEnforce IMDSv2 account-wide, restrict outbound SSRF via input validation
S3 bucket exposureBlock Public Access at account level, S3 Access Analyzer, no public-by-default
Overly permissive policiesService Control Policies (SCPs) at the organisation level, policy linting in CI/CD
Lambda and role abusePer-function scoped execution roles, secrets in Secrets Manager not environment variables
Undetected lateral movementAmazon GuardDuty enabled account-wide, CloudTrail logging to a separate, restricted account
SCPs, applied at the AWS Organizations level, are one of the highest-leverage controls here — they set a hard ceiling on what any account can do, even a fully compromised administrator credential. GuardDuty adds continuous, managed detection for the exact behaviours above — anomalous API calls, unusual-location credential use, metadata service abuse — without a custom rule to write first.
ℹ️
NOTE
CloudTrail logs are only a reliable forensic source if they can't be tampered with by the same compromised identity that generated them. Route CloudTrail to a separate logging account with restricted write access, so an attacker who escalates privileges in the primary account still can't erase the evidence of how they got there.
82%Breaches in 2023 involving data stored in a cloud environment (IBM Cost of a Data Breach Report 2023)

This figure is drawn from IBM's Cost of a Data Breach Report. CERT-In advisories have separately and repeatedly flagged misconfigured cloud identity and access controls as a recurring root cause in incidents reported by Indian organisations, per periodic advisories published by CERT-In, India's national computer emergency response team.

🎯Key Takeaway
AWS attack chains rarely exploit a flaw in AWS's own infrastructure — they exploit identity and permission design decisions the customer made. Testing that chain end-to-end, from IAM enumeration through privilege escalation to data access, is what a real cloud pentest verifies. A misconfiguration checklist alone cannot show whether those gaps are actually chainable into a full compromise.

Where This Fits Into a Broader Cloud Security Programme

Cloud environments change faster than most annual audit cycles can track — a new IAM role, Lambda function, or S3 bucket can introduce an exploitable path the same week it's created. A structured AWS penetration test, run against a properly scoped account under AWS's own testing policy, verifies whether the attack chains above are actually exploitable, not just whether individual settings look correct in isolation. Where regulatory submission requires it, this is typically delivered with a CERT-In empanelled partner. Bachao.AI, built by Dhisattva AI Pvt Ltd, gives Indian cloud teams continuous visibility into exactly these misconfiguration classes between audit cycles. Organisations processing personal data in AWS should also map findings against obligations under India's DPDP Act, since an exposed S3 bucket or over-privileged role can itself constitute a reportable incident.

Want to know whether your AWS account has an exploitable privilege-escalation path right now? Get a free VAPT scan, or browse the Bachao.AI blog for more technique-level security guides.

Frequently Asked Questions

Is AWS penetration testing legal without special permission?
Yes, for resources you own. AWS's self-service penetration testing policy pre-authorises testing of your own AWS-owned resources across a defined list of in-scope services, provided you avoid prohibited activities like DDoS testing or testing another customer's infrastructure.
What is the difference between IMDSv1 and IMDSv2?
IMDSv1 allows any simple GET request to the metadata endpoint to return the instance role's credentials, making it trivially abusable via SSRF. IMDSv2 requires a session token obtained via a PUT request first, which most SSRF payloads cannot easily replicate.
How do attackers escalate privileges in AWS IAM?
Through documented patterns like using iam:PassRole with Lambda or EC2 to run code under a higher-privilege role, attaching an administrative policy directly to a user they control, or exploiting a trust policy that allows role assumption by a broader set of principals than intended.
What is the single highest-impact control against these attack techniques?
Least-privilege IAM policy design, reinforced with Service Control Policies at the organisation level and IMDSv2 enforced account-wide. Together these remove most escalation paths and credential-theft techniques before individual misconfigurations are even found.
Why is S3 bucket exposure still common despite AWS defaults?
Many buckets were created before Block Public Access became the account-level default, and legacy policies or ACLs can carry forward public settings that predate it. Without periodic audits using tools like S3 Access Analyzer, older misconfigurations go unnoticed indefinitely.
What does GuardDuty actually detect in an AWS attack chain?
GuardDuty continuously analyses CloudTrail, VPC Flow Logs, and DNS logs for anomalous behaviour — credential use from unusual geographies, API call patterns consistent with enumeration, and signs of metadata service abuse — without requiring a custom detection rule first.
BR

Bachao.AI Research Team

Cybersecurity Research

AI-powered security research and threat intelligence from the Bachao.AI team. Covering the latest vulnerabilities, CVEs, and cybersecurity developments affecting Indian businesses.

Get cybersecurity insights for Indian SMBs

Weekly vulnerability alerts, DPDP compliance tips, and security guides. No spam — unsubscribe anytime.

We respect your privacy. Your email is never shared.

Find out if you're exposed to this class of threat

Free automated scan — risk score in under 2 hours. No credit card required.

Scan Your Attack Surface
Find your vulnerabilitiesStart free scan →