Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Cloud security posture management (CSPM) alerts on unauthorized resource changes
CloudTrail, Azure Activity Logs, or GCP Audit Logs show suspicious API calls
Cloud access keys or service principal credentials are suspected compromised
Unauthorized compute instances, storage buckets, or IAM changes are detected
A cloud-hosted application is breached and attacker activity spans cloud services
Do not use for on-premises-only incidents with no cloud component; use standard enterprise IR procedures.
Common Misconfigurations & Verification
Logging not enabled before the incident: the fatal gap. CloudTrail data events (S3 object-level, Lambda), VPC/NSG Flow Logs, and Azure Sign-in Logs are off or short-retention by default — if they weren't on, the evidence simply does not exist. Confirm coverage first; absence of events is not absence of activity.
Containment that tips off the attacker or breaks evidence: terminating the EC2 instance or deleting the IAM user destroys volatile state and memory before you snapshot. Isolate via security group / NSG deny-all and snapshot EBS/managed disks first, then eradicate.
STS/refresh tokens survive key disablement: disabling an access key or AccountEnabled=$false does NOT kill already-issued temporary credentials. You must add a aws:TokenIssueTime deny condition (AWS) or Revoke-AzureADUserAllRefreshToken (Azure) or the attacker keeps acting with assumed-role sessions until expiry.
Single-region tunnel vision: crypto-mining RunInstances and backdoor IAM users get deployed across every region/all regions — checking only the home region misses them.
Persistence missed: attacker-created access keys, additional IAM users, service-principal secrets, Lambda functions, and login profiles outlive the original compromised identity.
Verify containment actually held: re-query CloudTrail/Activity Logs and confirm zero successful API calls from the attacker IP/identity after the containment timestamp; confirm disabled keys and rotated creds are rejected; enumerate IAM/SP credentials across all regions to prove no backdoor remains; and confirm disabled security controls (CloudTrail, GuardDuty, Defender) are re-enabled and logging.
CloudTrail suspicious events to investigate:
- ConsoleLogin from unexpected geolocation or IP
- CreateAccessKey for existing IAM user (persistence)
- RunInstances for crypto-mining (large instance types)
- PutBucketPolicy making S3 bucket public
- AssumeRole to cross-account roles
- DeleteTrail or StopLogging (defense evasion)
- CreateUser or AttachUserPolicy (privilege escalation)
Azure Indicators:
Azure Activity Log events to investigate:
- Sign-in from anonymous IP or TOR exit node
- Service principal credential added
- Role assignment changes (Owner, Contributor added)
- VM created in unusual region
- Storage account access key regenerated
- Conditional Access policy modified or deleted
- MFA disabled for user account
GCP Indicators:
GCP Audit Log events to investigate:
- SetIamPolicy changes granting broad access
- CreateServiceAccountKey for existing SA
- InsertInstance in unexpected zone
- SetBucketIamPolicy with allUsers
- DeleteLog or UpdateSink (log tampering)
Step 2: Contain Cloud Identity Compromise
Cloud containment is primarily an identity operation:
AWS Containment:
# Disable compromised IAM access keys
aws iam update-access-key --user-name compromised-user \
--access-key-id AKIA... --status Inactive
# Attach deny-all policy to compromised user
aws iam attach-user-policy --user-name compromised-user \
--policy-arn arn:aws:iam::aws:policy/AWSDenyAll
# Revoke all active sessions for compromised IAM role
aws iam put-role-policy --role-name compromised-role \
--policy-name RevokeOlderSessions --policy-document '{
"Version":"2012-10-17",
"Statement":[{
"Effect":"Deny",
"Action":"*",
"Resource":"*",
"Condition":{"DateLessThan":
{"aws:TokenIssueTime":"2025-11-15T15:00:00Z"}}
}]
}'# Isolate compromised EC2 instance
aws ec2 modify-instance-attribute --instance-id i-0abc123 \
--groups sg-isolate-forensic
Steampipe: Open-source SQL-based tool for querying cloud APIs to investigate IAM configurations and resource states
Cartography (Lyft): Open-source tool for mapping cloud infrastructure relationships and identifying attack paths
Common Scenarios
Scenario: AWS Access Key Compromised via Public GitHub Repository
Context: AWS GuardDuty alerts on API calls from an unexpected IP address using an IAM user's access key. The key was accidentally committed to a public GitHub repository 4 hours ago.
Approach:
Immediately disable the compromised access key via AWS IAM
Attach AWSDenyAll policy to the affected IAM user
Query CloudTrail for all API calls made with the compromised key since exposure
Identify resources created or modified by the attacker (EC2 instances for crypto-mining, new IAM users for persistence)
Terminate unauthorized resources and remove backdoor IAM entities
Rotate all credentials the compromised user had access to
Enable GitHub secret scanning to prevent future credential leaks
Pitfalls:
Only disabling the access key without checking for new access keys or IAM users created as persistence
Not checking all AWS regions for attacker-created resources (crypto-miners deployed in every region)
Forgetting to revoke temporary credentials from assumed roles (STS tokens remain valid until expiry)
Not calculating the financial impact of unauthorized resource usage for insurance claims
Output Format
CLOUD INCIDENT RESPONSE REPORT
================================
Incident: INC-2025-1705
Cloud Provider: AWS (Account: 123456789012)
Date Detected: 2025-11-15T14:00:00Z
Detection Source: GuardDuty - UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration
COMPROMISE SUMMARY
Initial Access: IAM access key exposed in public GitHub repo
Affected Identity: iam-user: deploy-bot (AKIA...)
Attacker IP: 203.0.113.42 (VPN exit node, Netherlands)
Duration: 4 hours (10:00 UTC - 14:00 UTC)
ATTACKER ACTIVITY (from CloudTrail)
10:15 UTC - DescribeInstances (reconnaissance)
10:18 UTC - RunInstances x 12 (c5.4xlarge, all regions - crypto-mining)
10:22 UTC - CreateUser "backup-admin" (persistence)
10:23 UTC - CreateAccessKey for "backup-admin"
10:25 UTC - AttachUserPolicy - AdministratorAccess to "backup-admin"
10:30 UTC - PutBucketPolicy - s3://data-bucket made public (exfiltration)
CONTAINMENT ACTIONS
[x] Original access key disabled
[x] User policy set to AWSDenyAll
[x] Backdoor IAM user "backup-admin" deleted
[x] 12 crypto-mining instances terminated (all regions)
[x] S3 bucket policy restored to private
FINANCIAL IMPACT
Unauthorized EC2: $2,847 (4 hours x 12 x c5.4xlarge)
Data Transfer: $127 (S3 public access data egress)
Total: $2,974
POST-INCIDENT HARDENING
1. GitHub secret scanning enabled
2. Access key rotation policy implemented
3. SCP preventing CloudTrail disablement deployed
4. GuardDuty auto-remediation Lambda configured