RAWS playbook · Compute and containers
Resource hijacking and cryptomining
The attacker launches large or GPU instances, often in Regions you never use, and asks for higher quotas to run more of them. Spot requests, fleets and Auto Scaling groups relaunch instances you terminate. Contain the launching identity first, then remove the relaunch mechanism before you clean up.
Look here
| Log | Search for |
|---|---|
| CloudTrail, EC2 events | Launches, key pairs and opened ports in every Region: RunInstances, RequestSpotInstances, CreateFleet, ImportKeyPair, CreateKeyPair, AuthorizeSecurityGroupIngress |
| CloudTrail, every Region | RunInstances calls in each enabled Region, saved to one file per Region: for r in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do aws cloudtrail lookup-events --region $r --lookup-attributes AttributeKey=EventName,AttributeValue=RunInstances --start-time <utc> > <case>-runinstances-$r.json; done |
| CloudTrail, Auto Scaling | Groups and templates that relaunch instances. A group with a desired capacity above zero replaces any instance you terminate: CreateAutoScalingGroup, UpdateAutoScalingGroup, CreateLaunchTemplate, CreateLaunchTemplateVersion |
| Running instances, every Region | Running instances with type, launch time and instance profile: for r in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do aws ec2 describe-instances --region $r --filters Name=instance-state-name,Values=running --query "Reservations[].Instances[].[InstanceId,InstanceType,LaunchTime,IamInstanceProfile.Arn]" --output text; done |
CloudTrail, servicequotas.amazonaws.com | Quota increase requests, logged as RequestServiceQuotaIncrease. History for a Region: aws service-quotas list-requested-service-quota-change-history --service-code ec2 --region <region> |
| GuardDuty | Mining findings: CryptoCurrency:EC2/BitcoinTool.B, CryptoCurrency:EC2/BitcoinTool.B!DNS, Impact:EC2/BitcoinDomainRequest.Reputation |
| GuardDuty Runtime Monitoring | Mining findings from the agent: CryptoCurrency:Runtime/BitcoinTool.B, Impact:Runtime/CryptoMinerExecuted, Impact:Runtime/BitcoinDomainRequest.Reputation |
| Billing | EC2 cost by Region and instance type for the incident window, in Cost Explorer. Cost Anomaly Detection alerts, if configured, often show the start time |
Contain
| # | Item |
|---|---|
| 1 | Contain the identity that launched the instances, using credential leak or account takeover |
| 2 | Snapshot one instance per launch pattern as evidence |
| 3 | Cancel the attacker's Spot requests before you stop or terminate their instances: aws ec2 cancel-spot-instance-requests --region <region> --spot-instance-request-ids <id> |
| 4 | Set each attacker Auto Scaling group to zero: aws autoscaling update-auto-scaling-group --region <region> --auto-scaling-group-name <asg> --min-size 0 --max-size 0 --desired-capacity 0 |
| 5 | Stop the attacker's instances: aws ec2 stop-instances --region <region> --instance-ids <id> <id> |
| 6 | Create a Region deny service control policy (SCP) on aws:RequestedRegion, with global services in NotAction: aws organizations create-policy --content file://region-deny.json --name ir-region-deny --type SERVICE_CONTROL_POLICY --description "<case>" |
| 7 | Attach the Region deny SCP: aws organizations attach-policy --policy-id <p-id> --target-id <ou-or-account> |
Eradicate and recover
| # | Item |
|---|---|
| 1 | Terminate the attacker's instances once evidence is captured destructive: aws ec2 terminate-instances --region <region> --instance-ids <id> |
| 2 | Delete the fleets, Auto Scaling groups, launch templates, key pairs and security groups the attacker created, in every Region |
| 3 | Reduce quotas the attacker raised, and review quota increase requests still open |
| 4 | Open an AWS Support case about the unauthorized usage and charges |
| 5 | Set budget alerts that cover Regions you do not use |
Watch out
- Test the Region deny SCP on one account first. Its
NotActionlist must keep global services such as IAM, Organizations and STS working. Start from the AWS example policy. - Terminating an instance launched by a persistent Spot request reopens the request, which launches a new instance. Cancel the request first.
- Stopped instances still bill for their EBS volumes and Elastic IP addresses.