October 21, 2025
Updated: November 5, 2026
The complete 2026 guide for ethical hackers and security engineers performing AWS penetration testing from reconnaissance to privilege escalation and detection evasion.
Ahmed M. Arafat

Quick Reference for AWS Penetration Testers:
AWS is the largest cloud infrastructure provider, with a 26% share of worldwide cloud infrastructure services spending in Q3 2026, according to Synergy Research Group, and it hosts workloads for millions of organizations. As enterprises migrate critical workloads to AWS, understanding the security implications and attack surfaces becomes paramount. Unlike traditional infrastructure, AWS presents unique challenges: ephemeral compute instances, complex IAM policies, serverless architectures, and shared responsibility models.
DeepStrike’s PTaaS is also available on AWS Marketplace.
This comprehensive guide provides a structured methodology for conducting AWS cloud penetration testing from reconnaissance and enumeration to exploitation and privilege escalation designed for intermediate to senior security professionals. Testing Microsoft’s cloud as well? See our Azure penetration testing methodology.
Hiring rather than testing in-house? Compare AWS penetration testing companies or see DeepStrike's cloud penetration testing services.
Amazon Web Services (AWS) powers a significant portion of the internet's infrastructure. From startups to Fortune 500 companies, organizations trust AWS with their most sensitive data. For U.S. organizations testing AWS environments, this trust must be validated through rigorous security testing across IAM, S3, EC2, APIs, serverless workloads, and cloud network segmentation.
Key reasons for AWS penetration testing:
In 2019, Gartner predicted that "through 2025, 99% of cloud security failures will be the customer's fault."
— Gartner, "Is the Cloud Secure?" (October 2019)
Good news: AWS does not require pre-approval for penetration testing of the permitted services listed on its current penetration testing policy page (reviewed November 2026).
Important: To test services that are not on the permitted list, work directly with AWS Support or your AWS account representative. Any security testing that includes Command and Control (C2) requires prior approval. Covert red team simulations, simulated phishing, and malware testing require a Simulated Events form submitted at least two weeks before the start date. If you find a vulnerability in an AWS service itself, report it to AWS Security (aws-security@amazon.com) within 24 hours of completing testing.
When planning an isolated AWS testing environment, budget for compute, storage, and logging, and set spending alerts before deployment. Eligible teams may be able to use AWS credits to offset some infrastructure costs, subject to the offer’s eligibility requirements and covered services.
Testing Approaches:
Read More: Best Cloud Penetration Testing Companies: 2026 Buyer’s Guide.
AWS resources follow a hierarchical organization model:
AWS Organization (Root)
├── Organizational Units (OUs)
│ ├── Production Account
│ ├── Staging Account
│ └── Development Account
└── Management Account (formerly Master Account)
Each AWS Account contains:
├── Regions (geographic areas)
│ ├── Availability Zones (isolated data centers)
│ │ ├── VPCs (Virtual Private Clouds)
│ │ │ ├── Subnets (public/private)
│ │ │ │ ├── EC2 Instances
│ │ │ │ ├── RDS Databases
│ │ │ │ └── Other Resources
│ │ │ └── Security Groups & NACLs
│ │ └── S3 Buckets (global namespace but regional)
│ └── IAM (Identity & Access Management - global service)Key Security Services:
Goal: Discover publicly accessible S3 buckets and identify data exposure risks.
Common naming patterns:
# Company-based patterns
companyname-backup
companyname-logs
companyname-prod
companyname-dev
companyname-assets
companyname-data
# Application-based
app-name-uploads
app-name-static
webapp-mediaEnumeration techniques:
# Check if bucket exists (DNS resolution)
nslookup bucket-name.s3.amazonaws.com
# Try to list bucket contents (anonymous)
aws s3 ls s3://bucket-name --no-sign-request
# Download accessible files
aws s3 cp s3://bucket-name/file.txt . --no-sign-request
# Sync entire bucket (if accessible)
aws s3 sync s3://bucket-name ./local-dir --no-sign-requestCheck bucket ACL and policies:
# Get bucket ACL
aws s3api get-bucket-acl --bucket bucket-name
# Get bucket policy
aws s3api get-bucket-policy --bucket bucket-name
# Check public access block configuration
aws s3api get-public-access-block --bucket bucket-nameCommon misconfigurations:
public-read or public-read-write ACLsMitigation:
Goal: Discover valid IAM principals and harvest credentials from various sources.
Credential sources:
# Check common locations
~/.aws/credentials
~/.aws/config
.env files
config.json
Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
CI/CD configuration files (.gitlab-ci.yml, .github/workflows/*)
Container images (Docker layers)
Source code repositories
Instance user data scriptsCheck identity and IAM read access:
# Requires iam:GetUser on the target user; AccessDenied does not confirm whether the user exists
aws iam get-user --user-name target-user
# Enumerate current identity (works without any IAM permissions)
aws sts get-caller-identity
# List access keys for current user
aws iam list-access-keysTest credential permissions:
# Quick permission check
aws iam get-account-authorization-details --output json
# Enumerate accessible S3 buckets
aws s3 ls
# List EC2 instances
aws ec2 describe-instances
# List Lambda functions
aws lambda list-functions
# Enumerate IAM roles
aws iam list-rolesPrivilege enumeration script:
#!/bin/bash
# Quick AWS permission checker
echo "[+] Checking caller identity..."
aws sts get-caller-identity
echo "[+] Attempting to list S3 buckets..."
aws s3 ls 2>/dev/null && echo "✓ S3 ListAllMyBuckets" || echo "✗ S3 access denied"
echo "[+] Attempting to list EC2 instances..."
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,State.Name]' --output text 2>/dev/null && echo "✓ EC2 Describe" || echo "✗ EC2 access denied"
echo "[+] Attempting to list IAM users..."
aws iam list-users 2>/dev/null && echo "✓ IAM List Users" || echo "✗ IAM access denied"
echo "[+] Attempting to list Lambda functions..."
aws lambda list-functions 2>/dev/null && echo "✓ Lambda List" || echo "✗ Lambda access denied"Mitigation:
Goal: Confirm that no application or workload on an EC2 instance can be used to obtain the instance role's temporary credentials from the Instance Metadata Service (IMDS), and that the role would have limited reach if it were.
Most real-world IMDS exposure starts with an SSRF in an application running on the instance.
What the tester checks:
HttpTokens set to optional). IMDSv1 answers a single unauthenticated GET, so any bug that lets an outsider steer a server-side request can reach it.Safe verification (read-only, run by the account owner):
# List instances that still allow IMDSv1 (HttpTokens = optional)
aws ec2 describe-instances \
--filters "Name=metadata-options.http-tokens,Values=optional" \
--query "Reservations[*].Instances[*].[InstanceId]" --output text
# Review metadata settings for every instance
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceId,MetadataOptions.HttpTokens,MetadataOptions.HttpPutResponseHopLimit,MetadataOptions.HttpEndpoint]" \
--output table
# Count IMDSv1 calls before enforcing IMDSv2 (CloudWatch metric MetadataNoToken, namespace AWS/EC2)
aws cloudwatch get-metric-statistics --namespace AWS/EC2 \
--metric-name MetadataNoToken \
--dimensions Name=InstanceId,Value=i-1234567890abcdef0 \
--start-time 2026-10-29T00:00:00Z --end-time 2026-11-05T00:00:00Z \
--period 86400 --statistics SumSSRF and the metadata service:
A server-side request forgery flaw lets an outsider make the application send requests on their behalf, so an endpoint that is only reachable from inside the instance, such as IMDS, becomes reachable from the internet. IMDSv2 blunts this: a session token must first be requested with a PUT call carrying a custom header, which most SSRF bugs cannot send, and a hop limit of 1 keeps the token response from leaving the instance. Testers report SSRF as the root cause and IMDSv1 as the factor that turns it into credential exposure. Our guide to server-side request forgery (SSRF) explains the vulnerability class and how to fix it in application code.
Policy guardrails (IAM condition keys):
ec2:MetadataHttpTokens: in an IAM policy or SCP, deny ec2:RunInstances and ec2:ModifyInstanceMetadataOptions unless the value is required, so nobody can launch an IMDSv1 instance or switch one back.ec2:MetadataHttpPutResponseHopLimit: cap the hop limit that launches and modifications may set.ec2:RoleDelivery: require a value of 2.0 so API calls made with role credentials that were delivered through IMDSv1 fail with UnauthorizedOperation.Mitigation:
aws ec2 modify-instance-metadata-options --instance-id i-xxx --http-tokens required --http-endpoint enabled--http-put-response-hop-limit 1 (use 2 if containers on the instance need IMDS)aws ec2 modify-instance-metadata-defaults (or an AWS Organizations declarative policy), then enforce it once MetadataNoToken shows zero IMDSv1 calls.UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS and UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.InsideAWS, which flag EC2 instance-role credentials used from outside AWS or from a different AWS account.Goal: Discover Lambda functions and extract source code that may contain hardcoded secrets.
Enumeration:
# List all Lambda functions
aws lambda list-functions --output table
# Get function configuration
aws lambda get-function-configuration --function-name function-name
# Get function code location
aws lambda get-function --function-name function-name
# Download function code
aws lambda get-function --function-name function-name --query 'Code.Location' --output text | xargs curl -o function.zip
# Extract and review
unzip function.zip
grep -r "password\\|secret\\|key\\|token" .Check environment variables:
# Extract environment variables (may contain secrets)
aws lambda get-function-configuration --function-name function-name --query 'Environment.Variables'Review Lambda execution role:
# Get execution role ARN
ROLE_ARN=$(aws lambda get-function-configuration --function-name function-name --query 'Role' --output text)
# Get role name from ARN
ROLE_NAME=$(echo $ROLE_ARN | awk -F'/' '{print $NF}')
# Get attached policies
aws iam list-attached-role-policies --role-name $ROLE_NAME
# Get inline policies
aws iam list-role-policies --role-name $ROLE_NAMETest Lambda invocation:
# Invoke function (if you have permissions)
aws lambda invoke --function-name function-name --payload '{"key":"value"}' output.txt
# Review output
cat output.txtMitigation:
Goal: Identify publicly shared or accessible RDS snapshots containing sensitive data.
Enumeration:
# List all RDS snapshots
aws rds describe-db-snapshots --output table
# Public sharing is not a DBSnapshot field; check each snapshot's attributes for restore = all (see below)
# Describe specific snapshot
aws rds describe-db-snapshot-attributes --db-snapshot-identifier snapshot-nameCheck snapshot sharing:
# Get snapshot attributes
aws rds describe-db-snapshot-attributes --db-snapshot-identifier snapshot-id
# Look for "all" in restore attribute (public)What the tester checks: whether any manual snapshot's restore attribute contains all (public) or account IDs nobody can explain, and whether snapshots are encrypted. The finding is proven by the attribute itself; copying or restoring the snapshot adds no evidence and would move customer data.
# Which manual snapshots are public or shared with other accounts? (read-only)
for s in $(aws rds describe-db-snapshots --snapshot-type manual --query 'DBSnapshots[*].DBSnapshotIdentifier' --output text); do
echo "$s: $(aws rds describe-db-snapshot-attributes --db-snapshot-identifier $s \
--query "DBSnapshotAttributesResult.DBSnapshotAttributes[?AttributeName=='restore'].AttributeValues" --output text)"
done
# Which snapshots are unencrypted?
aws rds describe-db-snapshots --query 'DBSnapshots[?Encrypted==`false`].DBSnapshotIdentifier' --output text
# Who changed snapshot sharing recently?
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=ModifyDBSnapshotAttributeMitigation:
ModifyDBSnapshotAttribute calls that add all or an unknown account; GuardDuty Exfiltration:IAMUser/AnomalousBehavior also flags anomalous calls such as RestoreDBInstanceFromDBSnapshot.Goal: Identify publicly shared or unencrypted EBS snapshots that could expose data to other accounts.
Enumeration:
# List all EBS snapshots owned by you
aws ec2 describe-snapshots --owner-ids self
# Search for public snapshots (specific region)
aws ec2 describe-snapshots --restorable-by-user-ids all --region us-east-1
# Describe specific snapshot
aws ec2 describe-snapshot-attribute --snapshot-id snap-xxx --attribute createVolumePermissionCheck snapshot exposure (read-only):
# Which of your snapshots are public or shared with other accounts?
for s in $(aws ec2 describe-snapshots --owner-ids self --query 'Snapshots[*].SnapshotId' --output text); do
echo "$s: $(aws ec2 describe-snapshot-attribute --snapshot-id $s --attribute createVolumePermission --query 'CreateVolumePermissions' --output json)"
done
# Which snapshots are unencrypted?
aws ec2 describe-snapshots --owner-ids self --query 'Snapshots[?Encrypted==`false`].SnapshotId' --output text
# Is block public access for EBS snapshots turned on in this Region?
aws ec2 get-snapshot-block-public-access-stateMitigation:
Goal: Extract sensitive information from CloudFormation templates and parameters.
Enumeration:
# List all CloudFormation stacks
aws cloudformation list-stacks --output table
# Describe specific stack
aws cloudformation describe-stacks --stack-name stack-name
# Get stack resources
aws cloudformation describe-stack-resources --stack-name stack-name
# Get template body (may contain hardcoded secrets)
aws cloudformation get-template --stack-name stack-name --query 'TemplateBody' --output text
# Extract parameters (often contains secrets)
aws cloudformation describe-stacks --stack-name stack-name --query 'Stacks[0].Parameters'Look for sensitive data:
# Download template
aws cloudformation get-template --stack-name stack-name --query 'TemplateBody' --output text > template.yaml
# Search for secrets
grep -i "password\\|secret\\|key\\|token" template.yamlMitigation:
NoEcho: true for sensitive parametersGoal: Determine who can read which secrets and parameters, and confirm that access is scoped, rotated, and monitored.
What the tester checks: which principals are allowed secretsmanager:GetSecretValue or ssm:GetParameter* on which resources, whether resource policies grant cross-account access, whether rotation is turned on, and whether credentials sit in plain String parameters instead of SecureString. The IAM policy simulator answers the access question without reading a single secret value.
Secrets Manager:
# Inventory: rotation status and last access (metadata only, no secret values)
aws secretsmanager list-secrets \
--query 'SecretList[*].[Name,RotationEnabled,LastRotatedDate,LastAccessedDate]' --output table
# Does a resource policy grant access outside the account?
aws secretsmanager get-resource-policy --secret-id prod/db-credentials
# Would this principal be allowed to read the secret? (simulation only)
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/app-role \
--action-names secretsmanager:GetSecretValue secretsmanager:BatchGetSecretValue \
--resource-arns arn:aws:secretsmanager:us-east-1:111122223333:secret:prod/db-credentials-AbCdEf \
--query 'EvaluationResults[*].[EvalActionName,EvalDecision]' --output tableParameter Store:
# Which parameters are plain String rather than SecureString? (names and types only)
aws ssm describe-parameters --query 'Parameters[*].[Name,Type,LastModifiedDate]' --output table
# Would this principal be allowed to read parameters under a path? (simulation only)
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/app-role \
--action-names ssm:GetParameter ssm:GetParameters ssm:GetParametersByPath \
--resource-arns arn:aws:ssm:us-east-1:111122223333:parameter/production/db-password \
--query 'EvaluationResults[*].[EvalActionName,EvalDecision]' --output tableDetection:
Bulk reads show up in CloudTrail as bursts of GetSecretValue, BatchGetSecretValue, or GetParameter* calls from one principal. GuardDuty CredentialAccess:IAMUser/AnomalousBehavior flags anomalous GetSecretValue and BatchGetSecretValue requests. To review recent access:
# Who read secrets recently? (CloudTrail event history, last 90 days)
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=GetSecretValue \
--query 'Events[*].[EventTime,Username]' --output tableMitigation:
Goal: Identify exposed or misconfigured API Gateway endpoints.
Enumeration:
# List all APIs
aws apigateway get-rest-apis
# Get API details
aws apigateway get-rest-api --rest-api-id api-id
# List resources
aws apigateway get-resources --rest-api-id api-id
# Get method configuration
aws apigateway get-method --rest-api-id api-id --resource-id resource-id --http-method GETCommon API patterns:
https://{api-id}.execute-api.{region}.amazonaws.com/{stage}/{resource}Test authentication:
# Test without authentication
curl https://api-id.execute-api.us-east-1.amazonaws.com/prod/endpoint
# Test with API key
curl -H "x-api-key: key" <https://api-id.execute-api.us-east-1.amazonaws.com/prod/endpoint
# Test authorization bypass
curl -H "Authorization: Bearer fake-token" https://api-id.execute-api.us-east-1.amazonaws.com/prod/endpointCommon misconfigurations:
Mitigation:
Goal: Determine whether a compromised container could break isolation or reach host, task, or cluster credentials, and confirm the controls that prevent it.
ECS task roles and the task metadata endpoint:
ECS tasks receive their task role credentials from a local credentials endpoint, so the same SSRF and code-execution risks that apply to IMDS apply here. The tester checks which role each task uses, what that role allows, and whether any task runs privileged or mounts host paths, all from the control plane:
# Which task role and execution role does a task definition use?
aws ecs describe-task-definition --task-definition my-task:1 \
--query 'taskDefinition.[taskRoleArn,executionRoleArn,networkMode]'
# Do any containers run privileged, as root, or with host mounts?
aws ecs describe-task-definition --task-definition my-task:1 \
--query 'taskDefinition.containerDefinitions[*].[name,privileged,user,mountPoints]'EKS Privilege Escalation:
# What can a given service account do? (read-only)
kubectl auth can-i --list --as=system:serviceaccount:my-namespace:my-sa
# Can it create pods? Pod creation is a common escalation path
kubectl auth can-i create pods --as=system:serviceaccount:my-namespace:my-sa -n my-namespace
# List pods
kubectl get pods --all-namespaces
# Check for privileged containers
kubectl get pods -o json | jq '.items[] | select(.spec.containers[].securityContext.privileged==true)'
# Which namespaces enforce Pod Security Standards?
kubectl get namespaces -L pod-security.kubernetes.io/enforceContainer escape exposure checks:
# Run inside a container in scope for the authorized test
# Check effective capabilities (a full set suggests --privileged)
cat /proc/1/status | grep CapEff
# Check for a Docker socket mount (access to it is equivalent to root on the host)
ls -la /var/run/docker.sock
# Either finding is reportable on its own; no escape attempt is needed to prove impactMitigation:
UnauthorizedAccess:IAMUser/ResourceCredentialExfiltration.OutsideAWS and UnauthorizedAccess:IAMUser/ResourceCredentialExfiltration.InsideAWS, which flag ECS task or Lambda function credentials used outside the resource that received them.Goal: Confirm that logging cannot be silently stopped, redirected, or narrowed, and that any attempt raises an alert.
What the tester checks:
cloudtrail:StopLogging, DeleteTrail, UpdateTrail, and PutEventSelectors, and whether an SCP restricts them to a break-glass role.Safe verification (read-only):
# Is each trail multi-Region, validated, and logging?
aws cloudtrail describe-trails \
--query 'trailList[*].[Name,IsMultiRegionTrail,IsOrganizationTrail,LogFileValidationEnabled,S3BucketName]' --output table
aws cloudtrail get-trail-status --name trail-name --query '[IsLogging,LatestDeliveryTime,LatestDeliveryError]'
# Which events does the trail record?
aws cloudtrail get-event-selectors --trail-name trail-name
# Have any log files been changed or deleted?
aws cloudtrail validate-logs --trail-arn arn:aws:cloudtrail:us-east-1:111122223333:trail/trail-name \
--start-time 2026-11-01T00:00:00Z
# Could this principal stop or change logging? (simulation only)
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/ops-role \
--action-names cloudtrail:StopLogging cloudtrail:DeleteTrail cloudtrail:UpdateTrail cloudtrail:PutEventSelectors \
--query 'EvaluationResults[*].[EvalActionName,EvalDecision]' --output tableDetection indicators:
Mitigation:
Stealth:IAMUser/CloudTrailLoggingDisabled fires when a trail is disabled or deleted, and DefenseEvasion:IAMUser/AnomalousBehavior flags anomalous calls such as StopLogging.Goal: Identify and exploit overly permissive IAM role trust policies and permissions.
Enumerate assumable roles:
# List all roles
aws iam list-roles
# Get role trust policy
aws iam get-role --role-name role-name --query 'Role.AssumeRolePolicyDocument'
# Look for roles with permissive trust policies
aws iam list-roles --query 'Roles[?AssumeRolePolicyDocument.Statement[?Principal.Service==`lambda.amazonaws.com`]]'Check escalation paths without exploiting them:
# Would this principal be allowed to perform known escalation actions? (simulation only, nothing is changed)
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:user/test-user \
--action-names iam:PassRole iam:CreateAccessKey iam:AttachUserPolicy \
iam:PutUserPolicy iam:UpdateAssumeRolePolicy iam:CreatePolicyVersion \
lambda:CreateFunction lambda:UpdateFunctionCode ec2:RunInstances \
--query 'EvaluationResults[*].[EvalActionName,EvalDecision]' --output table
# Who is trusted to assume a sensitive role?
aws iam get-role --role-name AdminRole --query 'Role.AssumeRolePolicyDocument'
# Find roles and resources shared outside the account or organization
aws accessanalyzer list-findings --analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/my-analyzerWell-documented AWS IAM privilege escalation techniques:
Mitigation:
Goal: Check whether a user pool lets outsiders discover valid accounts, self-register where the app doesn't need it, or sign in without risk and rate controls.
Enumerate user pools:
# List user pools
aws cognito-idp list-user-pools --max-results 60
# Get user pool details
aws cognito-idp describe-user-pool --user-pool-id us-east-1_XXXXX
# List users (requires admin privileges)
aws cognito-idp list-users --user-pool-id us-east-1_XXXXX
# Get user attributes
aws cognito-idp admin-get-user --user-pool-id us-east-1_XXXXX --username user@example.comWhat the tester checks:
PreventUserExistenceErrors is ENABLED on each app client. With LEGACY, sign-in returns UserNotFoundException, which confirms which accounts exist.SignUp always reports a taken username, but aliases keep it from confirming that an email address or phone number is registered.USER_PASSWORD_AUTH is enabled where SRP would do, whether MFA is required, and whether threat protection (AdvancedSecurityMode set to AUDIT or ENFORCED, Plus tier) is on.Safe verification (read-only):
# Pool-level settings: self-registration, aliases, MFA, threat protection
aws cognito-idp describe-user-pool --user-pool-id us-east-1_XXXXX \
--query 'UserPool.[AdminCreateUserConfig.AllowAdminCreateUserOnly,AliasAttributes,UsernameAttributes,MfaConfiguration,UserPoolAddOns.AdvancedSecurityMode]'
# App client settings: user-existence errors and allowed auth flows
aws cognito-idp describe-user-pool-client --user-pool-id us-east-1_XXXXX --client-id client-id \
--query 'UserPoolClient.[PreventUserExistenceErrors,ExplicitAuthFlows]'Mitigation:
Goal: Extract environment variables from Elastic Beanstalk that may contain secrets.
Enumeration:
# List all environments
aws elasticbeanstalk describe-environments
# Get environment configuration
aws elasticbeanstalk describe-configuration-settings \\
--application-name app-name \\
--environment-name env-name
# Extract environment variables
aws elasticbeanstalk describe-configuration-settings \\
--application-name app-name \\
--environment-name env-name \\
--query 'ConfigurationSettings[0].OptionSettings[?Namespace==`aws:elasticbeanstalk:application:environment`]'Alternative via EC2:
# SSH to Beanstalk EC2 instance
# Check environment variables
cat /opt/elasticbeanstalk/deployment/env
printenvMitigation:
For the concepts behind these paths, including vertical vs horizontal escalation and the ATT&CK TA0004 techniques, see what privilege escalation is.
| iam:AttachUserPolicy | Attach AdministratorAccess to current user |
|---|---|
| iam:CreateAccessKey | Create access key for privileged user |
| iam:PassRole + lambda:CreateFunction | Pass admin role to Lambda, invoke to escalate |
| iam:PutUserPolicy | Add inline admin policy to current user |
| iam:UpdateAssumeRolePolicy | Modify role trust to allow assumption |
| sts:AssumeRole + overly permissive trust | Assume higher-privilege role |
| ec2:RunInstances + iam:PassRole | Launch instance with privileged role |
| lambda:UpdateFunctionCode | Modify existing Lambda with privileged role |
In an authorized engagement, the useful question is whether the account would notice a backdoor, not whether one can be planted. For each common persistence technique below, the commands show how the owner can detect or review it with read-only calls. CloudTrail event history covers the last 90 days; use a trail or CloudTrail Lake for longer lookbacks.
1. Create new IAM user:
# Detect recently created IAM users and access keys
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=CreateUser
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=CreateAccessKey
# Review which users, groups, and roles hold AdministratorAccess
aws iam list-entities-for-policy --policy-arn arn:aws:iam::aws:policy/AdministratorAccess2. Add SSH key to EC2:
# Detect user data or key pair changes on instances
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=ModifyInstanceAttribute
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=ImportKeyPair3. Create Lambda backdoor:
# Detect new functions, then review the role each function runs as
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=CreateFunction20150331
aws lambda list-functions --query 'Functions[*].[FunctionName,Role,LastModified]' --output table4. Modify security group:
# Find security groups that allow SSH from anywhere
aws ec2 describe-security-groups \
--filters Name=ip-permission.from-port,Values=22 Name=ip-permission.cidr,Values=0.0.0.0/0 \
--query 'SecurityGroups[*].[GroupId,GroupName]' --output table
# Detect recent ingress rule changes
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=AuthorizeSecurityGroupIngress5. Create IAM role with external trust:
# Find roles that can be assumed from outside your zone of trust
aws accessanalyzer list-findings \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/my-analyzer \
--filter '{"resourceType": {"eq": ["AWS::IAM::Role"]}, "status": {"eq": ["ACTIVE"]}}'
# Detect trust policy changes
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=UpdateAssumeRolePolicy// High-severity events
- ConsoleLogin (especially from unusual locations)
- CreateAccessKey (especially for other users)
- DeleteTrail / StopLogging
- PutBucketPolicy (making buckets public)
- ModifySnapshotAttribute (making snapshots public)
- AuthorizeSecurityGroupIngress (0.0.0.0/0)
- AssumeRole (especially cross-account)
- AttachUserPolicy / AttachRolePolicy (privilege escalation)
- GetSecretValue (secret access)
- RunInstances (especially with privileged roles)Detect public S3 bucket creation:
{
"source": ["aws.s3"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventName": ["PutBucketAcl", "PutBucketPolicy"],
"requestParameters": {
"accessControlList": {
"grants": {
"grantee": {
"URI": ["http://acs.amazonaws.com/groups/global/AllUsers"]
}
}
}
}
}
}Detect CloudTrail deletion:
{
"source": ["aws.cloudtrail"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventName": ["DeleteTrail", "StopLogging", "UpdateTrail"]
}
}Enable GuardDuty for automatic threat detection:

Stay secure with DeepStrike penetration testing services. Reach out for a quote or customized technical proposal today
Contact Us